forked from unpbook/unpv13e
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsctp_displayevents.c
101 lines (99 loc) · 2.66 KB
/
sctp_displayevents.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include "unp.h"
void
print_notification(char *notify_buf)
{
union sctp_notification *snp;
struct sctp_assoc_change *sac;
struct sctp_paddr_change *spc;
struct sctp_remote_error *sre;
struct sctp_send_failed *ssf;
struct sctp_shutdown_event *sse;
struct sctp_adaption_event *ae;
struct sctp_pdapi_event *pdapi;
const char *str;
snp = (union sctp_notification *)notify_buf;
switch(snp->sn_header.sn_type) {
case SCTP_ASSOC_CHANGE:
sac = &snp->sn_assoc_change;
switch(sac->sac_state) {
case SCTP_COMM_UP:
str = "COMMUNICATION UP";
break;
case SCTP_COMM_LOST:
str = "COMMUNICATION LOST";
break;
case SCTP_RESTART:
str = "RESTART";
break;
case SCTP_SHUTDOWN_COMP:
str = "SHUTDOWN COMPLETE";
break;
case SCTP_CANT_STR_ASSOC:
str = "CAN'T START ASSOC";
break;
default:
str = "UNKNOWN";
break;
} /* end switch(sac->sac_state) */
printf("SCTP_ASSOC_CHANGE: %s, assoc=0x%x\n", str,
(uint32_t)sac->sac_assoc_id);
break;
case SCTP_PEER_ADDR_CHANGE:
spc = &snp->sn_paddr_change;
switch(spc->spc_state) {
case SCTP_ADDR_AVAILABLE:
str = "ADDRESS AVAILABLE";
break;
case SCTP_ADDR_UNREACHABLE:
str = "ADDRESS UNREACHABLE";
break;
case SCTP_ADDR_REMOVED:
str = "ADDRESS REMOVED";
break;
case SCTP_ADDR_ADDED:
str = "ADDRESS ADDED";
break;
case SCTP_ADDR_MADE_PRIM:
str = "ADDRESS MADE PRIMARY";
break;
default:
str = "UNKNOWN";
break;
} /* end switch(spc->spc_state) */
printf("SCTP_PEER_ADDR_CHANGE: %s, addr=%s, assoc=0x%x\n", str,
Sock_ntop((SA *)&spc->spc_aaddr, sizeof(spc->spc_aaddr)),
(uint32_t)spc->spc_assoc_id);
break;
case SCTP_REMOTE_ERROR:
sre = &snp->sn_remote_error;
printf("SCTP_REMOTE_ERROR: assoc=0x%x error=%d\n",
(uint32_t)sre->sre_assoc_id, sre->sre_error);
break;
case SCTP_SEND_FAILED:
ssf = &snp->sn_send_failed;
printf("SCTP_SEND_FAILED: assoc=0x%x error=%d\n",
(uint32_t)ssf->ssf_assoc_id, ssf->ssf_error);
break;
case SCTP_ADAPTION_INDICATION:
ae = &snp->sn_adaption_event;
printf("SCTP_ADAPTION_INDICATION: 0x%x\n",
(u_int)ae->sai_adaption_ind);
break;
case SCTP_PARTIAL_DELIVERY_EVENT:
pdapi = &snp->sn_pdapi_event;
if(pdapi->pdapi_indication == SCTP_PARTIAL_DELIVERY_ABORTED)
printf("SCTP_PARTIAL_DELIEVERY_ABORTED\n");
else
printf("Unknown SCTP_PARTIAL_DELIVERY_EVENT 0x%x\n",
pdapi->pdapi_indication);
break;
case SCTP_SHUTDOWN_EVENT:
sse = &snp->sn_shutdown_event;
printf("SCTP_SHUTDOWN_EVENT: assoc=0x%x\n",
(uint32_t)sse->sse_assoc_id);
break;
default:
printf("Unknown notification event type=0x%x\n",
snp->sn_header.sn_type);
}
}