1/*
2 * Layer Two Tunnelling Protocol Daemon
3 * Copyright (C) 1998 Adtran, Inc.
4 * Copyright (C) 2002 Jeff McAdams
5 *
6 * Mark Spencer
7 *
8 * This software is distributed under the terms
9 * of the GPL, which you should have received
10 * along with this source.
11 *
12 * File format handling header file
13 *
14 */
15
16#ifndef _FILE_H
17#define _FILE_H
18
19#define STRLEN 80               /* Length of a string */
20
21/* Definition of a keyword */
22struct keyword
23{
24    char *keyword;
25    int (*handler) (char *word, char *value, int context, void *item);
26};
27
28struct iprange
29{
30    unsigned int start;
31    unsigned int end;
32    int sense;
33    struct iprange *next;
34};
35
36struct host
37{
38    char hostname[STRLEN];
39    int port;
40    struct host *next;
41};
42
43
44#define CONTEXT_GLOBAL 	1
45#define CONTEXT_LNS	   	2
46#define CONTEXT_LAC		3
47#define CONTEXT_DEFAULT	256
48
49#define SENSE_ALLOW -1
50#define SENSE_DENY 0
51
52#define DEFAULT_AUTH_FILE "/etc/l2tp/l2tp-secrets"
53#define ALT_DEFAULT_AUTH_FILE "/etc/l2tpd/l2tp-secrets"
54#define DEFAULT_CONFIG_FILE "/etc/l2tp/l2tpd.conf"
55#define ALT_DEFAULT_CONFIG_FILE "/etc/l2tpd/l2tpd.conf"
56#define DEFAULT_PID_FILE "/var/run/l2tpd.pid"
57
58/* Definition of an LNS */
59struct lns
60{
61    struct lns *next;
62    int exclusive;              /* Only one tunnel per host? */
63    int active;                 /* Is this actively in use? */
64    unsigned int localaddr;     /* Local IP for PPP connections */
65    int tun_rws;                /* Receive window size (tunnel) */
66    int call_rws;               /* Call rws */
67    int hbit;                   /* Permit hidden AVP's? */
68    int lbit;                   /* Use the length field? */
69    int challenge;              /* Challenge authenticate the peer? */
70    int authpeer;               /* Authenticate our peer? */
71    int authself;               /* Authenticate ourselves? */
72    char authname[STRLEN];      /* Who we authenticate as */
73    char peername[STRLEN];      /* Force peer name to this */
74    char hostname[STRLEN];      /* Hostname to report */
75    char entname[STRLEN];       /* Name of this entry */
76    struct iprange *lacs;       /* Hosts permitted to connect */
77    struct iprange *range;      /* Range of IP's we provide */
78    int passwdauth;             /* Authenticate by passwd file? (or PAM) */
79    int pap_require;            /* Require PAP auth for PPP */
80    int chap_require;           /* Require CHAP auth for PPP */
81    int pap_refuse;             /* Refuse PAP authentication for us */
82    int chap_refuse;            /* Refuse CHAP authentication for us */
83    int idle;                   /* Idle timeout in seconds */
84    unsigned int pridns;        /* Primary DNS server */
85    unsigned int secdns;        /* Secondary DNS server */
86    unsigned int priwins;       /* Primary WINS server */
87    unsigned int secwins;       /* Secondary WINS server */
88    int proxyarp;               /* Use proxy-arp? */
89    int proxyauth;              /* Allow proxy authentication? */
90    int debug;                  /* Debug PPP? */
91    char pppoptfile[STRLEN];    /* File containing PPP options */
92    struct tunnel *t;           /* Tunnel of this, if it's ready */
93};
94
95struct lac
96{
97    struct lac *next;
98    struct host *lns;           /* LNS's we can connect to */
99    struct schedule_entry *rsched;
100    int tun_rws;                /* Receive window size (tunnel) */
101    int call_rws;               /* Call rws */
102    int active;                 /* Is this connection in active use? */
103    int hbit;                   /* Permit hidden AVP's? */
104    int lbit;                   /* Use the length field? */
105    int challenge;              /* Challenge authenticate the peer? */
106    unsigned int localaddr;     /* Local IP address */
107    unsigned int remoteaddr;    /* Force remote address to this */
108    char authname[STRLEN];      /* Who we authenticate as */
109    char peername[STRLEN];      /* Force peer name to this */
110    char hostname[STRLEN];      /* Hostname to report */
111    char entname[STRLEN];       /* Name of this entry */
112    int authpeer;               /* Authenticate our peer? */
113    int authself;               /* Authenticate ourselves? */
114    int pap_require;            /* Require PAP auth for PPP */
115    int chap_require;           /* Require CHAP auth for PPP */
116    int pap_refuse;             /* Refuse PAP authentication for us */
117    int chap_refuse;            /* Refuse CHAP authentication for us */
118    int idle;                   /* Idle timeout in seconds */
119    int autodial;               /* Try to dial immediately? */
120    int defaultroute;           /* Use as default route? */
121    int redial;                 /* Redial if disconnected */
122    int rmax;                   /* Maximum # of consecutive redials */
123    int rtries;                 /* # of tries so far */
124    int rtimeout;               /* Redial every this many # of seconds */
125    char pppoptfile[STRLEN];    /* File containing PPP options */
126    int debug;
127    struct tunnel *t;           /* Our tunnel */
128    struct call *c;             /* Our call */
129};
130
131struct global
132{
133    int port;                   /* Port number to listen to */
134    char authfile[STRLEN];      /* File containing authentication info */
135    char altauthfile[STRLEN];   /* File containing authentication info */
136    char configfile[STRLEN];    /* File containing configuration info */
137    char altconfigfile[STRLEN]; /* File containing configuration info */
138    char pidfile[STRLEN];       /* File containing the pid number*/
139    int daemon;                 /* Use daemon mode? */
140    int accesscontrol;          /* Use access control? */
141    int forceuserspace;         /* Force userspace? */
142};
143
144extern struct global gconfig;   /* Global configuration options */
145
146extern struct lns *lnslist;     /* All LNS entries */
147extern struct lac *laclist;     /* All LAC entries */
148extern struct lns *deflns;      /* Default LNS config */
149extern struct lac *deflac;      /* Default LAC config */
150extern int init_config ();      /* Read in the config file */
151#endif
152