sctp_check_notify.c 830 B

12345678910111213141516171819202122232425262728293031
  1. #include "unp.h"
  2. void
  3. check_notification(int sock_fd,char *recvline,int rd_len)
  4. {
  5. union sctp_notification *snp;
  6. struct sctp_assoc_change *sac;
  7. struct sockaddr_storage *sal,*sar;
  8. int num_rem, num_loc;
  9. snp = (union sctp_notification *)recvline;
  10. if(snp->sn_header.sn_type == SCTP_ASSOC_CHANGE) {
  11. sac = &snp->sn_assoc_change;
  12. if((sac->sac_state == SCTP_COMM_UP) ||
  13. (sac->sac_state == SCTP_RESTART)) {
  14. num_rem = sctp_getpaddrs(sock_fd,sac->sac_assoc_id,&sar);
  15. printf("There are %d remote addresses and they are:\n",
  16. num_rem);
  17. sctp_print_addresses(sar,num_rem);
  18. sctp_freepaddrs(sar);
  19. num_loc = sctp_getladdrs(sock_fd,sac->sac_assoc_id,&sal);
  20. printf("There are %d local addresses and they are:\n",
  21. num_loc);
  22. sctp_print_addresses(sal,num_loc);
  23. sctp_freeladdrs(sal);
  24. }
  25. }
  26. }