OpenVAS Libraries
9.0.3
|
#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"
Go to the source code of this file.
Data Structures | |
struct | interface_info |
struct | myroute |
Macros | |
#define | MAXROUTES 1024 |
Functions | |
struct interface_info * | getinterfaces (int *howmany) |
struct interface_info * | v6_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... | |
#define MAXROUTES 1024 |
Definition at line 39 of file pcap.c.
Referenced by getipv4routes(), getipv6routes(), and v6_is_local_ip().
int get_datalink_size | ( | int | datalink | ) |
Definition at line 442 of file pcap.c.
Referenced by capture_next_packet(), capture_next_v6_packet(), ids_open_sock_tcp(), ids_send(), nasl_pcap_next(), nasl_send_capture(), scan(), and v6_get_mac_addr().
int get_random_bytes | ( | void * | buf, |
int | numbytes | ||
) |
Definition at line 482 of file pcap.c.
References timeval().
Referenced by getsourceip(), and v6_getsourceip().
struct interface_info * getinterfaces | ( | int * | howmany | ) |
[out] | howmany | Return location for the number of interfaces found (might be NULL). |
Definition at line 630 of file pcap.c.
References log_legacy_write(), interface_info::name, and name.
Referenced by ipaddr2devname().
int getipv4routes | ( | struct myroute * | myroutes, |
int * | numroutes | ||
) |
Definition at line 826 of file pcap.c.
References myroute::dest6, myroute::dev, log_legacy_write(), myroute::mask, MAXROUTES, name, and v6_getinterfaces().
int getipv6routes | ( | struct myroute * | myroutes, |
int * | numroutes | ||
) |
Definition at line 948 of file pcap.c.
References myroute::dev, log_legacy_write(), myroute::mask, MAXROUTES, name, and v6_getinterfaces().
Referenced by v6_is_local_ip().
int getsourceip | ( | struct in_addr * | src, |
struct in_addr * | dst | ||
) |
Definition at line 787 of file pcap.c.
References get_random_bytes().
int ipaddr2devname | ( | char * | dev, |
int | sz, | ||
struct in_addr * | addr | ||
) |
Definition at line 351 of file pcap.c.
References interface_info::addr, getinterfaces(), and name.
Referenced by islocalhost().
int islocalhost | ( | struct in_addr * | addr | ) |
Tests whether a packet sent to IP is LIKELY to route through the kernel localhost interface.
Definition at line 415 of file pcap.c.
References interface_info::addr, and ipaddr2devname().
Referenced by init_capture_device(), nasl_tcp_ping(), and plugin_run_synscan().
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 :(
Definition at line 1244 of file pcap.c.
Referenced by ids_open_sock_tcp(), ids_send(), init_capture_device(), nasl_pcap_next(), nasl_send_capture(), nasl_tcp_ping(), and openbpf().
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.
Definition at line 171 of file pcap.c.
References bpf_close(), bpf_datalink(), bpf_next(), bpf_open_live(), get_datalink_size(), and v6_routethrough().
struct interface_info * v6_getinterfaces | ( | int * | howmany | ) |
Definition at line 549 of file pcap.c.
References interface_info::addr6, interface_info::mask, and name.
Referenced by getipv4routes(), getipv6routes(), v6_ipaddr2devname(), and v6_is_local_ip().
int v6_getsourceip | ( | struct in6_addr * | src, |
struct in6_addr * | dst | ||
) |
Definition at line 692 of file pcap.c.
References get_random_bytes(), and name.
Referenced by nasl_this_host().
int v6_ipaddr2devname | ( | char * | dev, |
int | sz, | ||
struct in6_addr * | addr | ||
) |
Definition at line 316 of file pcap.c.
References interface_info::addr, interface_info::addr6, name, and v6_getinterfaces().
Referenced by v6_islocalhost().
int v6_is_local_ip | ( | struct in6_addr * | addr | ) |
Definition at line 106 of file pcap.c.
References getipv6routes(), MAXROUTES, name, and v6_getinterfaces().
Referenced by nasl_islocalnet().
int v6_islocalhost | ( | struct in6_addr * | addr | ) |
Tests whether a packet sent to IP is LIKELY to route through the kernel localhost interface.
Definition at line 378 of file pcap.c.
References interface_info::addr, and v6_ipaddr2devname().
Referenced by init_v6_capture_device(), nasl_islocalhost(), nasl_send_v6packet(), nasl_tcp_v6_ping(), and nasl_this_host().
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 :(
Definition at line 1061 of file pcap.c.
Referenced by ids_open_sock_tcp(), ids_send(), init_v6_capture_device(), nasl_pcap_next(), nasl_send_capture(), nasl_tcp_v6_ping(), v6_get_mac_addr(), and v6_openbpf().