Logo Search packages:      
Sourcecode: libnl2 version File versions  Download package

Addresses
[Routing Family]


Detailed Description

Note:
The maximum size of an address label is IFNAMSIZ.

The address may not contain a prefix length if the peer address has been specified already.

1) Address Addition
 // Allocate an empty address object to be filled out with the attributes
 // of the new address.
 struct rtnl_addr *addr = rtnl_addr_alloc();

 // Fill out the mandatory attributes of the new address. Setting the
 // local address will automatically set the address family and the
 // prefix length to the correct values.
 rtnl_addr_set_ifindex(addr, ifindex);
 rtnl_addr_set_local(addr, local_addr);

 // The label of the address can be specified, currently only supported
 // by IPv4 and DECnet.
 rtnl_addr_set_label(addr, "mylabel");

 // The peer address can be specified if necessary, in either case a peer
 // address will be sent to the kernel in order to fullfil the interface
 // requirements. If none is set, it will equal the local address.
 // Note: Real peer addresses are only supported by IPv4 for now.
 rtnl_addr_set_peer(addr, peer_addr);

 // In case you want to have the address have a scope other than global
 // it may be overwritten using rtnl_addr_set_scope(). The scope currently
 // cannot be set for IPv6 addresses.
 rtnl_addr_set_scope(addr, rtnl_str2scope("site"));

 // Broadcast address may be specified using the relevant
 // functions, the address family will be verified if one of the other
 // addresses has been set already. Currently only works for IPv4.
 rtnl_addr_set_broadcast(addr, broadcast_addr);

 // Build the netlink message and send it to the kernel, the operation will
 // block until the operation has been completed. Alternatively the required
 // netlink message can be built using rtnl_addr_build_add_request() to be
 // sent out using nl_send_auto_complete().
 rtnl_addr_add(sk, addr, 0);

 // Free the memory
 rtnl_addr_put(addr);
2) Address Deletion
 // Allocate an empty address object to be filled out with the attributes
 // matching the address to be deleted. Alternatively a fully equipped
 // address object out of a cache can be used instead.
 struct rtnl_addr *addr = rtnl_addr_alloc();

 // The only mandatory parameter besides the address family is the interface
 // index the address is on, i.e. leaving out all other parameters will
 // result in all addresses of the specified address family interface tuple
 // to be deleted.
 rtnl_addr_set_ifindex(addr, ifindex);

 // Specyfing the address family manually is only required if neither the
 // local nor peer address have been specified.
 rtnl_addr_set_family(addr, AF_INET);

 // Specyfing the local address is optional but the best choice to delete
 // specific addresses.
 rtnl_addr_set_local(addr, local_addr);

 // The label of the address can be specified, currently only supported
 // by IPv4 and DECnet.
 rtnl_addr_set_label(addr, "mylabel");

 // The peer address can be specified if necessary, in either case a peer
 // address will be sent to the kernel in order to fullfil the interface
 // requirements. If none is set, it will equal the local address.
 // Note: Real peer addresses are only supported by IPv4 for now.
 rtnl_addr_set_peer(addr, peer_addr);

 // Build the netlink message and send it to the kernel, the operation will
 // block until the operation has been completed. Alternatively the required
 // netlink message can be built using rtnl_addr_build_delete_request()
 // to be sent out using nl_send_auto_complete().
 rtnl_addr_delete(sk, addr, 0);

 // Free the memory
 rtnl_addr_put(addr);


Flags Translations

static struct trans_tbl addr_flags []
char * rtnl_addr_flags2str (int flags, char *buf, size_t size)
int rtnl_addr_str2flags (const char *name)

Attributes

static int __assign_addr (struct rtnl_addr *addr, struct nl_addr **pos, struct nl_addr *new, int flag)
struct nl_addr * rtnl_addr_get_broadcast (struct rtnl_addr *addr)
uint32_t rtnl_addr_get_create_time (struct rtnl_addr *addr)
int rtnl_addr_get_family (struct rtnl_addr *addr)
unsigned int rtnl_addr_get_flags (struct rtnl_addr *addr)
int rtnl_addr_get_ifindex (struct rtnl_addr *addr)
char * rtnl_addr_get_label (struct rtnl_addr *addr)
uint32_t rtnl_addr_get_last_update_time (struct rtnl_addr *addr)
struct nl_addr * rtnl_addr_get_local (struct rtnl_addr *addr)
struct nl_addr * rtnl_addr_get_multicast (struct rtnl_addr *addr)
struct nl_addr * rtnl_addr_get_peer (struct rtnl_addr *addr)
uint32_t rtnl_addr_get_preferred_lifetime (struct rtnl_addr *addr)
int rtnl_addr_get_prefixlen (struct rtnl_addr *addr)
int rtnl_addr_get_scope (struct rtnl_addr *addr)
uint32_t rtnl_addr_get_valid_lifetime (struct rtnl_addr *addr)
int rtnl_addr_set_broadcast (struct rtnl_addr *addr, struct nl_addr *bcast)
void rtnl_addr_set_family (struct rtnl_addr *addr, int family)
void rtnl_addr_set_flags (struct rtnl_addr *addr, unsigned int flags)
void rtnl_addr_set_ifindex (struct rtnl_addr *addr, int ifindex)
int rtnl_addr_set_label (struct rtnl_addr *addr, const char *label)
int rtnl_addr_set_local (struct rtnl_addr *addr, struct nl_addr *local)
int rtnl_addr_set_multicast (struct rtnl_addr *addr, struct nl_addr *multicast)
int rtnl_addr_set_peer (struct rtnl_addr *addr, struct nl_addr *peer)
void rtnl_addr_set_preferred_lifetime (struct rtnl_addr *addr, uint32_t lifetime)
void rtnl_addr_set_prefixlen (struct rtnl_addr *addr, int prefix)
void rtnl_addr_set_scope (struct rtnl_addr *addr, int scope)
void rtnl_addr_set_valid_lifetime (struct rtnl_addr *addr, uint32_t lifetime)
void rtnl_addr_unset_flags (struct rtnl_addr *addr, unsigned int flags)

Addition

int rtnl_addr_add (struct nl_sock *sk, struct rtnl_addr *addr, int flags)
int rtnl_addr_build_add_request (struct rtnl_addr *addr, int flags, struct nl_msg **result)

Allocation/Freeing

struct rtnl_addr * rtnl_addr_alloc (void)
void rtnl_addr_put (struct rtnl_addr *addr)

Cache Management

int rtnl_addr_alloc_cache (struct nl_sock *sk, struct nl_cache **result)

Deletion

int rtnl_addr_build_delete_request (struct rtnl_addr *addr, int flags, struct nl_msg **result)
int rtnl_addr_delete (struct nl_sock *sk, struct rtnl_addr *addr, int flags)

Functions

static char * addr_attrs2str (int attrs, char *buf, size_t len)
static int addr_clone (struct nl_object *_dst, struct nl_object *_src)
static int addr_compare (struct nl_object *_a, struct nl_object *_b, uint32_t attrs, int flags)
static void addr_constructor (struct nl_object *obj)
static void addr_dump_details (struct nl_object *obj, struct nl_dump_params *p)
static void addr_dump_line (struct nl_object *obj, struct nl_dump_params *p)
static void addr_dump_stats (struct nl_object *obj, struct nl_dump_params *p)
static void __exit addr_exit (void)
static void addr_free_data (struct nl_object *obj)
static void __init addr_init (void)
static int addr_msg_parser (struct nl_cache_ops *ops, struct sockaddr_nl *who, struct nlmsghdr *nlh, struct nl_parser_param *pp)
static int addr_request_update (struct nl_cache *cache, struct nl_sock *sk)
static int build_addr_msg (struct rtnl_addr *tmpl, int cmd, int flags, struct nl_msg **result)

Variables

static struct trans_tbl addr_attrs []
static struct nl_af_group addr_groups []
static struct nl_object_ops addr_obj_ops
static struct nla_policy addr_policy [IFA_MAX+1]
static struct nl_cache_ops rtnl_addr_ops


Generated by  Doxygen 1.6.0   Back to index