summaryrefslogtreecommitdiff
path: root/accel-pptpd/ppp/ppp_ccp.h
blob: 3e4596977c4f4604dea7251d2336545ffefc4852 (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
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
93
94
#ifndef PPP_CCP_H
#define PPP_CCP_H

#include <stdint.h>

#include "triton.h"
#include "ppp_fsm.h"
/*
 * Options.
 */
#define CI_COMP	2	  /* IP-Compress-Protocol */
#define CI_ADDR 3   /* IP-Address */
#define CI_DNS1 129 /* Primary-DNS-Address */
#define CI_DNS2 131 /* Secondary-DNS-Address */

struct ccp_hdr_t
{
	uint16_t proto;
	uint8_t code;
	uint8_t id;
	uint16_t len;
} __attribute__((packed));
struct ccp_opt_hdr_t
{
	uint8_t id;
	uint8_t len;
} __attribute__((packed));
struct ccp_opt8_t
{
	struct ccp_opt_hdr_t hdr;
	uint8_t val;
} __attribute__((packed));
struct ccp_opt16_t
{
	struct ccp_opt_hdr_t hdr;
	uint16_t val;
} __attribute__((packed));
struct ccp_opt32_t
{
	struct ccp_opt_hdr_t hdr;
	uint32_t val;
} __attribute__((packed));

#define CCP_OPT_NONE  0
#define CCP_OPT_ACK   1
#define CCP_OPT_NAK  -1
#define CCP_OPT_REJ  -2
#define CCP_OPT_FAIL -3

struct ppp_ccp_t;
struct ccp_option_handler_t;

struct ccp_option_t
{
	struct list_head entry;
	int id;
	int len;
	int state;
	struct ccp_option_handler_t *h;
};

struct ccp_option_handler_t
{
	struct list_head entry;
	struct ccp_option_t* (*init)(struct ppp_ccp_t*);
	int (*send_conf_req)(struct ppp_ccp_t*,struct ccp_option_t*,uint8_t*);
	int (*send_conf_rej)(struct ppp_ccp_t*,struct ccp_option_t*,uint8_t*);
	int (*send_conf_nak)(struct ppp_ccp_t*,struct ccp_option_t*,uint8_t*);
	int (*recv_conf_req)(struct ppp_ccp_t*,struct ccp_option_t*,uint8_t*);
	int (*recv_conf_rej)(struct ppp_ccp_t*,struct ccp_option_t*,uint8_t*);
	int (*recv_conf_nak)(struct ppp_ccp_t*,struct ccp_option_t*,uint8_t*);
	int (*recv_conf_ack)(struct ppp_ccp_t*,struct ccp_option_t*,uint8_t*);
	void (*free)(struct ppp_ccp_t*,struct ccp_option_t*);
	void (*print)(void (*print)(const char *fmt,...), struct ccp_option_t*,uint8_t*);
};

struct ppp_ccp_t
{
	struct ppp_layer_data_t ld;
	struct ppp_handler_t hnd;
	struct ppp_fsm_t fsm;
	struct ppp_t *ppp;
	struct list_head options;

	struct list_head ropt_list; // last received ConfReq
	int ropt_len;
	
	int conf_req_len;
};

int ccp_option_register(struct ccp_option_handler_t *h);

#endif