addr.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * netlink/addr.h Abstract Address
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation version 2.1
  7. * of the License.
  8. *
  9. * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
  10. */
  11. #ifndef NETLINK_ADDR_H_
  12. #define NETLINK_ADDR_H_
  13. #include <netlink/netlink.h>
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. struct nl_addr;
  18. /* Creation */
  19. extern struct nl_addr * nl_addr_alloc(size_t);
  20. extern struct nl_addr * nl_addr_build(int, void *, size_t);
  21. extern struct nl_addr * nl_addr_parse(const char *, int);
  22. extern struct nl_addr * nl_addr_clone(struct nl_addr *);
  23. /* Destroyage */
  24. extern void nl_addr_destroy(struct nl_addr *);
  25. /* Usage Management */
  26. extern struct nl_addr * nl_addr_get(struct nl_addr *);
  27. extern void nl_addr_put(struct nl_addr *);
  28. extern int nl_addr_shared(struct nl_addr *);
  29. extern int nl_addr_cmp(struct nl_addr *, struct nl_addr *);
  30. extern int nl_addr_cmp_prefix(struct nl_addr *, struct nl_addr *);
  31. extern int nl_addr_iszero(struct nl_addr *);
  32. extern int nl_addr_valid(char *, int);
  33. extern int nl_addr_guess_family(struct nl_addr *);
  34. extern int nl_addr_fill_sockaddr(struct nl_addr *,
  35. struct sockaddr *, socklen_t *);
  36. extern struct addrinfo *nl_addr_info(struct nl_addr *addr);
  37. extern int nl_addr_resolve(struct nl_addr *addr, char *host, size_t hostlen);
  38. /* Access Functions */
  39. extern void nl_addr_set_family(struct nl_addr *, int);
  40. extern int nl_addr_get_family(struct nl_addr *);
  41. extern int nl_addr_set_binary_addr(struct nl_addr *, void *,
  42. size_t);
  43. extern void * nl_addr_get_binary_addr(struct nl_addr *);
  44. extern unsigned int nl_addr_get_len(struct nl_addr *);
  45. extern void nl_addr_set_prefixlen(struct nl_addr *, int);
  46. extern unsigned int nl_addr_get_prefixlen(struct nl_addr *);
  47. /* Address Family Translations */
  48. extern char * nl_af2str(int, char *, size_t);
  49. extern int nl_str2af(const char *);
  50. /* Translations to Strings */
  51. extern char * nl_addr2str(struct nl_addr *, char *, size_t);
  52. #ifdef __cplusplus
  53. }
  54. #endif
  55. #endif