util.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * util.h Utility structures and prototypes.
  3. *
  4. * License: BSD
  5. *
  6. */
  7. #ifndef UTIL_H
  8. # define UTIL_H
  9. #include <string.h>
  10. #ifndef HAVE_STRLCPY
  11. size_t rc_strlcpy(char *dst, char const *src, size_t siz);
  12. # define strlcpy rc_strlcpy
  13. #endif
  14. #include <includes.h>
  15. #if !defined(SA_LEN)
  16. #define SA_LEN(sa) \
  17. (((sa)->sa_family == AF_INET) ? \
  18. sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6))
  19. #define SS_LEN(sa) \
  20. (((sa)->ss_family == AF_INET) ? \
  21. sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6))
  22. #endif
  23. #define SA_GET_INADDR(sa) \
  24. (((sa)->sa_family == AF_INET) ? \
  25. ((void*)&(((struct sockaddr_in*)(sa))->sin_addr)) : ((void*)&(((struct sockaddr_in6*)(sa))->sin6_addr)))
  26. #define SA_GET_INLEN(sa) \
  27. ((sa)->sa_family == AF_INET) ? \
  28. sizeof(struct in_addr) : sizeof(struct in6_addr)
  29. //int rc_find_server_addr(rc_handle const *, char const *, struct addrinfo **, char *, unsigned flags);
  30. int rc_find_server_addr(rc_handle const *rh, char const *server_name, struct addrinfo** info, char *secret, unsigned flags);
  31. /* flags to rc_getaddrinfo() */
  32. #define PW_AI_PASSIVE 1
  33. #define PW_AI_AUTH (1<<1)
  34. #define PW_AI_ACCT (1<<2)
  35. struct addrinfo *rc_getaddrinfo (char const *host, unsigned flags);
  36. void rc_own_bind_addr(rc_handle *rh, struct sockaddr_storage *lia);
  37. #endif /* UTIL_H */