summaryrefslogtreecommitdiff
path: root/accel-pptpd/ppp_lcp.h
blob: d241de6ad795e458b7ecf321eba01831bf41be1c (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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#ifndef PPP_LCP_H
#define PPP_LCP_H

#include <stdint.h>

#include "triton/triton.h"
#include "ppp_fsm.h"
/*
 * Options.
 */
#define CI_VENDOR	0	/* Vendor Specific */
#define CI_MRU		1	/* Maximum Receive Unit */
#define CI_ASYNCMAP	2	/* Async Control Character Map */
#define CI_AUTH    3	/* Authentication Type */
#define CI_QUALITY	4	/* Quality Protocol */
#define CI_MAGIC	5	/* Magic Number */
#define CI_PCOMP	7	/* Protocol Field Compression */
#define CI_ACCOMP 8	/* Address/Control Field Compression */
#define CI_FCSALTERN	9	/* FCS-Alternatives */
#define CI_SDP		10	/* Self-Describing-Pad */
#define CI_NUMBERED	11	/* Numbered-Mode */
#define CI_CALLBACK	13	/* callback */
#define CI_MRRU		17	/* max reconstructed receive unit; multilink */
#define CI_SSNHF	18	/* short sequence numbers for multilink */
#define CI_EPDISC	19	/* endpoint discriminator */
#define CI_MPPLUS	22	/* Multi-Link-Plus-Procedure */
#define CI_LDISC	23	/* Link-Discriminator */
#define CI_LCPAUTH	24	/* LCP Authentication */
#define CI_COBS		25	/* Consistent Overhead Byte Stuffing */
#define CI_PREFELIS	26	/* Prefix Elision */
#define CI_MPHDRFMT	27	/* MP Header Format */
#define CI_I18N		28	/* Internationalization */
#define CI_SDL		29	/* Simple Data Link */

struct lcp_hdr_t
{
	uint16_t proto;
	uint8_t code;
	uint8_t id;
	uint16_t len;
} __attribute__((packed));
struct lcp_opt_hdr_t
{
	uint8_t id;
	uint8_t len;
} __attribute__((packed));
struct lcp_opt8_t
{
	struct lcp_opt_hdr_t hdr;
	uint8_t val;
} __attribute__((packed));
struct lcp_opt16_t
{
	struct lcp_opt_hdr_t hdr;
	uint16_t val;
} __attribute__((packed));
struct lcp_opt32_t
{
	struct lcp_opt_hdr_t hdr;
	uint32_t val;
} __attribute__((packed));

/*struct lcp_options_t
{
	int magic;
	int mtu;
	int mru;
	int accomp; // 0 - disabled, 1 - enable, 2 - allow, disabled, 3 - allow,enabled
	int pcomp;  // 0 - disabled, 1 - enable, 2 - allow, disabled, 3 - allow,enabled
	// negotiated options;
	int neg_mru;
	int neg_mtu;
	int neg_accomp; // -1 - rejected
	int neg_pcomp;
	int neg_auth[AUTH_MAX];
};*/

#define LCP_OPT_NONE  0
#define LCP_OPT_ACK   1
#define LCP_OPT_NAK  -1
#define LCP_OPT_REJ  -2
#define LCP_OPT_FAIL -3

struct ppp_lcp_t;
struct lcp_option_handler_t;

struct lcp_option_t
{
	struct list_head entry;
	int id;
	int len;
	int state;
	struct lcp_option_handler_t *h;
};

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

struct ppp_lcp_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 lcp_option_register(struct lcp_option_handler_t *h);

#endif