DTS Application Library
0.2.3
Application library containing referenced objects and interfaces to common libraries
|
Implement various interface routines from libnetlink. More...
Files | |
file | interface.c |
Wrapper arround Linux libnetlink for managing network interfaces. | |
Data Structures | |
struct | iplink_req |
IP Netlink request. More... | |
struct | ipaddr_req |
IP Netlink IP addr request. More... | |
Enumerations | |
enum | ipv4_score { IPV4_SCORE_ZEROCONF = 1 << 0, IPV4_SCORE_RESERVED = 1 << 1, IPV4_SCORE_ROUTABLE = 1 << 2 } |
Order of precidence of ipv4. More... | |
enum | ipv6_score { IPV6_SCORE_RESERVED = 1 << 0, IPV6_SCORE_SIXIN4 = 1 << 1, IPV6_SCORE_ROUTABLE = 1 << 2 } |
Return best ipv6 address in order of FFC/7 2002/16 ... More... | |
Functions | |
void | closenetlink () |
Close netlink socket on application termination. More... | |
int | get_iface_index (const char *ifname) |
Get the netlink interface for a named interface. More... | |
int | delete_kernvlan (char *ifname, int vid) |
Delete a VLAN. More... | |
int | create_kernvlan (char *ifname, unsigned short vid) |
Create a VLAN on a interface. More... | |
int | delete_kernmac (char *ifname) |
Delete Kernel MAC VLAN. More... | |
int | create_kernmac (char *ifname, char *macdev, unsigned char *mac) |
Create a kernal MAC VLAN. More... | |
int | set_interface_flags (int ifindex, int set, int clear) |
Alter interface flags. More... | |
int | set_interface_addr (int ifindex, const unsigned char *hwaddr) |
Set interface MAC addr. More... | |
int | set_interface_name (int ifindex, const char *name) |
Rename interface. More... | |
int | interface_bind (char *iface, int protocol) |
Bind to device fd may be a existing socket. More... | |
void | randhwaddr (unsigned char *addr) |
create random MAC address More... | |
int | create_tun (const char *ifname, const unsigned char *hwaddr, int flags) |
Create a tunnel device. More... | |
int | ifdown (const char *ifname, int flags) |
Set interface down. More... | |
int | ifup (const char *ifname, int flags) |
Set interface up. More... | |
int | ifrename (const char *oldname, const char *newname) |
Rename interface helper. More... | |
int | ifhwaddr (const char *ifname, unsigned char *hwaddr) |
Get MAC addr for interface. More... | |
int | set_interface_ipaddr (char *ifname, char *ipaddr) |
Set IP addr on interface. More... | |
const char * | get_ifipaddr (const char *iface, int family) |
Find best IP adress for a interface. More... | |
Implement various interface routines from libnetlink.
enum ipv4_score |
Order of precidence of ipv4.
Enumerator | |
---|---|
IPV4_SCORE_ZEROCONF |
Zeroconf IP's 169.254/16. |
IPV4_SCORE_RESERVED |
Reseverd "private" ip addresses. |
IPV4_SCORE_ROUTABLE |
Routable IP's. |
Definition at line 63 of file interface.c.
enum ipv6_score |
Return best ipv6 address in order of FFC/7 2002/16 ...
Enumerator | |
---|---|
IPV6_SCORE_RESERVED |
Adminstrivly allocated addresses (FC/7) |
IPV6_SCORE_SIXIN4 |
6in4 address space |
IPV6_SCORE_ROUTABLE |
Other routable addresses. |
Definition at line 73 of file interface.c.
void closenetlink | ( | void | ) |
Close netlink socket on application termination.
Definition at line 130 of file interface.c.
References objunref().
int create_kernmac | ( | char * | ifname, |
char * | macdev, | ||
unsigned char * | mac | ||
) |
Create a kernal MAC VLAN.
ifname | Interface name to create |
macdev | Base interface |
mac | MAC address to use or random if NULL. |
Definition at line 282 of file interface.c.
References get_iface_index(), iplink_req::n, objalloc(), objlock(), objref(), objunlock(), objunref(), randhwaddr(), and strlenzero().
int create_kernvlan | ( | char * | ifname, |
unsigned short | vid | ||
) |
Create a VLAN on a interface.
ifname | Interface to add VLAN to. |
vid | VLAN id to add. |
Definition at line 214 of file interface.c.
References get_iface_index(), iplink_req::n, objalloc(), objlock(), objref(), objunlock(), objunref(), and strlenzero().
int create_tun | ( | const char * | ifname, |
const unsigned char * | hwaddr, | ||
int | flags | ||
) |
Create a tunnel device.
ifname | Interface name to create.. |
hwaddr | Hardware address to assign (optionally). |
flags | Flags to set device properties. |
Definition at line 496 of file interface.c.
References get_iface_index(), set_interface_addr(), and set_interface_flags().
int delete_kernmac | ( | char * | ifname | ) |
Delete Kernel MAC VLAN.
ifname | Interface to delete. |
Definition at line 272 of file interface.c.
int delete_kernvlan | ( | char * | ifname, |
int | vid | ||
) |
Delete a VLAN.
ifname | Interface we deleting vlan from. |
vid | VLAN id to delete. |
Definition at line 201 of file interface.c.
int get_iface_index | ( | const char * | ifname | ) |
Get the netlink interface for a named interface.
ifname | Interface name. |
Definition at line 139 of file interface.c.
References objlock(), objref(), objunlock(), and objunref().
Referenced by create_kernmac(), create_kernvlan(), create_tun(), ifdown(), ifhwaddr(), ifrename(), ifup(), interface_bind(), mcast_socket(), and set_interface_ipaddr().
const char* get_ifipaddr | ( | const char * | iface, |
int | family | ||
) |
Find best IP adress for a interface.
iface | Interface name. |
family | PF_INET or PF_INET6. |
Definition at line 783 of file interface.c.
References score_ipv4(), score_ipv6(), and strlenzero().
Referenced by mcast_socket().
int ifdown | ( | const char * | ifname, |
int | flags | ||
) |
Set interface down.
ifname | Interface name. |
flags | Additional flags to clear. |
Definition at line 535 of file interface.c.
References get_iface_index(), and set_interface_flags().
Referenced by ifrename().
int ifhwaddr | ( | const char * | ifname, |
unsigned char * | hwaddr | ||
) |
Get MAC addr for interface.
ifname | Interface name |
hwaddr | Buffer to place MAC in char[ETH_ALEN] |
Definition at line 588 of file interface.c.
References get_iface_index(), objref(), objunref(), and strlenzero().
Referenced by get_ip6_addrprefix().
int ifrename | ( | const char * | oldname, |
const char * | newname | ||
) |
Rename interface helper.
oldname | Original name. |
newname | New name. |
Definition at line 571 of file interface.c.
References get_iface_index(), ifdown(), and set_interface_name().
int ifup | ( | const char * | ifname, |
int | flags | ||
) |
Set interface up.
ifname | Interface name. |
flags | Additional flags to set. |
Definition at line 553 of file interface.c.
References get_iface_index(), and set_interface_flags().
int interface_bind | ( | char * | iface, |
int | protocol | ||
) |
Bind to device fd may be a existing socket.
iface | Interface to bind too. |
protocol | Protocol to use. |
Definition at line 453 of file interface.c.
References get_iface_index(), and set_interface_flags().
void randhwaddr | ( | unsigned char * | addr | ) |
create random MAC address
addr | Buffer char[ETH_ALEN] filled with the new address. |
Definition at line 485 of file interface.c.
References genrand().
Referenced by create_kernmac().
int set_interface_addr | ( | int | ifindex, |
const unsigned char * | hwaddr | ||
) |
Set interface MAC addr.
ifindex | Interface index. |
hwaddr | MAC address to set. |
Definition at line 388 of file interface.c.
References iplink_req::i, iplink_req::n, objalloc(), objlock(), objref(), objunlock(), and objunref().
Referenced by create_tun().
int set_interface_flags | ( | int | ifindex, |
int | set, | ||
int | clear | ||
) |
Alter interface flags.
ifindex | Interface index. |
set | Flags to set. |
clear | Flags to clear. |
Definition at line 348 of file interface.c.
References iplink_req::i, iplink_req::n, objalloc(), objlock(), objref(), objunlock(), and objunref().
Referenced by create_tun(), ifdown(), ifup(), and interface_bind().
int set_interface_ipaddr | ( | char * | ifname, |
char * | ipaddr | ||
) |
Set IP addr on interface.
ifname | Interface to assign IP to |
ipaddr | IP Addr to assign. |
Definition at line 611 of file interface.c.
References get_iface_index(), ipaddr_req::i, ipaddr_req::n, objalloc(), objlock(), objref(), objunlock(), and objunref().
int set_interface_name | ( | int | ifindex, |
const char * | name | ||
) |
Rename interface.
ifindex | Interface index. |
name | New interface name. |
Definition at line 421 of file interface.c.
References iplink_req::i, iplink_req::n, objalloc(), objlock(), objref(), objunlock(), and objunref().
Referenced by ifrename().