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 1

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);
2609
	pri_message(ctrl, " ]\n");
2626
	pri_message(ctrl, " ]\n");
2610
}
2627
}
2611

    
   
2628

   
2612

    
   
2629

   
[+20] [20] 29 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)
2642

    
   
2659

   
2643
static void dump_change_status(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
2660
static void dump_change_status(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
2644
{
2661
{
2645
	int x;
2662
	int x;
2646
	
2663
	
2647
	pri_message(ctrl, "%c Change Status Information (len=%2d) [", prefix, len);
2664
	pri_message(ctrl, "%c %s (len=%2d) [", prefix, ie2str(full_ie), len);
2648
	for (x=0; x<ie->len; x++) {
2665
	for (x = 0; x < ie->len; x++) {
2649
		pri_message(ctrl, " %02x", ie->data[x] & 0x7f);
2666
		pri_message(ctrl, " %02x", ie->data[x] & 0x7f);
2650
	}
2667
	}
2651
	pri_message(ctrl, " ]\n");
2668
	pri_message(ctrl, " ]\n");
2652
}
2669
}
2653

    
   
2670

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

    
   
2724

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

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

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

    
   
2735

   
2717
static int receive_display(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len)
2736
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));
3204
	return code2str(state, hold_states, ARRAY_LEN(hold_states));
3186
}
3205
}
3187

    
   
3206

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

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

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

    
   
3215

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

    
   
3224

   
3204
static void dump_time_date(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3225
static void dump_time_date(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3205
{
3226
{
3206
	pri_message(ctrl, "%c Time Date (len=%2d) [ ", prefix, len);
3227
	pri_message(ctrl, "%c %s (len=%2d) [ ", prefix, ie2str(full_ie), len);
3207
	if (ie->len > 0)
3228
	if (ie->len > 0)
3208
		pri_message(ctrl, "%02d", ie->data[0]);
3229
		pri_message(ctrl, "%02d", ie->data[0]);
3209
	if (ie->len > 1)
3230
	if (ie->len > 1)
3210
		pri_message(ctrl, "-%02d", ie->data[1]);
3231
		pri_message(ctrl, "-%02d", ie->data[1]);
3211
	if (ie->len > 2)
3232
	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)
3293
static void dump_keypad_facility(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3273
{
3294
{
3274
	unsigned char tmp[64];
3295
	unsigned char tmp[64];
3275

    
   
3296

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

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

    
   
3301

   
3280
static int receive_keypad_facility(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len)
3302
static int receive_keypad_facility(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len)
3281
{
3303
{
3282
	if (ie->len == 0)
3304
	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;
3334
		++x;
3313
	} else {
3335
	} else {
3314
		tmp[0] = '\0';
3336
		tmp[0] = '\0';
3315
	}
3337
	}
3316
	q931_strget(buf, sizeof(buf), &ie->data[x], ie->len - x);
3338
	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);
3339
	pri_message(ctrl,

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

    
   
3342

   
3320
#define CHECK_OVERFLOW(limit) \
3343
#define CHECK_OVERFLOW(limit) \
3321
	if (tmpptr - tmp + limit >= sizeof(tmp)) { \
3344
	if (tmpptr - tmp + limit >= sizeof(tmp)) { \
3322
		*tmpptr = '\0'; \
3345
		*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);
3385
	pri_message(ctrl, "%s", tmp);
3363
}
3386
}
3364

    
   
3387

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

    
   
3391
		prefix, ie2str(full_ie), len, Q931_IE_CODESET(full_ie));
3368
	dump_ie_data(ctrl, ie->data, ie->len);
3392
	dump_ie_data(ctrl, ie->data, ie->len);
3369
	pri_message(ctrl, " ]\n");
3393
	pri_message(ctrl, " ]\n");
3370
#if 0	/* Lets not dump parse of facility contents here anymore. */
3394
#if 0	/* Lets not dump parse of facility contents here anymore. */
3371
	/*
3395
	/*
3372
	 * The ASN.1 decode dump has already been done when the facility ie was added to the outgoing
3396
	 * 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. */
3406
#endif	/* Lets not dump parse of facility contents here anymore. */
3383
}
3407
}
3384

    
   
3408

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

    
   
3459

   
3436
static void dump_cause(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3460
static void dump_cause(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3437
{
3461
{
3438
	int x;
3462
	int x;
3439
	pri_message(ctrl, "%c Cause (len=%2d) [ Ext: %d  Coding: %s (%d)  Spare: %d  Location: %s (%d)\n",
3463
	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,
3464
		prefix, ie2str(full_ie), len, ie->data[0] >> 7,

    
   
3465
		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);
3466
		(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",
3467
	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, 
3468
		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);
3469
			pri_causeclass2str((ie->data[1] & 0x7f) >> 4), (ie->data[1] & 0x7f) >> 4);
3445
	if (ie->len < 3)
3470
	if (ie->len < 3)
[+20] [20] 48 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
	}
3519
	}
3495
}
3520
}
3496

    
   
3521

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

    
   
3526

   
3502
static int receive_sending_complete(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len)
3527
static int receive_sending_complete(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len)
3503
{
3528
{
3504
	/* We've got a "Complete" message: Exect no further digits. */
3529
	/* 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]));
3572
	return code2str(info, notifies, sizeof(notifies) / sizeof(notifies[0]));
3548
}
3573
}
3549

    
   
3574

   
3550
static void dump_notify(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3575
static void dump_notify(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
3551
{
3576
{
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);
3577
	pri_message(ctrl, "%c %s (len=%2d): Ext: %d  %s (%d)\n",

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

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

    
   
3581

   
3555
static int receive_notify(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len)
3582
static int receive_notify(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len)
3556
{
3583
{
3557
	call->notify = ie->data[0] & 0x7F;
3584
	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;
3594
	return 0;
3568
}
3595
}
3569

    
   
3596

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

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

    
   
3602

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

    
   
3634

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

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

    
   
3640

   
3612
static int receive_line_information(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len)
3641
static int receive_line_information(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len)
3613
{
3642
{
3614
	call->ani2 = ie->data[0];
3643
	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;
3688
	int encoding;
3660
	int type;
3689
	int type;
3661
	int idx;
3690
	int idx;
3662
	int value;
3691
	int value;
3663
	if (len < 3) {
3692
	if (len < 3) {
3664
		pri_message(ctrl, "%c Generic Digits (len=%02d): Invalid length\n", prefix, len);
3693
		pri_message(ctrl, "%c %s (len=%02d): Invalid length\n",

    
   
3694
			prefix, ie2str(full_ie), len);
3665
		return;
3695
		return;
3666
	}
3696
	}
3667
	encoding = (ie->data[0] >> 5) & 7;
3697
	encoding = (ie->data[0] >> 5) & 7;
3668
	type = ie->data[0] & 0x1F;
3698
	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));
3699
	pri_message(ctrl, "%c %s (len=%02d): Encoding %s  Type %s\n",

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

    
   
3856

   
3826

    
   
3857

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

    
   
3867

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

    
   
3878

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

    
   
3883

   
3853
static int receive_reverse_charging_indication(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len)
3884
static int receive_reverse_charging_indication(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len)
3854
{
3885
{
3855
	call->reversecharge = ie->data[0] & 0x7;
3886
	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;
3896
	return 0;
3866
}
3897
}
3867

    
   
3898

   
3868
static struct ie ies[] = {
3899
static struct ie ies[] = {
3869
	/* Codeset 0 - Common */
3900
	/* Codeset 0 - Common */
3870
	{ 1, NATIONAL_CHANGE_STATUS, "Change Status", dump_change_status, receive_change_status, transmit_change_status },
3901
	{ 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 },
3902
	{ 0, Q931_LOCKING_SHIFT, "Locking Shift", dump_shift },
3872
	{ 0, Q931_BEARER_CAPABILITY, "Bearer Capability", dump_bearer_capability, receive_bearer_capability, transmit_bearer_capability },
3903
	{ 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 },
3904
	{ 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 },
3905
	{ 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 },
3906
	{ 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 },
3937
	{ 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 },
3938
	{ 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 },
3939
	{ 1, Q931_IE_KEYPAD_FACILITY, "Keypad Facility", dump_keypad_facility, receive_keypad_facility, transmit_keypad_facility },
3909
	{ 0, Q931_IE_SIGNAL, "Signal", dump_signal },
3940
	{ 0, Q931_IE_SIGNAL, "Signal", dump_signal },
3910
	{ 1, Q931_IE_SWITCHHOOK, "Switch-hook" },
3941
	{ 1, Q931_IE_SWITCHHOOK, "Switch-hook" },
3911
	{ 1, Q931_IE_USER_USER, "User-User", dump_user_user, receive_user_user, transmit_user_user },
3942
	{ 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" },
3943
	{ 1, Q931_IE_ESCAPE_FOR_EXT, "Escape for Extension" },
3913
	{ 1, Q931_IE_CALL_STATUS, "Call Status" },
3944
	{ 1, Q931_IE_CALL_STATUS, "Call Status" },
3914
	{ 1, Q931_IE_CHANGE_STATUS, "Change Status", dump_change_status, receive_change_status, transmit_change_status },
3945
	{ 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 },
3946
	{ 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 },
3947
	{ 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 },
3948
	{ 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 },
3949
	{ 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" },
3950
	{ 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.