Review Board 1.7.16


Add ISDN Calling and Called Subaddress support functions to LIBPRI

Review Request #406 - Created Oct. 14, 2009 and submitted

Alec Davis
15604
Reviewers
asterisk-dev
mattf, rmudgett
LibPRI
Further Libpri support for subaddress, previously LIBPRI only supported receiving Calling Subaddress.

The first intentions of this are to add Transmit and Receive capabilites for Calling Subaddress and Called Subaddress.

Calling, Called, Connected and Redirecting Subaddress, now correctly supports User Specific type and the default NSAP.

Redirection and Redirecting Subaddress have been identified, but will come later.

 

Changes between revision 3 and 4

1 2 3 4 5 6 7
1 2 3 4 5 6 7

  1. /team/rmudgett/subaddr/q931.c: Loading...
/team/rmudgett/subaddr/q931.c
Diff Revision 3 Diff Revision 4
[20] 1538 lines
[+20] [+] static int receive_subaddr_helper(int full_ie, struct pri *ctrl, struct q931_party_subaddress *q931_subaddress, int msgtype, q931_ie *ie, int offset, int len)
1539
	q931_get_number((unsigned char *) q931_subaddress->data, sizeof(q931_subaddress->data), ie->data + offset, len );
1539
	q931_get_number((unsigned char *) q931_subaddress->data, sizeof(q931_subaddress->data), ie->data + offset, len );
1540

    
   
1540

   
1541
	return 0;
1541
	return 0;
1542
}
1542
}
1543

    
   
1543

   
1544
static void dump_subaddr_helper(int full_ie, struct pri *ctrl, q931_ie *ie, int offset, int len, char prefix, const char *named)
1544
static void dump_subaddr_helper(int full_ie, struct pri *ctrl, q931_ie *ie, int offset, int len, int datalen, char prefix, const char *named)
1545
{
1545
{
1546
	unsigned char cnum[256];
1546
	unsigned char cnum[256];
1547

    
   
1547

   
1548
	if (!(ie->data[0] & 0x70)) {
1548
	if (!(ie->data[0] & 0x70)) {
1549
		/* NSAP */
1549
		/* NSAP */
1550
		q931_get_number(cnum, sizeof(cnum), ie->data + 1, len);
1550
		q931_get_number(cnum, sizeof(cnum), ie->data + offset, datalen);
1551
	} else {
1551
	} else {
1552
		/* User Specified */
1552
		/* User Specified */
1553
		q931_get_subaddr_specific(cnum, sizeof(cnum), ie->data + offset, len, ie->data[0] & 0x08);
1553
		q931_get_subaddr_specific(cnum, sizeof(cnum), ie->data + offset, datalen, ie->data[0] & 0x08);
1554
	}
1554
	}
1555

    
   
1555

   
1556
	pri_message(ctrl, "%c %s Sub-Address (len=%2d) [ Ext: %d  Type: %s (%d)  O: %d  '%s' ]\n",
1556
	pri_message(ctrl, "%c %s Sub-Address (len=%2d) [ Ext: %d  Type: %s (%d)  O: %d  '%s' ]\n",
1557
		prefix, named, len, ie->data[0] >> 7,
1557
		prefix, named, len, ie->data[0] >> 7,
1558
		subaddrtype2str((ie->data[0] & 0x70) >> 4), (ie->data[0] & 0x70) >> 4,
1558
		subaddrtype2str((ie->data[0] & 0x70) >> 4), (ie->data[0] & 0x70) >> 4,
[+20] [20] 9 lines
[+20] [+] static void dump_called_party_number(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
1568
		prefix, len, ie->data[0] >> 7, ton2str((ie->data[0] >> 4) & 0x07), (ie->data[0] >> 4) & 0x07, npi2str(ie->data[0] & 0x0f), ie->data[0] & 0x0f, cnum);
1568
		prefix, len, ie->data[0] >> 7, ton2str((ie->data[0] >> 4) & 0x07), (ie->data[0] >> 4) & 0x07, npi2str(ie->data[0] & 0x0f), ie->data[0] & 0x0f, cnum);
1569
}
1569
}
1570

    
   
1570

   
1571
static void dump_called_party_subaddr(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
1571
static void dump_called_party_subaddr(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
1572
{
1572
{
1573
	dump_subaddr_helper(full_ie, ctrl, ie, 1 , len - 3, prefix, "Called");
1573
	dump_subaddr_helper(full_ie, ctrl, ie, 1 , len, len - 3, prefix, "Called");
1574
}
1574
}
1575

    
   
1575

   
1576
static void dump_calling_party_number(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
1576
static void dump_calling_party_number(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
1577
{
1577
{
1578
	unsigned char cnum[256];
1578
	unsigned char cnum[256];
[+20] [20] 8 lines
[+20] static void dump_calling_party_number(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
1587
		pri_message(ctrl, "%c                           Presentation: %s (%d)  '%s' ]\n", prefix, pri_pres2str(ie->data[1] & 0x7f), ie->data[1] & 0x7f, cnum);
1587
		pri_message(ctrl, "%c                           Presentation: %s (%d)  '%s' ]\n", prefix, pri_pres2str(ie->data[1] & 0x7f), ie->data[1] & 0x7f, cnum);
1588
}
1588
}
1589

    
   
1589

   
1590
static void dump_calling_party_subaddr(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
1590
static void dump_calling_party_subaddr(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
1591
{
1591
{
1592
	dump_subaddr_helper(full_ie, ctrl, ie, 1 , len - 3, prefix, "Calling");
1592
	dump_subaddr_helper(full_ie, ctrl, ie, 1 , len, len - 3, prefix, "Calling");
1593
}
1593
}
1594

    
   
1594

   
1595
static void dump_redirecting_number(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
1595
static void dump_redirecting_number(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
1596
{
1596
{
1597
	unsigned char cnum[256];
1597
	unsigned char cnum[256];
[+20] [20] 125 lines
[+20] [+] static int transmit_connected_subaddr(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len, int order)
1723
}
1723
}
1724

    
   
1724

   
1725
static void dump_connected_subaddr(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
1725
static void dump_connected_subaddr(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
1726
{
1726
{
1727
	/* XXX TODO XXX Check IE offsets, assumed they are the same as calling subaddress */
1727
	/* XXX TODO XXX Check IE offsets, assumed they are the same as calling subaddress */
1728
	dump_subaddr_helper(full_ie, ctrl, ie, 1 , len - 3, prefix, "Connected");
1728
	dump_subaddr_helper(full_ie, ctrl, ie, 1 , len, len - 3, prefix, "Connected");
1729
}
1729
}
1730

    
   
1730

   
1731
static int receive_redirecting_number(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len)
1731
static int receive_redirecting_number(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len)
1732
{
1732
{
1733
	int i = 0;
1733
	int i = 0;
[+20] [20] 47 lines
[+20] [+] static int transmit_redirecting_number(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len, int order)
1781
	return datalen + (3 + 2);
1781
	return datalen + (3 + 2);
1782
}
1782
}
1783

    
   
1783

   
1784
static void dump_redirecting_subaddr(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
1784
static void dump_redirecting_subaddr(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
1785
{
1785
{
1786
	dump_subaddr_helper(full_ie, ctrl, ie, 2 , len - 4, prefix, "Redirecting");
1786
	dump_subaddr_helper(full_ie, ctrl, ie, 2, len, len - 4, prefix, "Redirecting");
1787
}
1787
}
1788

    
   
1788

   
1789
static int receive_redirection_number(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len)
1789
static int receive_redirection_number(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len)
1790
{
1790
{
1791
	int i = 0;
1791
	int i = 0;
[+20] [20] 3741 lines
  1. /team/rmudgett/subaddr/q931.c: Loading...

https://reviewboard.asterisk.org/ runs on a server provided by Digium, Inc. and uses bandwidth donated to the open source Asterisk community by API Digital Communications in Huntsville, AL USA.
Please report problems with this site to asteriskteam@digium.com.