aboutsummaryrefslogtreecommitdiffstats
path: root/pingu_iface.h
blob: e690506b81228cee27c0940790c5b5d2432a492f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef PINGU_IFACE_H
#define PINGU_IFACE_H

#include <netinet/in.h>
#include <ev.h>
#include "list.h"

union sockaddr_any {
	struct sockaddr sa;
	struct sockaddr_in sin;
	struct sockaddr_in6 sin6;
};

struct pingu_gateway {
	union sockaddr_any gw;
	int metric;
	struct list_head gateway_list_entry;
};

struct pingu_iface {
	char name[32];
	int index;
	int has_binding;
	int has_link;
	int fd;
	union sockaddr_any primary_addr;
	int route_table;
	struct list_head iface_list_entry;
	struct list_head ping_list;
	struct list_head gateway_list;
	struct ev_io socket_watcher;
};

struct pingu_iface *pingu_iface_get_by_name(const char *name);
struct pingu_iface *pingu_iface_get_by_index(int index);
int pingu_iface_bind_socket(struct pingu_iface *iface, int log_error);
int pingu_iface_usable(struct pingu_iface *iface);
int pingu_iface_init(struct ev_loop *loop, struct list_head *host_list);

void pingu_iface_set_addr(struct pingu_iface *iface, int family,
			  void *data, int len);

#endif