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.

Diff revision 2

This is not the most recent revision of the diff. The latest diff is revision 3. See what's changed.

1 2 3
1 2 3

  1. branches/1.4/q931.c: Loading...
branches/1.4/q931.c
Revision 2279 New Change
[20] 1572 lines
[+20] [+] static char *ri2str(int ri)
1573
	return code2str(ri, ris, sizeof(ris) / sizeof(ris[0]));
1573
	return code2str(ri, ris, sizeof(ris) / sizeof(ris[0]));
1574
}
1574
}
1575

    
   
1575

   
1576
static void dump_restart_indicator(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
1576
static void dump_restart_indicator(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
1577
{
1577
{
1578
	pri_message(ctrl, "%c Restart Indentifier (len=%2d) [ Ext: %d  Spare: %d  Resetting %s (%d) ]\n", 
1578
	pri_message(ctrl,
1579
		prefix, len, (ie->data[0] & 0x80) >> 7, (ie->data[0] & 0x78) >> 3, ri2str(ie->data[0] & 0x7), ie->data[0] & 0x7);
1579
		"%c %s (len=%2d) [ Ext: %d  Spare: %d  Resetting %s (%d) ]\n",

    
   
1580
		prefix, ie2str(full_ie), len, (ie->data[0] & 0x80) >> 7,

    
   
1581
		(ie->data[0] & 0x78) >> 3, ri2str(ie->data[0] & 0x7), ie->data[0] & 0x7);
1580
}
1582
}
1581

    
   
1583

   
1582
static int receive_restart_indicator(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len)
1584
static int receive_restart_indicator(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len)
1583
{
1585
{
1584
	/* Pretty simple */
1586
	/* Pretty simple */
[+20] [20] 114 lines
[+20] [+] static char *int_rate2str(int proto)
1699
}
1701
}
1700

    
   
1702

   
1701
static void dump_bearer_capability(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
1703
static void dump_bearer_capability(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
1702
{
1704
{
1703
	int pos=2;
1705
	int pos=2;
1704
	pri_message(ctrl, "%c Bearer Capability (len=%2d) [ Ext: %d  Coding-Std: %d  Info transfer capability: %s (%d)\n",
1706
	pri_message(ctrl,
1705
		prefix, len, (ie->data[0] & 0x80 ) >> 7, (ie->data[0] & 0x60) >> 5, cap2str(ie->data[0] & 0x1f), (ie->data[0] & 0x1f));
1707
		"%c %s (len=%2d) [ Ext: %d  Coding-Std: %d  Info transfer capability: %s (%d)\n",

    
   
1708
		prefix, ie2str(full_ie), len, (ie->data[0] & 0x80 ) >> 7,

    
   
1709
		(ie->data[0] & 0x60) >> 5, cap2str(ie->data[0] & 0x1f),

    
   
1710
		(ie->data[0] & 0x1f));
1706
	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);
1707

    
   
1712

   
1708
	/* octet 4.1 exists iff mode/rate is multirate */
1713
	/* octet 4.1 exists iff mode/rate is multirate */
1709
	if ((ie->data[1] & 0x7f) == 0x18) {
1714
	if ((ie->data[1] & 0x7f) == 0x18) {
1710
	    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);
[+20] [20] 431 lines
[+20] [+] static void dump_subaddr_helper(int full_ie, struct pri *ctrl, q931_ie *ie, int offset, int len, int datalen, char prefix)
2142
static void dump_called_party_number(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
2147
static void dump_called_party_number(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
2143
{
2148
{
2144
	unsigned char cnum[256];
2149
	unsigned char cnum[256];
2145

    
   
2150

   
2146
	q931_strget(cnum, sizeof(cnum), ie->data + 1, len - 3);
2151
	q931_strget(cnum, sizeof(cnum), ie->data + 1, len - 3);
2147
	pri_message(ctrl, "%c Called Number (len=%2d) [ Ext: %d  TON: %s (%d)  NPI: %s (%d)  '%s' ]\n",
2152
	pri_message(ctrl,
2148
		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);
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,

    
   
2155
		ton2str((ie->data[0] >> 4) & 0x07), (ie->data[0] >> 4) & 0x07,

    
   
2156
		npi2str(ie->data[0] & 0x0f), ie->data[0] & 0x0f, cnum);
2149
}
2157
}
2150

    
   
2158

   
2151
static void dump_called_party_subaddr(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
2159
static void dump_called_party_subaddr(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
2152
{
2160
{
2153
	dump_subaddr_helper(full_ie, ctrl, ie, 1, len, len - 3, prefix);
2161
	dump_subaddr_helper(full_ie, ctrl, ie, 1, len, len - 3, prefix);
[+20] [20] 6 lines
[+20] [+] static void dump_calling_party_number(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
2160
	if (ie->data[0] & 0x80) {
2168
	if (ie->data[0] & 0x80) {
2161
		q931_strget(cnum, sizeof(cnum), ie->data + 1, len - 3);
2169
		q931_strget(cnum, sizeof(cnum), ie->data + 1, len - 3);
2162
	} else {
2170
	} else {
2163
		q931_strget(cnum, sizeof(cnum), ie->data + 2, len - 4);
2171
		q931_strget(cnum, sizeof(cnum), ie->data + 2, len - 4);
2164
	}
2172
	}
2165
	pri_message(ctrl, "%c Calling Number (len=%2d) [ Ext: %d  TON: %s (%d)  NPI: %s (%d)\n", 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);
2173
	pri_message(ctrl,

    
   
2174
		"%c %s (len=%2d) [ Ext: %d  TON: %s (%d)  NPI: %s (%d)\n",

    
   
2175
		prefix, ie2str(full_ie), len, ie->data[0] >> 7,

    
   
2176
		ton2str((ie->data[0] >> 4) & 0x07), (ie->data[0] >> 4) & 0x07,

    
   
2177
		npi2str(ie->data[0] & 0x0f), ie->data[0] & 0x0f);
2166
	if (ie->data[0] & 0x80)
2178
	if (ie->data[0] & 0x80)
2167
		pri_message(ctrl, "%c                           Presentation: %s (%d)  '%s' ]\n", prefix, pri_pres2str(0), 0, cnum);
2179
		pri_message(ctrl, "%c                           Presentation: %s (%d)  '%s' ]\n", prefix, pri_pres2str(0), 0, cnum);
2168
	else
2180
	else
2169
		pri_message(ctrl, "%c                           Presentation: %s (%d)  '%s' ]\n", prefix, pri_pres2str(ie->data[1] & 0x7f), ie->data[1] & 0x7f, cnum);
2181
		pri_message(ctrl, "%c                           Presentation: %s (%d)  '%s' ]\n", prefix, pri_pres2str(ie->data[1] & 0x7f), ie->data[1] & 0x7f, cnum);
2170
}
2182
}
2171

    
   
2183

   
2172
static void dump_calling_party_subaddr(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
2184
static void dump_calling_party_subaddr(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
2173
{
2185
{
2174
	dump_subaddr_helper(full_ie, ctrl, ie, 1, len, len - 3, prefix);
2186
	dump_subaddr_helper(full_ie, ctrl, ie, 1, len, len - 3, prefix);
2175
}
2187
}
2176

    
   
2188

   
2177
static void dump_calling_party_category(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
2189
static void dump_calling_party_category(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
2178
{
2190
{
2179
	pri_message(ctrl, "%c Calling Party Category (len=%2d) [ Ext: %d  Cat: %s (%d) ]\n",
2191
	pri_message(ctrl,
2180
		prefix, len, ie->data[0] >> 7, cpc2str(ie->data[0] & 0x0F), ie->data[0] & 0x0F);
2192
		"%c %s (len=%2d) [ Ext: %d  Cat: %s (%d) ]\n",

    
   
2193
		prefix, ie2str(full_ie), len, ie->data[0] >> 7,

    
   
2194
		cpc2str(ie->data[0] & 0x0F), ie->data[0] & 0x0F);
2181
}
2195
}
2182

    
   
2196

   
2183
static void dump_redirecting_number(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
2197
static void dump_redirecting_number(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
2184
{
2198
{
2185
	unsigned char cnum[256];
2199
	unsigned char cnum[256];
2186
	int i = 0;
2200
	int i = 0;
2187
	/* To follow Q.931 (4.5.1), we must search for start of octet 4 by
2201
	/* To follow Q.931 (4.5.1), we must search for start of octet 4 by
2188
	   walking through all bytes until one with ext bit (8) set to 1 */
2202
	   walking through all bytes until one with ext bit (8) set to 1 */
2189
	do {
2203
	do {
2190
		switch(i) {
2204
		switch(i) {
2191
		case 0:	/* Octet 3 */
2205
		case 0:	/* Octet 3 */
2192
			pri_message(ctrl, "%c Redirecting Number (len=%2d) [ Ext: %d  TON: %s (%d)  NPI: %s (%d)",
2206
			pri_message(ctrl,
2193
				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);
2207
				"%c %s (len=%2d) [ Ext: %d  TON: %s (%d)  NPI: %s (%d)",

    
   
2208
				prefix, ie2str(full_ie), len, ie->data[0] >> 7,

    
   
2209
				ton2str((ie->data[0] >> 4) & 0x07), (ie->data[0] >> 4) & 0x07,

    
   
2210
				npi2str(ie->data[0] & 0x0f), ie->data[0] & 0x0f);
2194
			break;
2211
			break;
2195
		case 1: /* Octet 3a */
2212
		case 1: /* Octet 3a */
2196
			pri_message(ctrl, "\n");
2213
			pri_message(ctrl, "\n");
2197
			pri_message(ctrl, "%c                               Ext: %d  Presentation: %s (%d)",
2214
			pri_message(ctrl, "%c                               Ext: %d  Presentation: %s (%d)",
2198
				prefix, ie->data[1] >> 7, pri_pres2str(ie->data[1] & 0x7f), ie->data[1] & 0x7f);
2215
				prefix, ie->data[1] >> 7, pri_pres2str(ie->data[1] & 0x7f), ie->data[1] & 0x7f);
[+20] [20] 17 lines
[+20] [+] static void dump_redirection_number(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
2216
	   walking through all bytes until one with ext bit (8) set to 1 */
2233
	   walking through all bytes until one with ext bit (8) set to 1 */
2217
	do {
2234
	do {
2218
		switch (i) {
2235
		switch (i) {
2219
		case 0:	/* Octet 3 */
2236
		case 0:	/* Octet 3 */
2220
			pri_message(ctrl,
2237
			pri_message(ctrl,
2221
				"%c Redirection Number (len=%2d) [ Ext: %d  TON: %s (%d)  NPI: %s (%d)",
2238
				"%c %s (len=%2d) [ Ext: %d  TON: %s (%d)  NPI: %s (%d)",
2222
				prefix, len, ie->data[0] >> 7,
2239
				prefix, ie2str(full_ie), len, ie->data[0] >> 7,
2223
				ton2str((ie->data[0] >> 4) & 0x07), (ie->data[0] >> 4) & 0x07,
2240
				ton2str((ie->data[0] >> 4) & 0x07), (ie->data[0] >> 4) & 0x07,
2224
				npi2str(ie->data[0] & 0x0f), ie->data[0] & 0x0f);
2241
				npi2str(ie->data[0] & 0x0f), ie->data[0] & 0x0f);
2225
			break;
2242
			break;
2226
		case 1: /* Octet 3a */
2243
		case 1: /* Octet 3a */
2227
			pri_message(ctrl, "\n");
2244
			pri_message(ctrl, "\n");
[+20] [20] 373 lines
[+20] [+] static int transmit_calling_party_number(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len, int order)
2601
}
2618
}
2602

    
   
2619

   
2603
static void dump_user_user(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
2620
static void dump_user_user(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
2604
{
2621
{
2605
	int x;
2622
	int x;
2606
	pri_message(ctrl, "%c User-User Information (len=%2d) [", prefix, len);
2623
	pri_message(ctrl, "%c %s (len=%2d) [", prefix, ie2str(full_ie), len);
2607
	for (x=0;x<ie->len;x++)
2624
	for (x = 0; x < ie->len; x++) {
2608
		pri_message(ctrl, " %02x", ie->data[x] & 0x7f);
2625
		pri_message(ctrl, " %02x", ie->data[x] & 0x7f);

    
   
2626
	}
2609
	pri_message(ctrl, " ]\n");
2627
	pri_message(ctrl, " ]\n");
2610
}
2628
}
2611

    
   
2629

   
2612

    
   
2630

   
2613
static int receive_user_user(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len)
2631
static int receive_user_user(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len)
[+20] [20] 27 lines
[+20] [+] static int transmit_user_user(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len, int order)
2641
}
2659
}
2642

    
   
2660

   
2643
static void dump_change_status(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
2661
static void dump_change_status(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
2644
{
2662
{
2645
	int x;
2663
	int x;
2646
	
2664

   
2647
	pri_message(ctrl, "%c Change Status Information (len=%2d) [", prefix, len);
2665
	pri_message(ctrl, "%c %s (len=%2d) [", prefix, ie2str(full_ie), len);
2648
	for (x=0; x<ie->len; x++) {
2666
	for (x = 0; x < ie->len; x++) {
2649
		pri_message(ctrl, " %02x", ie->data[x] & 0x7f);
2667
		pri_message(ctrl, " %02x", ie->data[x] & 0x7f);
2650
	}
2668
	}
2651
	pri_message(ctrl, " ]\n");
2669
	pri_message(ctrl, " ]\n");
2652
}
2670
}
2653

    
   
2671

   
[+20] [20] 51 lines
[+20] [+] static char *loc2str(int loc)
2705
	return code2str(loc, locs, sizeof(locs) / sizeof(locs[0]));
2723
	return code2str(loc, locs, sizeof(locs) / sizeof(locs[0]));
2706
}
2724
}
2707

    
   
2725

   
2708
static void dump_progress_indicator(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
2726
static void dump_progress_indicator(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
2709
{
2727
{
2710
	pri_message(ctrl, "%c Progress Indicator (len=%2d) [ Ext: %d  Coding: %s (%d)  0: %d  Location: %s (%d)\n",
2728
	pri_message(ctrl,
2711
		prefix, len, ie->data[0] >> 7, coding2str((ie->data[0] & 0x60) >> 5), (ie->data[0] & 0x60) >> 5,
2729
		"%c %s (len=%2d) [ Ext: %d  Coding: %s (%d)  0: %d  Location: %s (%d)\n",
2712
		(ie->data[0] & 0x10) >> 4, loc2str(ie->data[0] & 0xf), ie->data[0] & 0xf);
2730
		prefix, ie2str(full_ie), len, ie->data[0] >> 7, coding2str((ie->data[0] & 0x60) >> 5),

    
   
2731
		(ie->data[0] & 0x60) >> 5, (ie->data[0] & 0x10) >> 4,

    
   
2732
		loc2str(ie->data[0] & 0xf), ie->data[0] & 0xf);
2713
	pri_message(ctrl, "%c                               Ext: %d  Progress Description: %s (%d) ]\n",
2733
	pri_message(ctrl, "%c                               Ext: %d  Progress Description: %s (%d) ]\n",
2714
		prefix, ie->data[1] >> 7, prog2str(ie->data[1] & 0x7f), ie->data[1] & 0x7f);
2734
		prefix, ie->data[1] >> 7, prog2str(ie->data[1] & 0x7f), ie->data[1] & 0x7f);
2715
}
2735
}
2716

    
   
2736

   
2717
static int receive_display(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len)
2737
static int receive_display(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len)
[+20] [20] 467 lines
[+20] [+] static const char *q931_hold_state_str(enum Q931_HOLD_STATE state)
3185
	return code2str(state, hold_states, ARRAY_LEN(hold_states));
3205
	return code2str(state, hold_states, ARRAY_LEN(hold_states));
3186
}
3206
}
3187

    
   
3207

   
3188
static void dump_call_state(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3208
static void dump_call_state(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3189
{
3209
{
3190
	pri_message(ctrl, "%c Call State (len=%2d) [ Ext: %d  Coding: %s (%d)  Call state: %s (%d)\n",
3210
	pri_message(ctrl,
3191
		prefix, len, ie->data[0] >> 7, coding2str((ie->data[0] & 0xC0) >> 6), (ie->data[0] & 0xC0) >> 6,
3211
		"%c %s (len=%2d) [ Ext: %d  Coding: %s (%d)  Call state: %s (%d)\n",

    
   
3212
		prefix, ie2str(full_ie), len, ie->data[0] >> 7,

    
   
3213
		coding2str((ie->data[0] & 0xC0) >> 6), (ie->data[0] & 0xC0) >> 6,
3192
		q931_call_state_str(ie->data[0] & 0x3f), ie->data[0] & 0x3f);
3214
		q931_call_state_str(ie->data[0] & 0x3f), ie->data[0] & 0x3f);
3193
}
3215
}
3194

    
   
3216

   
3195
static void dump_call_identity(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3217
static void dump_call_identity(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3196
{
3218
{
3197
	int x;
3219
	int x;
3198
	pri_message(ctrl, "%c Call Identity (len=%2d) [ ", prefix, len);
3220
	pri_message(ctrl, "%c %s (len=%2d) [ ", prefix, ie2str(full_ie), len);
3199
	for (x=0;x<ie->len;x++) 
3221
	for (x = 0; x < ie->len; x++) {
3200
		pri_message(ctrl, "0x%02X ", ie->data[x]);
3222
		pri_message(ctrl, "0x%02X ", ie->data[x]);

    
   
3223
	}
3201
	pri_message(ctrl, " ]\n");
3224
	pri_message(ctrl, " ]\n");
3202
}
3225
}
3203

    
   
3226

   
3204
static void dump_time_date(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3227
static void dump_time_date(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3205
{
3228
{
3206
	pri_message(ctrl, "%c Time Date (len=%2d) [ ", prefix, len);
3229
	pri_message(ctrl, "%c %s (len=%2d) [ ", prefix, ie2str(full_ie), len);
3207
	if (ie->len > 0)
3230
	if (ie->len > 0)
3208
		pri_message(ctrl, "%02d", ie->data[0]);
3231
		pri_message(ctrl, "%02d", ie->data[0]);
3209
	if (ie->len > 1)
3232
	if (ie->len > 1)
3210
		pri_message(ctrl, "-%02d", ie->data[1]);
3233
		pri_message(ctrl, "-%02d", ie->data[1]);
3211
	if (ie->len > 2)
3234
	if (ie->len > 2)
[+20] [20] 60 lines
[+20] [+] static int transmit_time_date(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len, int order)
3272
static void dump_keypad_facility(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3295
static void dump_keypad_facility(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3273
{
3296
{
3274
	unsigned char tmp[64];
3297
	unsigned char tmp[64];
3275

    
   
3298

   
3276
	q931_strget(tmp, sizeof(tmp), ie->data, ie->len);
3299
	q931_strget(tmp, sizeof(tmp), ie->data, ie->len);
3277
	pri_message(ctrl, "%c Keypad Facility (len=%2d) [ %s ]\n", prefix, ie->len, tmp);
3300
	pri_message(ctrl,

    
   
3301
		"%c %s (len=%2d) [ %s ]\n", prefix, ie2str(full_ie), ie->len, tmp);
3278
}
3302
}
3279

    
   
3303

   
3280
static int receive_keypad_facility(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len)
3304
static int receive_keypad_facility(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len)
3281
{
3305
{
3282
	if (ie->len == 0)
3306
	if (ie->len == 0)
[+20] [20] 29 lines
[+20] [+] static void dump_display(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3312
		++x;
3336
		++x;
3313
	} else {
3337
	} else {
3314
		tmp[0] = '\0';
3338
		tmp[0] = '\0';
3315
	}
3339
	}
3316
	q931_strget(buf, sizeof(buf), &ie->data[x], ie->len - x);
3340
	q931_strget(buf, sizeof(buf), &ie->data[x], ie->len - x);
3317
	pri_message(ctrl, "%c Display (len=%2d) %s[ %s ]\n", prefix, ie->len, tmp, buf);
3341
	pri_message(ctrl,

    
   
3342
		"%c %s (len=%2d) %s[ %s ]\n", prefix, ie2str(full_ie), ie->len, tmp, buf);
3318
}
3343
}
3319

    
   
3344

   
3320
#define CHECK_OVERFLOW(limit) \
3345
#define CHECK_OVERFLOW(limit) \
3321
	if (tmpptr - tmp + limit >= sizeof(tmp)) { \
3346
	if (tmpptr - tmp + limit >= sizeof(tmp)) { \
3322
		*tmpptr = '\0'; \
3347
		*tmpptr = '\0'; \
[+20] [20] 39 lines
[+20] [+] static void dump_ie_data(struct pri *ctrl, unsigned char *c, int len)
3362
	pri_message(ctrl, "%s", tmp);
3387
	pri_message(ctrl, "%s", tmp);
3363
}
3388
}
3364

    
   
3389

   
3365
static void dump_facility(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3390
static void dump_facility(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3366
{
3391
{
3367
	pri_message(ctrl, "%c Facility (len=%2d, codeset=%d) [ ", prefix, len, Q931_IE_CODESET(full_ie));
3392
	pri_message(ctrl, "%c %s (len=%2d, codeset=%d) [ ",

    
   
3393
		prefix, ie2str(full_ie), len, Q931_IE_CODESET(full_ie));
3368
	dump_ie_data(ctrl, ie->data, ie->len);
3394
	dump_ie_data(ctrl, ie->data, ie->len);
3369
	pri_message(ctrl, " ]\n");
3395
	pri_message(ctrl, " ]\n");
3370
#if 0	/* Lets not dump parse of facility contents here anymore. */
3396
#if 0	/* Lets not dump parse of facility contents here anymore. */
3371
	/*
3397
	/*
3372
	 * The ASN.1 decode dump has already been done when the facility ie was added to the outgoing
3398
	 * The ASN.1 decode dump has already been done when the facility ie was added to the outgoing
[+20] [20] 9 lines
[+20] static void dump_facility(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3382
#endif	/* Lets not dump parse of facility contents here anymore. */
3408
#endif	/* Lets not dump parse of facility contents here anymore. */
3383
}
3409
}
3384

    
   
3410

   
3385
static void dump_network_spec_fac(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3411
static void dump_network_spec_fac(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3386
{
3412
{
3387
	pri_message(ctrl, "%c Network-Specific Facilities (len=%2d) [ ", prefix, ie->len);
3413
	pri_message(ctrl, "%c %s (len=%2d) [ ", prefix, ie2str(full_ie), ie->len);
3388
	if (ie->data[0] == 0x00) {
3414
	if (ie->data[0] == 0x00) {
3389
 		pri_message(ctrl, "%s", code2str(ie->data[1], facilities, ARRAY_LEN(facilities)));
3415
		pri_message(ctrl, "%s", code2str(ie->data[1], facilities, ARRAY_LEN(facilities)));
3390
	}
3416
	} else {
3391
	else

   
3392
 		dump_ie_data(ctrl, ie->data, ie->len);
3417
		dump_ie_data(ctrl, ie->data, ie->len);

    
   
3418
	}
3393
	pri_message(ctrl, " ]\n");
3419
	pri_message(ctrl, " ]\n");
3394
}
3420
}
3395

    
   
3421

   
3396
static int receive_network_spec_fac(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len)
3422
static int receive_network_spec_fac(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len)
3397
{
3423
{
[+20] [20] 36 lines
[+20] [+] static char *pri_causeclass2str(int cause)
3434
}
3460
}
3435

    
   
3461

   
3436
static void dump_cause(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3462
static void dump_cause(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3437
{
3463
{
3438
	int x;
3464
	int x;
3439
	pri_message(ctrl, "%c Cause (len=%2d) [ Ext: %d  Coding: %s (%d)  Spare: %d  Location: %s (%d)\n",
3465
	pri_message(ctrl, "%c %s (len=%2d) [ Ext: %d  Coding: %s (%d)  Spare: %d  Location: %s (%d)\n",
3440
		prefix, len, ie->data[0] >> 7, coding2str((ie->data[0] & 0x60) >> 5), (ie->data[0] & 0x60) >> 5,
3466
		prefix, ie2str(full_ie), len, ie->data[0] >> 7,

    
   
3467
		coding2str((ie->data[0] & 0x60) >> 5), (ie->data[0] & 0x60) >> 5,
3441
		(ie->data[0] & 0x10) >> 4, loc2str(ie->data[0] & 0xf), ie->data[0] & 0xf);
3468
		(ie->data[0] & 0x10) >> 4, loc2str(ie->data[0] & 0xf), ie->data[0] & 0xf);
3442
	pri_message(ctrl, "%c                  Ext: %d  Cause: %s (%d), class = %s (%d) ]\n",
3469
	pri_message(ctrl, "%c                  Ext: %d  Cause: %s (%d), class = %s (%d) ]\n",
3443
		prefix, (ie->data[1] >> 7), pri_cause2str(ie->data[1] & 0x7f), ie->data[1] & 0x7f, 
3470
		prefix, (ie->data[1] >> 7), pri_cause2str(ie->data[1] & 0x7f), ie->data[1] & 0x7f,
3444
			pri_causeclass2str((ie->data[1] & 0x7f) >> 4), (ie->data[1] & 0x7f) >> 4);
3471
		pri_causeclass2str((ie->data[1] & 0x7f) >> 4), (ie->data[1] & 0x7f) >> 4);
3445
	if (ie->len < 3)
3472
	if (ie->len < 3)
3446
		return;
3473
		return;
3447
	/* Dump cause data in readable form */
3474
	/* Dump cause data in readable form */
3448
	switch(ie->data[1] & 0x7f) {
3475
	switch(ie->data[1] & 0x7f) {
[+20] [20] 45 lines
[+20] [+] static int transmit_cause(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len, int order)
3494
	}
3521
	}
3495
}
3522
}
3496

    
   
3523

   
3497
static void dump_sending_complete(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3524
static void dump_sending_complete(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3498
{
3525
{
3499
	pri_message(ctrl, "%c Sending Complete (len=%2d)\n", prefix, len);
3526
	pri_message(ctrl, "%c %s (len=%2d)\n", prefix, ie2str(full_ie), len);
3500
}
3527
}
3501

    
   
3528

   
3502
static int receive_sending_complete(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len)
3529
static int receive_sending_complete(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len)
3503
{
3530
{
3504
	/* We've got a "Complete" message: Exect no further digits. */
3531
	/* We've got a "Complete" message: Exect no further digits. */
[+20] [20] 42 lines
[+20] [+] static char *notify2str(int info)
3547
	return code2str(info, notifies, sizeof(notifies) / sizeof(notifies[0]));
3574
	return code2str(info, notifies, sizeof(notifies) / sizeof(notifies[0]));
3548
}
3575
}
3549

    
   
3576

   
3550
static void dump_notify(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3577
static void dump_notify(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3551
{
3578
{
3552
	pri_message(ctrl, "%c Notification indicator (len=%2d): Ext: %d  %s (%d)\n", prefix, len, ie->data[0] >> 7, notify2str(ie->data[0] & 0x7f), ie->data[0] & 0x7f);
3579
	pri_message(ctrl, "%c %s (len=%2d): Ext: %d  %s (%d)\n",

    
   
3580
		prefix, ie2str(full_ie), len, ie->data[0] >> 7,

    
   
3581
		notify2str(ie->data[0] & 0x7f), ie->data[0] & 0x7f);
3553
}
3582
}
3554

    
   
3583

   
3555
static int receive_notify(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len)
3584
static int receive_notify(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len)
3556
{
3585
{
3557
	call->notify = ie->data[0] & 0x7F;
3586
	call->notify = ie->data[0] & 0x7F;
[+20] [20] 9 lines
[+20] [+] static int transmit_notify(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len, int order)
3567
	return 0;
3596
	return 0;
3568
}
3597
}
3569

    
   
3598

   
3570
static void dump_shift(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3599
static void dump_shift(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3571
{
3600
{
3572
	pri_message(ctrl, "%c %sLocking Shift (len=%02d): Requested codeset %d\n", prefix, (full_ie & 8) ? "Non-" : "", len, full_ie & 7);
3601
	pri_message(ctrl, "%c %s%s (len=%02d): Requested codeset %d\n",

    
   
3602
		prefix, (full_ie & 8) ? "Non-" : "", ie2str(full_ie), len, full_ie & 7);
3573
}
3603
}
3574

    
   
3604

   
3575
static char *lineinfo2str(int info)
3605
static char *lineinfo2str(int info)
3576
{
3606
{
3577
	/* NAPNA ANI II digits */
3607
	/* NAPNA ANI II digits */
[+20] [20] 26 lines
[+20] static char *lineinfo2str(int info)
3604
	return code2str(info, lineinfo, sizeof(lineinfo) / sizeof(lineinfo[0]));
3634
	return code2str(info, lineinfo, sizeof(lineinfo) / sizeof(lineinfo[0]));
3605
}
3635
}
3606

    
   
3636

   
3607
static void dump_line_information(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3637
static void dump_line_information(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3608
{
3638
{
3609
	pri_message(ctrl, "%c Originating Line Information (len=%02d): %s (%d)\n", prefix, len, lineinfo2str(ie->data[0]), ie->data[0]);
3639
	pri_message(ctrl, "%c %s (len=%02d): %s (%d)\n",

    
   
3640
		prefix, ie2str(full_ie), len, lineinfo2str(ie->data[0]), ie->data[0]);
3610
}
3641
}
3611

    
   
3642

   
3612
static int receive_line_information(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len)
3643
static int receive_line_information(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len)
3613
{
3644
{
3614
	call->ani2 = ie->data[0];
3645
	call->ani2 = ie->data[0];
[+20] [20] 44 lines
[+20] [+] static void dump_generic_digits(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3659
	int encoding;
3690
	int encoding;
3660
	int type;
3691
	int type;
3661
	int idx;
3692
	int idx;
3662
	int value;
3693
	int value;
3663
	if (len < 3) {
3694
	if (len < 3) {
3664
		pri_message(ctrl, "%c Generic Digits (len=%02d): Invalid length\n", prefix, len);
3695
		pri_message(ctrl, "%c %s (len=%02d): Invalid length\n",

    
   
3696
			prefix, ie2str(full_ie), len);
3665
		return;
3697
		return;
3666
	}
3698
	}
3667
	encoding = (ie->data[0] >> 5) & 7;
3699
	encoding = (ie->data[0] >> 5) & 7;
3668
	type = ie->data[0] & 0x1F;
3700
	type = ie->data[0] & 0x1F;
3669
	pri_message(ctrl, "%c Generic Digits (len=%02d): Encoding %s  Type %s\n", prefix, len, gdencoding2str(encoding), gdtype2str(type));
3701
	pri_message(ctrl, "%c %s (len=%02d): Encoding %s  Type %s\n",

    
   
3702
		prefix, ie2str(full_ie), len, gdencoding2str(encoding), gdtype2str(type));
3670
	if (encoding == 3) {	/* Binary */
3703
	if (encoding == 3) {	/* Binary */
3671
		pri_message(ctrl, "%c                            Don't know how to handle binary encoding\n",
3704
		pri_message(ctrl, "%c                            Don't know how to handle binary encoding\n",
3672
			prefix);
3705
			prefix);
3673
		return;
3706
		return;
3674
	}
3707
	}
[+20] [20] 149 lines
[+20] [+] static char *signal2str(int signal)
3824
}
3857
}
3825

    
   
3858

   
3826

    
   
3859

   
3827
static void dump_signal(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3860
static void dump_signal(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3828
{
3861
{
3829
	pri_message(ctrl, "%c Signal (len=%02d): ", prefix, len);
3862
	pri_message(ctrl, "%c %s (len=%02d): ", prefix, ie2str(full_ie), len);
3830
	if (len < 3) {
3863
	if (len < 3) {
3831
		pri_message(ctrl, "Invalid length\n");
3864
		pri_message(ctrl, "Invalid length\n");
3832
		return;
3865
		return;
3833
	}
3866
	}
3834
	pri_message(ctrl, "Signal %s (%d)\n", signal2str(ie->data[0]), ie->data[0]);
3867
	pri_message(ctrl, "Signal %s (%d)\n", signal2str(ie->data[0]), ie->data[0]);
3835
}
3868
}
3836

    
   
3869

   
3837
static void dump_transit_count(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3870
static void dump_transit_count(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3838
{
3871
{
3839
	/* Defined in ECMA-225 */
3872
	/* Defined in ECMA-225 */
3840
	pri_message(ctrl, "%c Transit Count (len=%02d): ", prefix, len);
3873
	pri_message(ctrl, "%c %s (len=%02d): ", prefix, ie2str(full_ie), len);
3841
	if (len < 3) {
3874
	if (len < 3) {
3842
		pri_message(ctrl, "Invalid length\n");
3875
		pri_message(ctrl, "Invalid length\n");
3843
		return;
3876
		return;
3844
	}
3877
	}
3845
	pri_message(ctrl, "Count=%d (0x%02x)\n", ie->data[0] & 0x1f, ie->data[0] & 0x1f);
3878
	pri_message(ctrl, "Count=%d (0x%02x)\n", ie->data[0] & 0x1f, ie->data[0] & 0x1f);
3846
}
3879
}
3847

    
   
3880

   
3848
static void dump_reverse_charging_indication(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3881
static void dump_reverse_charging_indication(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3849
{
3882
{
3850
	pri_message(ctrl, "%c Reverse Charging Indication (len=%02d): %d\n", prefix, len, ie->data[0] & 0x7);
3883
	pri_message(ctrl, "%c %s (len=%02d): %d\n", prefix, ie2str(full_ie), len, ie->data[0] & 0x7);
3851
}
3884
}
3852

    
   
3885

   
3853
static int receive_reverse_charging_indication(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len)
3886
static int receive_reverse_charging_indication(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len)
3854
{
3887
{
3855
	call->reversecharge = ie->data[0] & 0x7;
3888
	call->reversecharge = ie->data[0] & 0x7;
[+20] [20] 9 lines
[+20] [+] static int transmit_reverse_charging_indication(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len, int order)
3865
	return 0;
3898
	return 0;
3866
}
3899
}
3867

    
   
3900

   
3868
static struct ie ies[] = {
3901
static struct ie ies[] = {
3869
	/* Codeset 0 - Common */
3902
	/* Codeset 0 - Common */
3870
	{ 1, NATIONAL_CHANGE_STATUS, "Change Status", dump_change_status, receive_change_status, transmit_change_status },
3903
	{ 1, NATIONAL_CHANGE_STATUS, "Change Status Information", dump_change_status, receive_change_status, transmit_change_status },
3871
	{ 0, Q931_LOCKING_SHIFT, "Locking Shift", dump_shift },
3904
	{ 0, Q931_LOCKING_SHIFT, "Locking Shift", dump_shift },
3872
	{ 0, Q931_BEARER_CAPABILITY, "Bearer Capability", dump_bearer_capability, receive_bearer_capability, transmit_bearer_capability },
3905
	{ 0, Q931_BEARER_CAPABILITY, "Bearer Capability", dump_bearer_capability, receive_bearer_capability, transmit_bearer_capability },
3873
	{ 0, Q931_CAUSE, "Cause", dump_cause, receive_cause, transmit_cause },
3906
	{ 0, Q931_CAUSE, "Cause", dump_cause, receive_cause, transmit_cause },
3874
	{ 1, Q931_IE_CALL_STATE, "Call State", dump_call_state, receive_call_state, transmit_call_state },
3907
	{ 1, Q931_IE_CALL_STATE, "Call State", dump_call_state, receive_call_state, transmit_call_state },
3875
	{ 0, Q931_CHANNEL_IDENT, "Channel Identification", dump_channel_id, receive_channel_id, transmit_channel_id },
3908
	{ 0, Q931_CHANNEL_IDENT, "Channel Identification", dump_channel_id, receive_channel_id, transmit_channel_id },
[+20] [20] 30 lines
[+20] static struct ie ies[] = {
3906
	{ 1, Q931_DISPLAY, "Display", dump_display, receive_display, transmit_display },
3939
	{ 1, Q931_DISPLAY, "Display", dump_display, receive_display, transmit_display },
3907
	{ 1, Q931_IE_TIME_DATE, "Date/Time", dump_time_date, receive_time_date, transmit_time_date },
3940
	{ 1, Q931_IE_TIME_DATE, "Date/Time", dump_time_date, receive_time_date, transmit_time_date },
3908
	{ 1, Q931_IE_KEYPAD_FACILITY, "Keypad Facility", dump_keypad_facility, receive_keypad_facility, transmit_keypad_facility },
3941
	{ 1, Q931_IE_KEYPAD_FACILITY, "Keypad Facility", dump_keypad_facility, receive_keypad_facility, transmit_keypad_facility },
3909
	{ 0, Q931_IE_SIGNAL, "Signal", dump_signal },
3942
	{ 0, Q931_IE_SIGNAL, "Signal", dump_signal },
3910
	{ 1, Q931_IE_SWITCHHOOK, "Switch-hook" },
3943
	{ 1, Q931_IE_SWITCHHOOK, "Switch-hook" },
3911
	{ 1, Q931_IE_USER_USER, "User-User", dump_user_user, receive_user_user, transmit_user_user },
3944
	{ 1, Q931_IE_USER_USER, "User-User Information", dump_user_user, receive_user_user, transmit_user_user },
3912
	{ 1, Q931_IE_ESCAPE_FOR_EXT, "Escape for Extension" },
3945
	{ 1, Q931_IE_ESCAPE_FOR_EXT, "Escape for Extension" },
3913
	{ 1, Q931_IE_CALL_STATUS, "Call Status" },
3946
	{ 1, Q931_IE_CALL_STATUS, "Call Status" },
3914
	{ 1, Q931_IE_CHANGE_STATUS, "Change Status", dump_change_status, receive_change_status, transmit_change_status },
3947
	{ 1, Q931_IE_CHANGE_STATUS, "Change Status Information", dump_change_status, receive_change_status, transmit_change_status },
3915
	{ 1, Q931_IE_CONNECTED_ADDR, "Connected Address", dump_connected_number, receive_connected_number, transmit_connected_number },
3948
	{ 1, Q931_IE_CONNECTED_ADDR, "Connected Address", dump_connected_number, receive_connected_number, transmit_connected_number },
3916
	{ 1, Q931_IE_CONNECTED_NUM, "Connected Number", dump_connected_number, receive_connected_number, transmit_connected_number },
3949
	{ 1, Q931_IE_CONNECTED_NUM, "Connected Number", dump_connected_number, receive_connected_number, transmit_connected_number },
3917
	{ 1, Q931_IE_CONNECTED_SUBADDR, "Connected Subaddress", dump_connected_subaddr, receive_connected_subaddr, transmit_connected_subaddr },
3950
	{ 1, Q931_IE_CONNECTED_SUBADDR, "Connected Subaddress", dump_connected_subaddr, receive_connected_subaddr, transmit_connected_subaddr },
3918
	{ 1, Q931_IE_ORIGINAL_CALLED_NUMBER, "Original Called Number", dump_redirecting_number, receive_redirecting_number, transmit_redirecting_number },
3951
	{ 1, Q931_IE_ORIGINAL_CALLED_NUMBER, "Original Called Number", dump_redirecting_number, receive_redirecting_number, transmit_redirecting_number },
3919
	{ 1, Q931_IE_USER_USER_FACILITY, "User-User Facility" },
3952
	{ 1, Q931_IE_USER_USER_FACILITY, "User-User Facility" },
[+20] [20] 5869 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.