sctp_displayevents.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #include "unp.h"
  2. void
  3. print_notification(char *notify_buf)
  4. {
  5. union sctp_notification *snp;
  6. struct sctp_assoc_change *sac;
  7. struct sctp_paddr_change *spc;
  8. struct sctp_remote_error *sre;
  9. struct sctp_send_failed *ssf;
  10. struct sctp_shutdown_event *sse;
  11. struct sctp_adaption_event *ae;
  12. struct sctp_pdapi_event *pdapi;
  13. const char *str;
  14. snp = (union sctp_notification *)notify_buf;
  15. switch(snp->sn_header.sn_type) {
  16. case SCTP_ASSOC_CHANGE:
  17. sac = &snp->sn_assoc_change;
  18. switch(sac->sac_state) {
  19. case SCTP_COMM_UP:
  20. str = "COMMUNICATION UP";
  21. break;
  22. case SCTP_COMM_LOST:
  23. str = "COMMUNICATION LOST";
  24. break;
  25. case SCTP_RESTART:
  26. str = "RESTART";
  27. break;
  28. case SCTP_SHUTDOWN_COMP:
  29. str = "SHUTDOWN COMPLETE";
  30. break;
  31. case SCTP_CANT_STR_ASSOC:
  32. str = "CAN'T START ASSOC";
  33. break;
  34. default:
  35. str = "UNKNOWN";
  36. break;
  37. } /* end switch(sac->sac_state) */
  38. printf("SCTP_ASSOC_CHANGE: %s, assoc=0x%x\n", str,
  39. (uint32_t)sac->sac_assoc_id);
  40. break;
  41. case SCTP_PEER_ADDR_CHANGE:
  42. spc = &snp->sn_paddr_change;
  43. switch(spc->spc_state) {
  44. case SCTP_ADDR_AVAILABLE:
  45. str = "ADDRESS AVAILABLE";
  46. break;
  47. case SCTP_ADDR_UNREACHABLE:
  48. str = "ADDRESS UNREACHABLE";
  49. break;
  50. case SCTP_ADDR_REMOVED:
  51. str = "ADDRESS REMOVED";
  52. break;
  53. case SCTP_ADDR_ADDED:
  54. str = "ADDRESS ADDED";
  55. break;
  56. case SCTP_ADDR_MADE_PRIM:
  57. str = "ADDRESS MADE PRIMARY";
  58. break;
  59. default:
  60. str = "UNKNOWN";
  61. break;
  62. } /* end switch(spc->spc_state) */
  63. printf("SCTP_PEER_ADDR_CHANGE: %s, addr=%s, assoc=0x%x\n", str,
  64. Sock_ntop((SA *)&spc->spc_aaddr, sizeof(spc->spc_aaddr)),
  65. (uint32_t)spc->spc_assoc_id);
  66. break;
  67. case SCTP_REMOTE_ERROR:
  68. sre = &snp->sn_remote_error;
  69. printf("SCTP_REMOTE_ERROR: assoc=0x%x error=%d\n",
  70. (uint32_t)sre->sre_assoc_id, sre->sre_error);
  71. break;
  72. case SCTP_SEND_FAILED:
  73. ssf = &snp->sn_send_failed;
  74. printf("SCTP_SEND_FAILED: assoc=0x%x error=%d\n",
  75. (uint32_t)ssf->ssf_assoc_id, ssf->ssf_error);
  76. break;
  77. case SCTP_ADAPTION_INDICATION:
  78. ae = &snp->sn_adaption_event;
  79. printf("SCTP_ADAPTION_INDICATION: 0x%x\n",
  80. (u_int)ae->sai_adaption_ind);
  81. break;
  82. case SCTP_PARTIAL_DELIVERY_EVENT:
  83. pdapi = &snp->sn_pdapi_event;
  84. if(pdapi->pdapi_indication == SCTP_PARTIAL_DELIVERY_ABORTED)
  85. printf("SCTP_PARTIAL_DELIEVERY_ABORTED\n");
  86. else
  87. printf("Unknown SCTP_PARTIAL_DELIVERY_EVENT 0x%x\n",
  88. pdapi->pdapi_indication);
  89. break;
  90. case SCTP_SHUTDOWN_EVENT:
  91. sse = &snp->sn_shutdown_event;
  92. printf("SCTP_SHUTDOWN_EVENT: assoc=0x%x\n",
  93. (uint32_t)sse->sse_assoc_id);
  94. break;
  95. default:
  96. printf("Unknown notification event type=0x%x\n",
  97. snp->sn_header.sn_type);
  98. }
  99. }