OpenVAS Libraries  8.0.3
Data Structures | Macros | Functions
pcap.c File Reference
#include <netinet/in.h>
#include <resolv.h>
#include <pcap.h>
#include <net/if.h>
#include <arpa/inet.h>
#include <sys/ioctl.h>
#include <netdb.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <ifaddrs.h>
#include "bpf_share.h"
#include "pcap_openvas.h"
#include "openvas_logging.h"
#include "network.h"
#include "support.h"

Data Structures

struct  interface_info
 
struct  myroute
 

Macros

#define MAXROUTES   1024
 

Functions

struct interface_infogetinterfaces (int *howmany)
 
struct interface_infov6_getinterfaces (int *howmany)
 
int getipv6routes (struct myroute *myroutes, int *numroutes)
 
int v6_is_local_ip (struct in6_addr *addr)
 
int v6_get_mac_addr (struct in6_addr *addr, char **mac)
 We send an empty UDP packet to the remote host, and read back its mac. More...
 
int v6_ipaddr2devname (char *dev, int sz, struct in6_addr *addr)
 
int ipaddr2devname (char *dev, int sz, struct in_addr *addr)
 
int v6_islocalhost (struct in6_addr *addr)
 Tests whether a packet sent to IP is LIKELY to route through the kernel localhost interface. More...
 
int islocalhost (struct in_addr *addr)
 Tests whether a packet sent to IP is LIKELY to route through the kernel localhost interface. More...
 
int get_datalink_size (int datalink)
 
int get_random_bytes (void *buf, int numbytes)
 
int v6_getsourceip (struct in6_addr *src, struct in6_addr *dst)
 
int getsourceip (struct in_addr *src, struct in_addr *dst)
 
int getipv4routes (struct myroute *myroutes, int *numroutes)
 
char * v6_routethrough (struct in6_addr *dest, struct in6_addr *source)
 An awesome function to determine what interface a packet to a given destination should be routed through. More...
 
char * routethrough (struct in_addr *dest, struct in_addr *source)
 An awesome function to determine what interface a packet to a given destination should be routed through. More...
 

Macro Definition Documentation

#define MAXROUTES   1024

Function Documentation

int get_datalink_size ( int  datalink)
int get_random_bytes ( void *  buf,
int  numbytes 
)
struct interface_info * getinterfaces ( int *  howmany)
Parameters
[out]howmanyReturn location for the number of interfaces found (might be NULL).
int getipv4routes ( struct myroute myroutes,
int *  numroutes 
)
int getipv6routes ( struct myroute myroutes,
int *  numroutes 
)
int getsourceip ( struct in_addr *  src,
struct in_addr *  dst 
)
int ipaddr2devname ( char *  dev,
int  sz,
struct in_addr *  addr 
)
int islocalhost ( struct in_addr *  addr)

Tests whether a packet sent to IP is LIKELY to route through the kernel localhost interface.

char* routethrough ( struct in_addr *  dest,
struct in_addr *  source 
)

An awesome function to determine what interface a packet to a given destination should be routed through.

It returns NULL if no appropriate interface is found, oterwise it returns the device name and fills in the source parameter. Some of the stuff is from Stevens' Unix Network Programming V2. He had an easier suggestion for doing this (in the book), but it isn't portable :(

int v6_get_mac_addr ( struct in6_addr *  addr,
char **  mac 
)

We send an empty UDP packet to the remote host, and read back its mac.

address.

(we should first interrogate the kernel's arp cache - we may rely on libdnet in the future to do that)

As a bonus, this function works well as a local ping.

struct interface_info * v6_getinterfaces ( int *  howmany)
int v6_getsourceip ( struct in6_addr *  src,
struct in6_addr *  dst 
)
int v6_ipaddr2devname ( char *  dev,
int  sz,
struct in6_addr *  addr 
)
int v6_is_local_ip ( struct in6_addr *  addr)
int v6_islocalhost ( struct in6_addr *  addr)

Tests whether a packet sent to IP is LIKELY to route through the kernel localhost interface.

char* v6_routethrough ( struct in6_addr *  dest,
struct in6_addr *  source 
)

An awesome function to determine what interface a packet to a given destination should be routed through.

It returns NULL if no appropriate interface is found, oterwise it returns the device name and fills in the source parameter. Some of the stuff is from Stevens' Unix Network Programming V2. He had an easier suggestion for doing this (in the book), but it isn't portable :(