DTS Application Library  0.2.3
Application library containing referenced objects and interfaces to common libraries
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
interface.c File Reference

Wrapper arround Linux libnetlink for managing network interfaces. More...

#include <netinet/in.h>
#include <linux/if_vlan.h>
#include <linux/if_ether.h>
#include <linux/if_packet.h>
#include <linux/if_tun.h>
#include <linux/if_arp.h>
#include <linux/sockios.h>
#include <linux/if.h>
#include <ifaddrs.h>
#include <sys/ioctl.h>
#include <netdb.h>
#include <sys/time.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include "include/dtsapp.h"
#include "libnetlink/include/libnetlink.h"
#include "libnetlink/include/ll_map.h"
#include "libnetlink/include/utils.h"

Go to the source code of this file.

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...
 
void eui48to64 (unsigned char *mac48, unsigned char *eui64)
 Generate IPv6 address from mac address. More...
 
int get_ip6_addrprefix (const char *iface, unsigned char *prefix)
 Generate Unique Local IPv6 Unicast Addresses RFC 4193. More...
 
int score_ipv4 (struct sockaddr_in *sa4, char *ipaddr, int iplen)
 Return a score for a IPv4 addrress. More...
 
int score_ipv6 (struct sockaddr_in6 *sa6, char *ipaddr, int iplen)
 Return a score for a IPv6 addrress. More...
 
const char * get_ifipaddr (const char *iface, int family)
 Find best IP adress for a interface. More...
 

Detailed Description

Wrapper arround Linux libnetlink for managing network interfaces.

Definition in file interface.c.