Dibbler - a portable DHCPv6  1.0.2RC1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
lowlevel-linux.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <syslog.h>
#include <fcntl.h>
#include <netdb.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <linux/netdevice.h>
#include <linux/if_arp.h>
#include <linux/sockios.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
#include <fnmatch.h>
#include <time.h>
#include <errno.h>
#include "libnetlink.h"
#include "ll_map.h"
#include "utils.h"
#include "rt_names.h"
#include "Portable.h"
+ Include dependency graph for lowlevel-linux.c:

Classes

struct  nlmsg_list

Macros

#define _GNU_SOURCE
#define ADDROPER_ADD   1
#define ADDROPER_DEL   0
#define ADDROPER_UPDATE   2
#define IF_RA_MANAGED   0x40
#define IF_RA_OTHERCONF   0x80
#define IPV6_RECVPKTINFO   IPV6_PKTINFO

Functions

int default_scope (inet_prefix *lcl)
const char * dnet_ntop (int af, const void *addr, char *str, size_t len)
int dnet_pton (int af, const char *src, void *addr)
char * error_message ()
int get_mac_from_ipv6 (const char *iface_name, int ifindex, const char *v6addr, char *mac, int *mac_len)
 gets MAC address from the specified IPv6 address
int get_rt_realms (__u32 *realms, char *arg)
char * getAAAKey (uint32_t SPI, unsigned *len)
char * getAAAKeyFilename (uint32_t SPI)
struct ifaceif_list_get ()
void if_list_release (struct iface *list)
int ipaddr_add (const char *ifacename, int ifaceid, const char *addr, unsigned long pref, unsigned long valid, int prefixLength)
int ipaddr_add_or_del (const char *addr, const char *ifacename, int prefixLen, unsigned long preferred, unsigned long valid, int mode)
int ipaddr_del (const char *ifacename, int ifaceid, const char *addr, int prefixLength)
void ipaddr_global_get (int *count, char **buf, int ifindex, struct nlmsg_list *ainfo)
void ipaddr_local_get (int *count, char **buf, int ifindex, struct nlmsg_list *ainfo)
int ipaddr_update (const char *ifacename, int ifindex, const char *addr, unsigned long pref, unsigned long valid, int prefixLength)
const char * ipx_ntop (int af, const void *addr, char *str, size_t len)
int is_addr_tentative (char *ifacename, int iface, char *addr)
uint32_t link_get_mo_bits (struct rtattr *rta)
int lowlevelExit ()
int lowlevelInit ()
void microsleep (int microsecs)
int print_addrinfo (struct nlmsghdr *n)
void print_link_flags (unsigned flags)
int print_linkinfo (struct nlmsghdr *n)
int print_selected_addrinfo (int ifindex, struct nlmsg_list *ainfo)
void release_nlmsg_list (struct nlmsg_list *n)
int rtnl_dsfield_a2n (__u32 *id, char *arg)
char * rtnl_dsfield_n2a (int id, char *buf, int len)
int rtnl_rtntype_a2n (int *id, char *arg)
char * rtnl_rtntype_n2a (int id, char *buf, int len)
int rtnl_rtprot_a2n (__u32 *id, char *arg)
char * rtnl_rtprot_n2a (int id, char *buf, int len)
int rtnl_rtrealm_a2n (__u32 *id, char *arg)
char * rtnl_rtrealm_n2a (int id, char *buf, int len)
int rtnl_rtscope_a2n (__u32 *id, char *arg)
char * rtnl_rtscope_n2a (int id, char *buf, int len)
int rtnl_rttable_a2n (__u32 *id, char *arg)
char * rtnl_rttable_n2a (int id, char *buf, int len)
int sock_add (char *ifacename, int ifaceid, char *addr, int port, int thisifaceonly, int reuse)
int sock_del (int fd)
int sock_recv (int fd, char *myPlainAddr, char *peerPlainAddr, char *buf, int buflen)
int sock_send (int sock, char *addr, char *buf, int message_len, int port, int iface)
int store_nlmsg (const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)

Variables

char * _SL_
char Message [1024] = {0}
int preferred_family = AF_INET6
struct rtnl_handle rth
int show_stats = 0

Macro Definition Documentation

#define _GNU_SOURCE
#define ADDROPER_ADD   1
#define ADDROPER_DEL   0
#define ADDROPER_UPDATE   2
#define IF_RA_MANAGED   0x40
#define IF_RA_OTHERCONF   0x80
#define IPV6_RECVPKTINFO   IPV6_PKTINFO

Function Documentation

int default_scope ( inet_prefix lcl)
const char* dnet_ntop ( int  af,
const void *  addr,
char *  str,
size_t  len 
)
int dnet_pton ( int  af,
const char *  src,
void *  addr 
)
char* error_message ( )
int get_mac_from_ipv6 ( const char *  iface_name,
int  ifindex,
const char *  v6addr,
char *  mac,
int *  mac_len 
)

gets MAC address from the specified IPv6 address

This is called immediately after we received message from that address, so the neighbor cache is guaranteed to have entry for it. This is highly os specific

Parameters
iface_namenetwork interface name
ifindexnetwork interface index
v6addrtext represenation of the IPv6 address
macpointer to MAC buffer (length specified in mac_len)
mac_lenspecifies MAC buffer length. Must be set so number of bytes set by the function
Returns
0 if successful, negative values if there are errors
Todo:
: Implement this for Linux see "/sbin/ip -6 neigh"
int get_rt_realms ( __u32 *  realms,
char *  arg 
)
char* getAAAKey ( uint32_t  SPI,
unsigned *  len 
)
char* getAAAKeyFilename ( uint32_t  SPI)
struct iface* if_list_get ( )
read
Todo:
: Ugly workaround. Please remove one BSD guys fix their kernel.
void if_list_release ( struct iface list)
int ipaddr_add ( const char *  ifacename,
int  ifaceid,
const char *  addr,
unsigned long  pref,
unsigned long  valid,
int  prefixLength 
)
int ipaddr_add_or_del ( const char *  addr,
const char *  ifacename,
int  prefixLen,
unsigned long  preferred,
unsigned long  valid,
int  mode 
)

adds, updates or deletes addresses to interface

Parameters
addr
ifacename
prefixLen
preferred
valid
mode- 0-delete, 1-add, 2-update
Returns
int ipaddr_del ( const char *  ifacename,
int  ifaceid,
const char *  addr,
int  prefixLength 
)
void ipaddr_global_get ( int *  count,
char **  bufPtr,
int  ifindex,
struct nlmsg_list ainfo 
)

returns non-local addresses for specified interface

void ipaddr_local_get ( int *  count,
char **  bufPtr,
int  ifindex,
struct nlmsg_list ainfo 
)

returns local addresses for specified interface

int ipaddr_update ( const char *  ifacename,
int  ifindex,
const char *  addr,
unsigned long  pref,
unsigned long  valid,
int  prefixLength 
)
Todo:
: Linux kernel currently does not provide API for dynamic addresses
const char* ipx_ntop ( int  af,
const void *  addr,
char *  str,
size_t  len 
)
int is_addr_tentative ( char *  ifacename,
int  iface,
char *  addr 
)
Todo:
: implement this
uint32_t link_get_mo_bits ( struct rtattr *  rta)

extracts M(managed) and O(other conf) flags set by Router Advertisement

Parameters
rtaa pointer to tb[IFLA_PROTINFO] message received over netlink
Returns
flags (see IF_RA_MANAGED and IF_RA_OTHERCONF)
int lowlevelExit ( )
int lowlevelInit ( )
void microsleep ( int  microsecs)
int print_addrinfo ( struct nlmsghdr *  n)
void print_link_flags ( unsigned  flags)
int print_linkinfo ( struct nlmsghdr *  n)
int print_selected_addrinfo ( int  ifindex,
struct nlmsg_list ainfo 
)
void release_nlmsg_list ( struct nlmsg_list n)
int rtnl_dsfield_a2n ( __u32 *  id,
char *  arg 
)
char* rtnl_dsfield_n2a ( int  id,
char *  buf,
int  len 
)
int rtnl_rtntype_a2n ( int *  id,
char *  arg 
)
char* rtnl_rtntype_n2a ( int  id,
char *  buf,
int  len 
)
int rtnl_rtprot_a2n ( __u32 *  id,
char *  arg 
)
char* rtnl_rtprot_n2a ( int  id,
char *  buf,
int  len 
)
int rtnl_rtrealm_a2n ( __u32 *  id,
char *  arg 
)
char* rtnl_rtrealm_n2a ( int  id,
char *  buf,
int  len 
)
int rtnl_rtscope_a2n ( __u32 *  id,
char *  arg 
)
char* rtnl_rtscope_n2a ( int  id,
char *  buf,
int  len 
)
int rtnl_rttable_a2n ( __u32 *  id,
char *  arg 
)
char* rtnl_rttable_n2a ( int  id,
char *  buf,
int  len 
)
int sock_add ( char *  ifacename,
int  ifaceid,
char *  addr,
int  port,
int  thisifaceonly,
int  reuse 
)
int sock_del ( int  fd)
int sock_recv ( int  fd,
char *  myPlainAddr,
char *  peerPlainAddr,
char *  buf,
int  buflen 
)
int sock_send ( int  sock,
char *  addr,
char *  buf,
int  message_len,
int  port,
int  iface 
)
int store_nlmsg ( const struct sockaddr_nl *  who,
struct nlmsghdr *  n,
void *  arg 
)

Variable Documentation

char* _SL_
char Message[1024] = {0}
int preferred_family = AF_INET6
struct rtnl_handle rth
int show_stats = 0