144d362409d5469aed47d19e7908d19bd194493aThomas Graf/* 244d362409d5469aed47d19e7908d19bd194493aThomas Graf * netlink/addr.h Abstract Address 344d362409d5469aed47d19e7908d19bd194493aThomas Graf * 444d362409d5469aed47d19e7908d19bd194493aThomas Graf * This library is free software; you can redistribute it and/or 544d362409d5469aed47d19e7908d19bd194493aThomas Graf * modify it under the terms of the GNU Lesser General Public 644d362409d5469aed47d19e7908d19bd194493aThomas Graf * License as published by the Free Software Foundation version 2.1 744d362409d5469aed47d19e7908d19bd194493aThomas Graf * of the License. 844d362409d5469aed47d19e7908d19bd194493aThomas Graf * 9eed2afaab7aa72fae393a395a8879b91a922ff5eThomas Graf * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch> 1044d362409d5469aed47d19e7908d19bd194493aThomas Graf */ 1144d362409d5469aed47d19e7908d19bd194493aThomas Graf 1244d362409d5469aed47d19e7908d19bd194493aThomas Graf#ifndef NETLINK_ADDR_H_ 1344d362409d5469aed47d19e7908d19bd194493aThomas Graf#define NETLINK_ADDR_H_ 1444d362409d5469aed47d19e7908d19bd194493aThomas Graf 1544d362409d5469aed47d19e7908d19bd194493aThomas Graf#include <netlink/netlink.h> 1644d362409d5469aed47d19e7908d19bd194493aThomas Graf 1744d362409d5469aed47d19e7908d19bd194493aThomas Graf#ifdef __cplusplus 1844d362409d5469aed47d19e7908d19bd194493aThomas Grafextern "C" { 1944d362409d5469aed47d19e7908d19bd194493aThomas Graf#endif 2044d362409d5469aed47d19e7908d19bd194493aThomas Graf 2144d362409d5469aed47d19e7908d19bd194493aThomas Grafstruct nl_addr; 2244d362409d5469aed47d19e7908d19bd194493aThomas Graf 2344d362409d5469aed47d19e7908d19bd194493aThomas Graf/* Creation */ 2444d362409d5469aed47d19e7908d19bd194493aThomas Grafextern struct nl_addr * nl_addr_alloc(size_t); 25eed2afaab7aa72fae393a395a8879b91a922ff5eThomas Grafextern struct nl_addr * nl_addr_alloc_attr(struct nlattr *, int); 2644d362409d5469aed47d19e7908d19bd194493aThomas Grafextern struct nl_addr * nl_addr_build(int, void *, size_t); 278a3efffa5b3fde252675239914118664d36a2c24Thomas Grafextern int nl_addr_parse(const char *, int, struct nl_addr **); 2844d362409d5469aed47d19e7908d19bd194493aThomas Grafextern struct nl_addr * nl_addr_clone(struct nl_addr *); 2944d362409d5469aed47d19e7908d19bd194493aThomas Graf 3044d362409d5469aed47d19e7908d19bd194493aThomas Graf/* Destroyage */ 3144d362409d5469aed47d19e7908d19bd194493aThomas Grafextern void nl_addr_destroy(struct nl_addr *); 3244d362409d5469aed47d19e7908d19bd194493aThomas Graf 3344d362409d5469aed47d19e7908d19bd194493aThomas Graf/* Usage Management */ 3444d362409d5469aed47d19e7908d19bd194493aThomas Grafextern struct nl_addr * nl_addr_get(struct nl_addr *); 3544d362409d5469aed47d19e7908d19bd194493aThomas Grafextern void nl_addr_put(struct nl_addr *); 3644d362409d5469aed47d19e7908d19bd194493aThomas Grafextern int nl_addr_shared(struct nl_addr *); 3744d362409d5469aed47d19e7908d19bd194493aThomas Graf 3844d362409d5469aed47d19e7908d19bd194493aThomas Grafextern int nl_addr_cmp(struct nl_addr *, struct nl_addr *); 3944d362409d5469aed47d19e7908d19bd194493aThomas Grafextern int nl_addr_cmp_prefix(struct nl_addr *, struct nl_addr *); 403ad4665be2f192291238cbe78118a57ec42436c6Thomas Grafextern int nl_addr_iszero(struct nl_addr *); 4144d362409d5469aed47d19e7908d19bd194493aThomas Grafextern int nl_addr_valid(char *, int); 4244d362409d5469aed47d19e7908d19bd194493aThomas Grafextern int nl_addr_guess_family(struct nl_addr *); 4344d362409d5469aed47d19e7908d19bd194493aThomas Grafextern int nl_addr_fill_sockaddr(struct nl_addr *, 4444d362409d5469aed47d19e7908d19bd194493aThomas Graf struct sockaddr *, socklen_t *); 458a3efffa5b3fde252675239914118664d36a2c24Thomas Grafextern int nl_addr_info(struct nl_addr *, struct addrinfo **); 4644d362409d5469aed47d19e7908d19bd194493aThomas Grafextern int nl_addr_resolve(struct nl_addr *addr, char *host, size_t hostlen); 4744d362409d5469aed47d19e7908d19bd194493aThomas Graf 4844d362409d5469aed47d19e7908d19bd194493aThomas Graf/* Access Functions */ 4944d362409d5469aed47d19e7908d19bd194493aThomas Grafextern void nl_addr_set_family(struct nl_addr *, int); 5044d362409d5469aed47d19e7908d19bd194493aThomas Grafextern int nl_addr_get_family(struct nl_addr *); 5144d362409d5469aed47d19e7908d19bd194493aThomas Grafextern int nl_addr_set_binary_addr(struct nl_addr *, void *, 5244d362409d5469aed47d19e7908d19bd194493aThomas Graf size_t); 5344d362409d5469aed47d19e7908d19bd194493aThomas Grafextern void * nl_addr_get_binary_addr(struct nl_addr *); 5444d362409d5469aed47d19e7908d19bd194493aThomas Grafextern unsigned int nl_addr_get_len(struct nl_addr *); 5544d362409d5469aed47d19e7908d19bd194493aThomas Grafextern void nl_addr_set_prefixlen(struct nl_addr *, int); 5644d362409d5469aed47d19e7908d19bd194493aThomas Grafextern unsigned int nl_addr_get_prefixlen(struct nl_addr *); 5744d362409d5469aed47d19e7908d19bd194493aThomas Graf 5844d362409d5469aed47d19e7908d19bd194493aThomas Graf/* Address Family Translations */ 5944d362409d5469aed47d19e7908d19bd194493aThomas Grafextern char * nl_af2str(int, char *, size_t); 6044d362409d5469aed47d19e7908d19bd194493aThomas Grafextern int nl_str2af(const char *); 6144d362409d5469aed47d19e7908d19bd194493aThomas Graf 6244d362409d5469aed47d19e7908d19bd194493aThomas Graf/* Translations to Strings */ 6344d362409d5469aed47d19e7908d19bd194493aThomas Grafextern char * nl_addr2str(struct nl_addr *, char *, size_t); 6444d362409d5469aed47d19e7908d19bd194493aThomas Graf 6544d362409d5469aed47d19e7908d19bd194493aThomas Graf#ifdef __cplusplus 6644d362409d5469aed47d19e7908d19bd194493aThomas Graf} 6744d362409d5469aed47d19e7908d19bd194493aThomas Graf#endif 6844d362409d5469aed47d19e7908d19bd194493aThomas Graf 6944d362409d5469aed47d19e7908d19bd194493aThomas Graf#endif 70