mcast_get_if.c 551 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include "unp.h"
  2. int
  3. mcast_get_if(int sockfd)
  4. {
  5. switch (sockfd_to_family(sockfd)) {
  6. case AF_INET: {
  7. /* TODO: similar to mcast_set_if() */
  8. return(-1);
  9. }
  10. #ifdef IPV6
  11. case AF_INET6: {
  12. u_int idx;
  13. socklen_t len;
  14. len = sizeof(idx);
  15. if (getsockopt(sockfd, IPPROTO_IPV6, IPV6_MULTICAST_IF,
  16. &idx, &len) < 0)
  17. return(-1);
  18. return(idx);
  19. }
  20. #endif
  21. default:
  22. errno = EAFNOSUPPORT;
  23. return(-1);
  24. }
  25. }
  26. int
  27. Mcast_get_if(int sockfd)
  28. {
  29. int rc;
  30. if ( (rc = mcast_get_if(sockfd)) < 0)
  31. err_sys("mcast_get_if error");
  32. return(rc);
  33. }