Mirror of :pserver:cvs@cvs.fefe.de:/cvs libowfat https://www.fefe.de/libowfat/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

33 lines
546 B

  1. #include <sys/types.h>
  2. #include <sys/socket.h>
  3. #include <netinet/in.h>
  4. #include <errno.h>
  5. #include "haveip6.h"
  6. #include "socket.h"
  7. #ifndef EAFNOSUPPORT
  8. #define EAFNOSUPPORT EINVAL
  9. #endif
  10. int socket_udp6(void)
  11. {
  12. #ifdef LIBC_HAS_IP6
  13. int s;
  14. if (noipv6) goto compat;
  15. s = socket(PF_INET6,SOCK_DGRAM,0);
  16. if (s == -1) {
  17. if (errno == EINVAL || errno == EAFNOSUPPORT) {
  18. compat:
  19. s=socket(AF_INET,SOCK_DGRAM,0);
  20. noipv6=1;
  21. if (s==-1) return -1;
  22. } else
  23. return -1;
  24. }
  25. return s;
  26. #else
  27. return socket_udp();
  28. #endif
  29. }