-
Notifications
You must be signed in to change notification settings - Fork 2
/
6brd.h
92 lines (77 loc) · 2.4 KB
/
6brd.h
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/**
* Copyright (C) 2012-2013 Steven Barth <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License v2 as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#pragma once
#include <stddef.h>
#include <netinet/in.h>
#include "nloop.h"
#ifndef container_of
#define container_of(ptr, type, member) ( \
(type *)( (char *)ptr - offsetof(type,member) ))
#endif
struct interface;
struct odhcpd_event {
struct uloop_fd uloop;
void (*handle_dgram)(void *addr, void *data, size_t len,
struct interface *iface);
void (*handle_error)(struct odhcpd_event *e, int error);
void (*recv_msgs)(struct odhcpd_event *e);
};
struct netevent_handler_info {
struct interface *iface;
struct {
struct in6_addr dst;
uint16_t state;
uint8_t flags;
} neigh;
};
void ndp_netevent_cb
(unsigned long event, struct netevent_handler_info *info);
enum netevents {
NETEV_NEIGH6_ADD,
NETEV_NEIGH6_DEL,
};
struct config {
bool foreground;
int log_level;
int cnt;
};
extern struct config config;
struct interface {
int ifindex;
char *ifname;
int learn_routes;
int external;
struct odhcpd_event ndp_event;
};
extern struct interface *interfaces;
// Exported main functions
int odhcpd_register(struct odhcpd_event *event);
int odhcpd_deregister(struct odhcpd_event *event);
void do_log (int priority, const char *format, ...);
ssize_t odhcpd_send(int socket, struct sockaddr_in6 *dest,
struct iovec *iov, size_t iov_len,
const struct interface *iface);
struct interface* odhcpd_get_interface_by_name(const char *name);
int odhcpd_get_mac(const struct interface *iface, uint8_t mac[6]);
struct interface* odhcpd_get_interface_by_index(int ifindex);
int netlink_setup_route(const struct in6_addr *addr, const int prefixlen,
const int ifindex, const struct in6_addr *gw,
const uint32_t metric, const int add);
int netlink_setup_proxy_neigh(const struct in6_addr *addr,
const int ifindex, const int add);
void netlink_dump_neigh_table(const int proxy);
// Exported module initializers
int netlink_init(void);
int ndp_init(void);
int ndp_setup_interface(struct interface *iface, int enable);