Review Board 1.7.16


use ie2str(full_ie) where possible in q931.c

Review Request #1633 - Created Dec. 18, 2011 and submitted

Alec Davis
1.4
Reviewers
asterisk-dev
rmudgett
LibPRI
compiles

Only 'dump_channel_id' left is.
basic calls.
adjust some output formatting as suggested.

Changes between revision 2 and 3

1 2 3
1 2 3

  1. branches/1.4/q931.c: Loading...
branches/1.4/q931.c
Diff Revision 2 Diff Revision 3
[20] 1502 lines
[+20] [+] static void dump_channel_id(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
1503
		"No channel selected", "B1 channel", "B2 channel", "Any channel selected",
1503
		"No channel selected", "B1 channel", "B2 channel", "Any channel selected",
1504
		"No channel selected", "As indicated in following octets", "Reserved", "Any channel selected"
1504
		"No channel selected", "As indicated in following octets", "Reserved", "Any channel selected"
1505
	};
1505
	};
1506

    
   
1506

   
1507
	pri_message(ctrl,
1507
	pri_message(ctrl,
1508
		"%c Channel ID (len=%2d) [ Ext: %d  IntID: %s  %s  Spare: %d  %s  Dchan: %d\n",
1508
		"%c %s (len=%2d) [ Ext: %d  IntID: %s  %s  Spare: %d  %s  Dchan: %d\n",
1509
		prefix, len,
1509
		prefix, ie2str(full_ie), len,
1510
		(ie->data[0] & 0x80) ? 1 : 0,
1510
		(ie->data[0] & 0x80) ? 1 : 0,
1511
		(ie->data[0] & 0x40) ? "Explicit" : "Implicit",
1511
		(ie->data[0] & 0x40) ? "Explicit" : "Implicit",
1512
		(ie->data[0] & 0x20) ? "Other(PRI)" : "BRI",
1512
		(ie->data[0] & 0x20) ? "Other(PRI)" : "BRI",
1513
		(ie->data[0] & 0x10) ? 1 : 0,
1513
		(ie->data[0] & 0x10) ? 1 : 0,
1514
		(ie->data[0] & 0x08) ? "Exclusive" : "Preferred",
1514
		(ie->data[0] & 0x08) ? "Exclusive" : "Preferred",
[+20] [20] 193 lines
[+20] [+] static void dump_bearer_capability(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
1708
		prefix, ie2str(full_ie), len, (ie->data[0] & 0x80 ) >> 7,
1708
		prefix, ie2str(full_ie), len, (ie->data[0] & 0x80 ) >> 7,
1709
		(ie->data[0] & 0x60) >> 5, cap2str(ie->data[0] & 0x1f),
1709
		(ie->data[0] & 0x60) >> 5, cap2str(ie->data[0] & 0x1f),
1710
		(ie->data[0] & 0x1f));
1710
		(ie->data[0] & 0x1f));
1711
	pri_message(ctrl, "%c                              Ext: %d  Trans mode/rate: %s (%d)\n", prefix, (ie->data[1] & 0x80) >> 7, mode2str(ie->data[1] & 0x7f), ie->data[1] & 0x7f);
1711
	pri_message(ctrl, "%c                              Ext: %d  Trans mode/rate: %s (%d)\n", prefix, (ie->data[1] & 0x80) >> 7, mode2str(ie->data[1] & 0x7f), ie->data[1] & 0x7f);
1712

    
   
1712

   
1713
	/* octet 4.1 exists iff mode/rate is multirate */
1713
	/* octet 4.1 exists if mode/rate is multirate */
1714
	if ((ie->data[1] & 0x7f) == 0x18) {
1714
	if ((ie->data[1] & 0x7f) == 0x18) {
1715
	    pri_message(ctrl, "%c                              Ext: %d  Transfer rate multiplier: %d x 64\n", prefix, (ie->data[2] & 0x80) >> 7, ie->data[2] & 0x7f);
1715
		pri_message(ctrl, "%c                              Ext: %d  Transfer rate multiplier: %d x 64\n", prefix, (ie->data[2] & 0x80) >> 7, ie->data[2] & 0x7f);
1716
		pos++;
1716
		pos++;
1717
	}
1717
	}
1718

    
   
1718

   
[+20] [20] 122 lines
[+20] [+] static int receive_bearer_capability(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len)
1841
	switch (ie->data[0] & 0x60) {
1841
	switch (ie->data[0] & 0x60) {
1842
	case 0x00:/* ITU-T standardized coding */
1842
	case 0x00:/* ITU-T standardized coding */
1843
		call->bc.transcapability = ie->data[0] & 0x1f;
1843
		call->bc.transcapability = ie->data[0] & 0x1f;
1844
		call->bc.transmoderate = ie->data[1] & 0x7f;
1844
		call->bc.transmoderate = ie->data[1] & 0x7f;
1845

    
   
1845

   
1846
		/* octet 4.1 exists iff mode/rate is multirate */
1846
		/* octet 4.1 exists if mode/rate is multirate */
1847
		if (call->bc.transmoderate == TRANS_MODE_MULTIRATE) {
1847
		if (call->bc.transmoderate == TRANS_MODE_MULTIRATE) {
1848
			call->bc.transmultiple = ie->data[pos++] & 0x7f;
1848
			call->bc.transmultiple = ie->data[pos++] & 0x7f;
1849
		}
1849
		}
1850

    
   
1850

   
1851
		/* Look for octet 5; this is identified by bits 5,6 == 01 */
1851
		/* Look for octet 5; this is identified by bits 5,6 == 01 */
[+20] [20] 70 lines
[+20] [+] static int transmit_bearer_capability(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len, int order)
1922
	tc = call->bc.transcapability;
1922
	tc = call->bc.transcapability;
1923
	ie->data[0] = 0x80 | tc;
1923
	ie->data[0] = 0x80 | tc;
1924
	ie->data[1] = call->bc.transmoderate | 0x80;
1924
	ie->data[1] = call->bc.transmoderate | 0x80;
1925

    
   
1925

   
1926
 	pos = 2;
1926
	pos = 2;
1927
 	/* octet 4.1 exists iff mode/rate is multirate */
1927
	/* octet 4.1 exists if mode/rate is multirate */
1928
 	if (call->bc.transmoderate == TRANS_MODE_MULTIRATE ) {
1928
	if (call->bc.transmoderate == TRANS_MODE_MULTIRATE ) {
1929
 		ie->data[pos++] = call->bc.transmultiple | 0x80;
1929
		ie->data[pos++] = call->bc.transmultiple | 0x80;
1930
	}
1930
	}
1931

    
   
1931

   
1932
	if ((tc & PRI_TRANS_CAP_DIGITAL) && (ctrl->switchtype == PRI_SWITCH_EUROISDN_E1) &&
1932
	if ((tc & PRI_TRANS_CAP_DIGITAL) && (ctrl->switchtype == PRI_SWITCH_EUROISDN_E1) &&
[+20] [20] 217 lines
[+20] [+] static void dump_called_party_number(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
2150

    
   
2150

   
2151
	q931_strget(cnum, sizeof(cnum), ie->data + 1, len - 3);
2151
	q931_strget(cnum, sizeof(cnum), ie->data + 1, len - 3);
2152
	pri_message(ctrl,
2152
	pri_message(ctrl,
2153
		"%c %s (len=%2d) [ Ext: %d  TON: %s (%d)  NPI: %s (%d)  '%s' ]\n",
2153
		"%c %s (len=%2d) [ Ext: %d  TON: %s (%d)  NPI: %s (%d)  '%s' ]\n",
2154
		prefix, ie2str(full_ie), len, ie->data[0] >> 7,
2154
		prefix, ie2str(full_ie), len, ie->data[0] >> 7,

    
   
2155

   
2155
		ton2str((ie->data[0] >> 4) & 0x07), (ie->data[0] >> 4) & 0x07,
2156
		ton2str((ie->data[0] >> 4) & 0x07), (ie->data[0] >> 4) & 0x07,
2156
		npi2str(ie->data[0] & 0x0f), ie->data[0] & 0x0f, cnum);
2157
		npi2str(ie->data[0] & 0x0f), ie->data[0] & 0x0f, cnum);
2157
}
2158
}
2158

    
   
2159

   
2159
static void dump_called_party_subaddr(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
2160
static void dump_called_party_subaddr(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
[+20] [20] 13 lines
[+20] [+] static void dump_calling_party_number(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
2173
	pri_message(ctrl,
2174
	pri_message(ctrl,
2174
		"%c %s (len=%2d) [ Ext: %d  TON: %s (%d)  NPI: %s (%d)\n",
2175
		"%c %s (len=%2d) [ Ext: %d  TON: %s (%d)  NPI: %s (%d)\n",
2175
		prefix, ie2str(full_ie), len, ie->data[0] >> 7,
2176
		prefix, ie2str(full_ie), len, ie->data[0] >> 7,
2176
		ton2str((ie->data[0] >> 4) & 0x07), (ie->data[0] >> 4) & 0x07,
2177
		ton2str((ie->data[0] >> 4) & 0x07), (ie->data[0] >> 4) & 0x07,
2177
		npi2str(ie->data[0] & 0x0f), ie->data[0] & 0x0f);
2178
		npi2str(ie->data[0] & 0x0f), ie->data[0] & 0x0f);
2178
	if (ie->data[0] & 0x80)
2179
	if (ie->data[0] & 0x80) {
2179
		pri_message(ctrl, "%c                           Presentation: %s (%d)  '%s' ]\n", prefix, pri_pres2str(0), 0, cnum);
2180
		pri_message(ctrl, "%c                                 Presentation: %s (%d)  '%s' ]\n",
2180
	else
2181
			prefix, pri_pres2str(0), 0, cnum);
2181
		pri_message(ctrl, "%c                           Presentation: %s (%d)  '%s' ]\n", prefix, pri_pres2str(ie->data[1] & 0x7f), ie->data[1] & 0x7f, cnum);
2182
	} else {

    
   
2183
		pri_message(ctrl, "%c                                 Presentation: %s (%d)  '%s' ]\n",

    
   
2184
			prefix, pri_pres2str(ie->data[1] & 0x7f), ie->data[1] & 0x7f, cnum);

    
   
2185
	}
2182
}
2186
}
2183

    
   
2187

   
2184
static void dump_calling_party_subaddr(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
2188
static void dump_calling_party_subaddr(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
2185
{
2189
{
2186
	dump_subaddr_helper(full_ie, ctrl, ie, 1, len, len - 3, prefix);
2190
	dump_subaddr_helper(full_ie, ctrl, ie, 1, len, len - 3, prefix);
[+20] [20] 9 lines
[+20] [+] static void dump_calling_party_category(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
2196

    
   
2200

   
2197
static void dump_redirecting_number(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
2201
static void dump_redirecting_number(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
2198
{
2202
{
2199
	unsigned char cnum[256];
2203
	unsigned char cnum[256];
2200
	int i = 0;
2204
	int i = 0;

    
   
2205

   

    
   
2206
	char *ie_str;

    
   
2207
	int indent;

    
   
2208

   

    
   
2209
	ie_str = ie2str(full_ie);

    
   
2210
	indent = strlen(ie_str) + 13; /* indentation including: prefix, ie.length etc: 13 = '> (len= 2) [ ') */

    
   
2211

   
2201
	/* To follow Q.931 (4.5.1), we must search for start of octet 4 by
2212
	/* To follow Q.931 (4.5.1), we must search for start of octet 4 by
2202
	   walking through all bytes until one with ext bit (8) set to 1 */
2213
	   walking through all bytes until one with ext bit (8) set to 1 */
2203
	do {
2214
	do {
2204
		switch(i) {
2215
		switch(i) {
2205
		case 0:	/* Octet 3 */
2216
		case 0:	/* Octet 3 */
2206
			pri_message(ctrl,
2217
			pri_message(ctrl,
2207
				"%c %s (len=%2d) [ Ext: %d  TON: %s (%d)  NPI: %s (%d)",
2218
				"%c %s (len=%2d) [ Ext: %d  TON: %s (%d)  NPI: %s (%d)",
2208
				prefix, ie2str(full_ie), len, ie->data[0] >> 7,
2219
				prefix, ie_str, len, ie->data[0] >> 7,
2209
				ton2str((ie->data[0] >> 4) & 0x07), (ie->data[0] >> 4) & 0x07,
2220
				ton2str((ie->data[0] >> 4) & 0x07), (ie->data[0] >> 4) & 0x07,
2210
				npi2str(ie->data[0] & 0x0f), ie->data[0] & 0x0f);
2221
				npi2str(ie->data[0] & 0x0f), ie->data[0] & 0x0f);
2211
			break;
2222
			break;
2212
		case 1: /* Octet 3a */
2223
		case 1: /* Octet 3a */
2213
			pri_message(ctrl, "\n");
2224
			pri_message(ctrl, "\n");
2214
			pri_message(ctrl, "%c                               Ext: %d  Presentation: %s (%d)",
2225
			pri_message(ctrl, "%-*c Ext: %d  Presentation: %s (%d)",
2215
				prefix, ie->data[1] >> 7, pri_pres2str(ie->data[1] & 0x7f), ie->data[1] & 0x7f);
2226
				 indent, prefix, ie->data[1] >> 7, pri_pres2str(ie->data[1] & 0x7f), ie->data[1] & 0x7f);
2216
			break;
2227
			break;
2217
		case 2: /* Octet 3b */
2228
		case 2: /* Octet 3b */
2218
			pri_message(ctrl, "\n");
2229
			pri_message(ctrl, "\n");
2219
			pri_message(ctrl, "%c                               Ext: %d  Reason: %s (%d)",
2230
			pri_message(ctrl, "%-*c Ext: %d  Reason: %s (%d)",
2220
				prefix, ie->data[2] >> 7, redirection_reason2str(ie->data[2] & 0x7f), ie->data[2] & 0x7f);
2231
				 indent, prefix, ie->data[2] >> 7, redirection_reason2str(ie->data[2] & 0x7f), ie->data[2] & 0x7f);
2221
			break;
2232
			break;
2222
		}
2233
		}
2223
	} while(!(ie->data[i++]& 0x80));
2234
	} while (!(ie->data[i++] & 0x80));
2224
	q931_strget(cnum, sizeof(cnum), ie->data + i, ie->len - i);
2235
	q931_strget(cnum, sizeof(cnum), ie->data + i, ie->len - i);
2225
	pri_message(ctrl, "  '%s' ]\n", cnum);
2236
	pri_message(ctrl, "  '%s' ]\n", cnum);
2226
}
2237
}
2227

    
   
2238

   
2228
static void dump_redirection_number(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
2239
static void dump_redirection_number(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
[+20] [20] 1367 lines
[+20] [+] static int transmit_notify(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len, int order)
3596
	return 0;
3607
	return 0;
3597
}
3608
}
3598

    
   
3609

   
3599
static void dump_shift(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3610
static void dump_shift(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3600
{
3611
{
3601
	pri_message(ctrl, "%c %s%s (len=%02d): Requested codeset %d\n",
3612
	pri_message(ctrl, "%c %sLocking Shift (len=%02d): Requested codeset %d\n",
3602
		prefix, (full_ie & 8) ? "Non-" : "", ie2str(full_ie), len, full_ie & 7);
3613
		prefix, (full_ie & 8) ? "Non-" : "", len, full_ie & 7);
3603
}
3614
}
3604

    
   
3615

   
3605
static char *lineinfo2str(int info)
3616
static char *lineinfo2str(int info)
3606
{
3617
{
3607
	/* NAPNA ANI II digits */
3618
	/* NAPNA ANI II digits */
[+20] [20] 295 lines
[+20] [+] static struct ie ies[] = {
3903
	{ 1, NATIONAL_CHANGE_STATUS, "Change Status Information", dump_change_status, receive_change_status, transmit_change_status },
3914
	{ 1, NATIONAL_CHANGE_STATUS, "Change Status Information", dump_change_status, receive_change_status, transmit_change_status },
3904
	{ 0, Q931_LOCKING_SHIFT, "Locking Shift", dump_shift },
3915
	{ 0, Q931_LOCKING_SHIFT, "Locking Shift", dump_shift },
3905
	{ 0, Q931_BEARER_CAPABILITY, "Bearer Capability", dump_bearer_capability, receive_bearer_capability, transmit_bearer_capability },
3916
	{ 0, Q931_BEARER_CAPABILITY, "Bearer Capability", dump_bearer_capability, receive_bearer_capability, transmit_bearer_capability },
3906
	{ 0, Q931_CAUSE, "Cause", dump_cause, receive_cause, transmit_cause },
3917
	{ 0, Q931_CAUSE, "Cause", dump_cause, receive_cause, transmit_cause },
3907
	{ 1, Q931_IE_CALL_STATE, "Call State", dump_call_state, receive_call_state, transmit_call_state },
3918
	{ 1, Q931_IE_CALL_STATE, "Call State", dump_call_state, receive_call_state, transmit_call_state },
3908
	{ 0, Q931_CHANNEL_IDENT, "Channel Identification", dump_channel_id, receive_channel_id, transmit_channel_id },
3919
	{ 0, Q931_CHANNEL_IDENT, "Channel ID", dump_channel_id, receive_channel_id, transmit_channel_id },
3909
	{ 0, Q931_PROGRESS_INDICATOR, "Progress Indicator", dump_progress_indicator, receive_progress_indicator, transmit_progress_indicator },
3920
	{ 0, Q931_PROGRESS_INDICATOR, "Progress Indicator", dump_progress_indicator, receive_progress_indicator, transmit_progress_indicator },
3910
	{ 0, Q931_NETWORK_SPEC_FAC, "Network-Specific Facilities", dump_network_spec_fac, receive_network_spec_fac, transmit_network_spec_fac },
3921
	{ 0, Q931_NETWORK_SPEC_FAC, "Network-Specific Facilities", dump_network_spec_fac, receive_network_spec_fac, transmit_network_spec_fac },
3911
	{ 1, Q931_INFORMATION_RATE, "Information Rate" },
3922
	{ 1, Q931_INFORMATION_RATE, "Information Rate" },
3912
	{ 1, Q931_TRANSIT_DELAY, "End-to-End Transit Delay" },
3923
	{ 1, Q931_TRANSIT_DELAY, "End-to-End Transit Delay" },
3913
	{ 1, Q931_TRANS_DELAY_SELECT, "Transmit Delay Selection and Indication" },
3924
	{ 1, Q931_TRANS_DELAY_SELECT, "Transmit Delay Selection and Indication" },
[+20] [20] 5908 lines
  1. branches/1.4/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.