-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpri_q921.c
65 lines (64 loc) · 2.08 KB
/
pri_q921.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "pri_q921.h"
void syntax_q921(char *str)
{
int octet2 = convert(str[2])*16+convert(str[3]);
int octet3 = convert(str[5])*16+convert(str[6]);
int octet4 = convert(str[8])*16+convert(str[9]);
int octet5 = -1;
printf("octet2 :0x%x octet3 :0x%x octet4 :0x%x", octet2, octet3, octet4);
switch(octet4 & 0x3) {
case 0:
case 2:
octet5 = convert(str[11])*16+convert(str[12]);
printf(" octet5 :0x%x\nType : I format\n", octet5);
break;
case 1:
octet5 = convert(str[11])*16+convert(str[12]);
printf(" octet5 :0x%x\nType : S format\n", octet5);
switch(octet4) {
case 0x01:
printf("RR (receive ready)\n");
break;
case 0x05:
printf("RNR (receive not ready)\n");
break;
case 0x09:
printf("REJ (reject)\n");
break;
default:
break;
}
break;
case 3:
printf("\nType : U format\n");
switch(octet4) {
case 0x7f:
printf("SABME (set asynchronous balanced mode extended)\n");
break;
case 0x1f:
printf("DM (disconnected mode)\n");
break;
case 0x13:
printf("UI (unnumbered information)\n");
break;
case 0x53:
printf("DISC (disconnect)\n");
break;
case 0x73:
printf("UA (unnumbered acknowledgement)\n");
break;
case 0x97:
printf("FRMR (frame reject)\n");
break;
case 0xbf:
printf("XID (Exchange Identification)\n");
break;
default:
break;
}
break;
default:
break;
}
printf("\n");
}