ipoe.h 2.9 KB
Newer Older
K
Kozlov Dmitry 已提交
1 2 3 4 5 6 7 8
#ifndef __IPOE_H
#define __IPOE_H

#include <stdint.h>
#include <pthread.h>

#include "triton.h"
#include "ap_session.h"
K
Kozlov Dmitry 已提交
9
#include "ipdb.h"
K
Kozlov Dmitry 已提交
10 11
#include "dhcpv4.h"

12 13 14 15 16 17
#ifndef ETH_ALEN
#define ETH_ALEN 6
#endif

struct arp_serv;

D
Dmitry Kozlov 已提交
18
struct ipoe_serv {
K
Kozlov Dmitry 已提交
19 20 21 22
	struct list_head entry;
	struct triton_context_t ctx;
	char *ifname;
	int ifindex;
23
	uint8_t hwaddr[ETH_ALEN];
K
Kozlov Dmitry 已提交
24
	struct list_head sessions;
25
	struct list_head addr_list;
K
Kozlov Dmitry 已提交
26
	struct dhcpv4_serv *dhcpv4;
K
Kozlov Dmitry 已提交
27
	struct dhcpv4_relay *dhcpv4_relay;
28
	struct arp_serv *arp;
D
Dmitry Kozlov 已提交
29
	struct list_head disc_list;
30
	struct list_head req_list;
D
Dmitry Kozlov 已提交
31
	struct triton_timer_t disc_timer;
D
Dmitry Kozlov 已提交
32
	struct triton_timer_t timer;
K
Kozlov Dmitry 已提交
33
	pthread_mutex_t lock;
D
Dmitry Kozlov 已提交
34 35
	int parent_ifindex;
	int vid;
K
Kozlov Dmitry 已提交
36
	int opt_mode;
37
	uint32_t opt_src;
38
	int opt_arp;
39 40 41 42
	int opt_username;
#ifdef USE_LUA
	char *opt_lua_username_func;
#endif
K
Kozlov Dmitry 已提交
43 44 45
	int opt_shared:1;
	int opt_dhcpv4:1;
	int opt_up:1;
46
	int opt_ifcfg:1;
47
	int opt_nat:1;
48
	int need_close:1;
49
	int active:1;
K
Kozlov Dmitry 已提交
50 51
};

D
Dmitry Kozlov 已提交
52
struct ipoe_session {
K
Kozlov Dmitry 已提交
53 54 55 56
	struct list_head entry;
	struct triton_context_t ctx;
	struct triton_timer_t timer;
	struct ipoe_serv *serv;
57
	struct dhcpv4_serv *dhcpv4;
K
Kozlov Dmitry 已提交
58 59
	struct ap_ctrl ctrl;
	struct ap_session ses;
60
	uint8_t hwaddr[ETH_ALEN];
K
Kozlov Dmitry 已提交
61 62 63 64
	struct dhcpv4_option *client_id;
	struct dhcpv4_option *relay_agent;
	uint8_t *agent_circuit_id;
	uint8_t *agent_remote_id;
K
Kozlov Dmitry 已提交
65 66
	uint32_t xid;
	uint32_t giaddr;
67 68
	uint32_t yiaddr;
	uint32_t siaddr;
69
	uint32_t router;
K
Kozlov Dmitry 已提交
70
	uint32_t relay_server_id;
71
	int mask;
K
Kozlov Dmitry 已提交
72
	int lease_time;
K
Kozlov Dmitry 已提交
73 74
	uint8_t *data;
	struct dhcpv4_packet *dhcpv4_request;
K
Kozlov Dmitry 已提交
75
	struct dhcpv4_packet *dhcpv4_relay_reply;
76
	int relay_retransmit;
77
	int ifindex;
K
Kozlov Dmitry 已提交
78
	struct ipv4db_item_t ipv4;
79
	int ifcfg:1;
D
Dmitry Kozlov 已提交
80
	int started:1;
81
	int terminating:1;
82
	int dhcp_addr:1;
K
Kozlov Dmitry 已提交
83
	int relay_addr:1;
84
	int l4_redirect:1;
K
Kozlov Dmitry 已提交
85
	int l4_redirect_set:1;
K
Kozlov Dmitry 已提交
86 87
};

D
Dmitry Kozlov 已提交
88
struct ipoe_session_info {
89 90 91 92 93 94
	struct list_head entry;
	int ifindex;
	uint32_t addr;
	uint32_t peer_addr;
};

95 96 97 98 99
struct arp_serv {
	struct triton_md_handler_t h;
	struct ipoe_serv *ipoe;
};

K
Kozlov Dmitry 已提交
100 101 102 103
#ifdef USE_LUA
int ipoe_lua_set_username(struct ipoe_session *, const char *func);
#endif

104 105 106 107
struct iphdr;
struct ethhdr;

void ipoe_recv_up(int ifindex, struct ethhdr *eth, struct iphdr *iph);
D
Dmitry Kozlov 已提交
108 109
void ipoe_vlan_notify(int ifindex, int vid);

110 111 112
struct ipoe_session *ipoe_session_alloc(void);

struct ipoe_serv *ipoe_find_serv(const char *ifname);
113 114 115

void ipoe_nl_add_net(uint32_t addr, int mask);
void ipoe_nl_delete_nets(void);
116 117
void ipoe_nl_add_interface(int ifindex);
void ipoe_nl_delete_interfaces(void);
118 119
int ipoe_nl_create(uint32_t peer_addr, uint32_t addr, const char *ifname, uint8_t *hwaddr);
void ipoe_nl_delete(int ifindex);
K
Kozlov Dmitry 已提交
120
int ipoe_nl_modify(int ifindex, uint32_t peer_addr, uint32_t addr, const char *ifname, uint8_t *hwaddr);
121
void ipoe_nl_get_sessions(struct list_head *list);
D
Dmitry Kozlov 已提交
122 123 124
int ipoe_nl_add_vlan_mon(int ifindex, long *mask, int len);
int ipoe_nl_add_vlan_mon_vid(int ifindex, int vid);
int ipoe_nl_del_vlan_mon(int ifindex);
125

126 127
struct arp_serv *arpd_start(struct ipoe_serv *ipoe);
void arpd_stop(struct arp_serv *arp);
D
Dmitry Kozlov 已提交
128

K
Kozlov Dmitry 已提交
129 130
#endif