diff options
Diffstat (limited to 'accel-pppd/ctrl/l2tp/l2tp.h')
-rw-r--r-- | accel-pppd/ctrl/l2tp/l2tp.h | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/accel-pppd/ctrl/l2tp/l2tp.h b/accel-pppd/ctrl/l2tp/l2tp.h new file mode 100644 index 0000000..ac9b8e0 --- /dev/null +++ b/accel-pppd/ctrl/l2tp/l2tp.h @@ -0,0 +1,88 @@ +#ifndef __L2TP_H +#define __L2TP_H + +#include <netinet/in.h> + +#include "list.h" +#include "l2tp_prot.h" + +#define ATTR_TYPE_NONE 0 +#define ATTR_TYPE_INT16 1 +#define ATTR_TYPE_INT32 2 +#define ATTR_TYPE_INT64 3 +#define ATTR_TYPE_OCTETS 4 +#define ATTR_TYPE_STRING 5 + +#define L2TP_MAX_PACKET_SIZE 65536 +#define L2TP_MAX_TID 65534 + +#define L2TP_V2_PROTOCOL_VERSION ( 1 << 8 | 0 ) + +typedef union +{ + uint32_t uint32; + int32_t int32; + uint16_t uint16; + int16_t int16; + uint64_t uint64; + uint8_t *octets; + char *string; +} l2tp_value_t; + +struct l2tp_dict_attr_t +{ + struct list_head entry; + const char *name; + int id; + int type; + int M; + int H; + struct list_head values; +}; + +struct l2tp_dict_value_t +{ + struct list_head entry; + const char *name; + l2tp_value_t val; +}; + +struct l2tp_attr_t +{ + struct list_head entry; + struct l2tp_dict_attr_t *attr; + int M:1; + int H:1; + int length; + l2tp_value_t val; +}; + +struct l2tp_packet_t +{ + struct list_head entry; + struct sockaddr_in addr; + struct l2tp_hdr_t hdr; + struct list_head attrs; +}; + +extern int conf_verbose; + +struct l2tp_dict_attr_t *l2tp_dict_find_attr_by_name(const char *name); +struct l2tp_dict_attr_t *l2tp_dict_find_attr_by_id(int id); +struct l2tp_dict_value_t *l2tp_dict_find_value(struct l2tp_dict_attr_t *attr, l2tp_value_t val); + +int l2tp_recv(int fd, struct l2tp_packet_t **, struct in_pktinfo *); +void l2tp_packet_free(struct l2tp_packet_t *); +void l2tp_packet_print(struct l2tp_packet_t *, void (*print)(const char *fmt, ...)); +struct l2tp_packet_t *l2tp_packet_alloc(int ver, int msg_type, struct sockaddr_in *addr); +int l2tp_packet_send(int sock, struct l2tp_packet_t *); +int l2tp_packet_add_int16(struct l2tp_packet_t *pack, int id, int16_t val, int M); +int l2tp_packet_add_int32(struct l2tp_packet_t *pack, int id, int32_t val, int M); +int l2tp_packet_add_string(struct l2tp_packet_t *pack, int id, const char *val, int M); +int l2tp_packet_add_octets(struct l2tp_packet_t *pack, int id, const uint8_t *val, int size, int M); + +void l2tp_nl_create_tunnel(int fd, int tid, int peer_tid); +void l2tp_nl_create_session(int tid, int sid, int peer_sid); +void l2tp_nl_delete_tunnel(int tid); + +#endif |