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.

103 lines
3.1 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /* source: sysutils.h */
  2. /* Copyright Gerhard Rieger and contributors (see file CHANGES) */
  3. /* Published under the GNU General Public License V.2, see file COPYING */
  4. #ifndef __sysutils_h_included
  5. #define __sysutils_h_included 1
  6. #if WITH_IP6
  7. /* not all OSes provide in6_addr that allows splitting to 16 or 32 bit junks of
  8. the host address part of sockaddr_in6; here we help ourselves */
  9. union xioin6_u {
  10. uint8_t u6_addr8[16];
  11. uint16_t u6_addr16[8];
  12. uint32_t u6_addr32[4];
  13. } ;
  14. #endif /* WITH_IP6 */
  15. #if _WITH_SOCKET
  16. union sockaddr_union {
  17. struct sockaddr soa;
  18. #if WITH_UNIX
  19. struct sockaddr_un un;
  20. #endif /* WITH_UNIX */
  21. #if _WITH_IP4
  22. struct sockaddr_in ip4;
  23. #endif /* _WITH_IP4 */
  24. #if WITH_IP6
  25. struct sockaddr_in6 ip6;
  26. #endif /* WITH_IP6 */
  27. #if WITH_INTERFACE
  28. struct sockaddr_ll ll;
  29. #endif
  30. } ;
  31. #endif /* _WITH_SOCKET */
  32. #if _WITH_SOCKET
  33. struct xiorange {
  34. union sockaddr_union netaddr;
  35. union sockaddr_union netmask;
  36. } ;
  37. #endif /* _WITH_SOCKET */
  38. extern ssize_t writefull(int fd, const void *buff, size_t bytes);
  39. #if _WITH_SOCKET
  40. extern socklen_t socket_init(int af, union sockaddr_union *sa);
  41. #endif
  42. #if WITH_UNIX
  43. extern void socket_un_init(struct sockaddr_un *sa);
  44. #endif /* WITH_UNIX */
  45. #if _WITH_IP4
  46. extern void socket_in_init(struct sockaddr_in *sa);
  47. #endif /* _WITH_IP4 */
  48. #if _WITH_IP6
  49. extern void socket_in6_init(struct sockaddr_in6 *sa);
  50. #endif /* _WITH_IP4 */
  51. #if _WITH_SOCKET
  52. extern char *sockaddr_info(const struct sockaddr *sa, socklen_t salen, char *buff, size_t blen);
  53. #endif
  54. #if WITH_UNIX
  55. extern char *sockaddr_unix_info(const struct sockaddr_un *sa, socklen_t salen, char *buff, size_t blen);
  56. #endif /* WITH_UNIX */
  57. #if WITH_IP4
  58. extern char *inet4addr_info(uint32_t addr, char *buff, size_t blen);
  59. extern char *sockaddr_inet4_info(const struct sockaddr_in *sa, char *buff, size_t blen);
  60. #endif /* WITH_IP4 */
  61. #if WITH_IP6
  62. extern char *sockaddr_inet6_info(const struct sockaddr_in6 *sa, char *buff, size_t blen);
  63. #endif /* WITH_IP6 */
  64. #if !HAVE_INET_NTOP
  65. extern const char *inet_ntop(int pf, const void *binaddr,
  66. char *addrtext, socklen_t textlen);
  67. #endif
  68. #if defined(HAVE_SETGRENT) && defined(HAVE_GETGRENT) && defined(HAVE_ENDGRENT)
  69. extern int getusergroups(const char *user, gid_t *list, int *ngroups);
  70. #endif
  71. #if !HAVE_HSTRERROR
  72. extern const char *hstrerror(int err);
  73. #endif
  74. extern int xiopoll(struct pollfd fds[], unsigned long nfds, struct timeval *timeout);
  75. extern int parseport(const char *portname, int proto);
  76. extern int ifindexbyname(const char *ifname, int anysock);
  77. extern int ifindex(const char *ifname, unsigned int *ifindex, int anysock);
  78. extern int xiosetenv(const char *varname, const char *value, int overwrite, const char *sep);
  79. extern int
  80. xiosetenv2(const char *varname, const char *varname2, const char *value,
  81. int overwrite, const char *sep);
  82. extern int
  83. xiosetenv3(const char *varname, const char *varname2, const char *varname3,
  84. const char *value, int overwrite, const char *sep);
  85. extern int xiosetenvulong(const char *varname, unsigned long value,
  86. int overwrite);
  87. extern int xiosetenvushort(const char *varname, unsigned short value,
  88. int overwrite);
  89. #endif /* !defined(__sysutils_h_included) */