log regular cleanup actions at 3
[l2tpns.git] / l2tpns.h
1 // L2TPNS Global Stuff
2 // $Id: l2tpns.h,v 1.49.2.15 2005/05/30 06:35:19 bodea Exp $
3
4 #ifndef __L2TPNS_H__
5 #define __L2TPNS_H__
6
7 #include <netinet/in.h>
8 #include <execinfo.h>
9 #include <stdio.h>
10 #include <signal.h>
11 #include <stdlib.h>
12 #include <netinet/in.h>
13 #include <sys/socket.h>
14 #include <arpa/inet.h>
15 #include <sys/types.h>
16 #include <libcli.h>
17
18 #define VERSION "2.0.22"
19
20 // Limits
21 #define MAXTUNNEL 500 // could be up to 65535
22 #define MAXSESSION 60000 // could be up to 65535
23 #define MAXTBFS 6000 // Maximum token bucket filters. Might need up to 2 * session.
24
25 #define RADIUS_SHIFT 6
26 #define RADIUS_MASK ((1 << RADIUS_SHIFT) - 1)
27 #define MAXRADIUS (1 << (8 + RADIUS_SHIFT))
28
29 #define T_UNDEF (0xffff) // A tunnel ID that won't ever be used. Mark session as undefined.
30 #define T_FREE (0) // A tunnel ID that won't ever be used. Mark session as free.
31
32 #define MAXCONTROL 1000 // max length control message we ever send...
33 #define MAXETHER (1500+18) // max packet we try sending to tun
34 #define MAXTEL 96 // telephone number
35 #define MAXPLUGINS 20 // maximum number of plugins to load
36 #define MAXRADSERVER 10 // max radius servers
37 #define MAXROUTE 10 // max static routes per session
38 #define MAXIPPOOL 131072 // max number of ip addresses in pool
39 #define RINGBUFFER_SIZE 10000 // Number of ringbuffer entries to allocate
40 #define MAX_LOG_LENGTH 512 // Maximum size of log message
41 #define ECHO_TIMEOUT 60 // Time between last packet sent and LCP ECHO generation
42 #define IDLE_TIMEOUT 240 // Time between last packet sent and LCP ECHO generation
43 #define BUSY_WAIT_TIME 3000 // 5 minutes in 1/10th seconds to wait for radius to cleanup on shutdown
44
45 // Constants
46 #ifndef ETCDIR
47 #define ETCDIR "/etc/l2tpns"
48 #endif
49
50 #ifndef LIBDIR
51 #define LIBDIR "/usr/lib/l2tpns"
52 #endif
53
54 #ifndef STATEDIR
55 #define STATEDIR "/var/lib/l2tpns"
56 #endif
57
58 #ifndef PLUGINDIR
59 #define PLUGINDIR LIBDIR // Plugins
60 #endif
61
62 #ifndef PLUGINCONF
63 #define PLUGINCONF ETCDIR // Plugin config dir
64 #endif
65
66 #ifndef FLASHDIR
67 #define FLASHDIR ETCDIR
68 #endif
69
70 #ifndef DATADIR
71 #define DATADIR STATEDIR
72 #endif
73
74 #define TUNDEVICE "/dev/net/tun"
75 #define STATEFILE DATADIR "/state.dump" // State dump file
76 #define CONFIGFILE FLASHDIR "/startup-config" // Configuration file
77 #define CLIUSERS FLASHDIR "/users" // CLI Users file
78 #define IPPOOLFILE FLASHDIR "/ip_pool" // Address pool configuration
79 #define ACCT_TIME 3000 // 5 minute accounting interval
80 #define ACCT_SHUT_TIME 600 // 1 minute for counters of shutdown sessions
81 #define L2TPPORT 1701 // L2TP port
82 #define RADPORT 1645 // old radius port...
83 #define PKTARP 0x0806 // ARP packet type
84 #define PKTIP 0x0800 // IP packet type
85 #define PSEUDOMAC 0x0200 // pseudo MAC prefix (local significant MAC)
86 #define PPPPAP 0xC023
87 #define PPPCHAP 0xC223
88 #define PPPLCP 0xC021
89 #define PPPIPCP 0x8021
90 #define PPPCCP 0x80FD
91 #define PPPIP 0x0021
92 #define PPPMP 0x003D
93 #define MIN_IP_SIZE 0x19
94 enum
95 {
96 ConfigReq = 1,
97 ConfigAck,
98 ConfigNak,
99 ConfigRej,
100 TerminateReq,
101 TerminateAck,
102 CodeRej,
103 ProtocolRej,
104 EchoReq,
105 EchoReply,
106 DiscardRequest,
107 IdentRequest
108 };
109
110 // Types
111 typedef uint16_t sessionidt;
112 typedef uint16_t tunnelidt;
113 typedef uint32_t clockt;
114 typedef uint8_t hasht[16];
115
116 // CLI actions
117 struct cli_session_actions {
118 char action;
119 in_addr_t snoop_ip;
120 uint16_t snoop_port;
121 int throttle_in;
122 int throttle_out;
123 int filter_in;
124 int filter_out;
125 };
126
127 #define CLI_SESS_KILL 0x01
128 #define CLI_SESS_SNOOP 0x02
129 #define CLI_SESS_NOSNOOP 0x04
130 #define CLI_SESS_THROTTLE 0x08
131 #define CLI_SESS_NOTHROTTLE 0x10
132 #define CLI_SESS_FILTER 0x20
133 #define CLI_SESS_NOFILTER 0x40
134
135 struct cli_tunnel_actions {
136 char action;
137 };
138
139 #define CLI_TUN_KILL 0x01
140
141 // dump header: update number if internal format changes
142 #define DUMP_MAGIC "L2TPNS#" VERSION "#"
143
144 // structures
145 typedef struct // route
146 {
147 in_addr_t ip;
148 in_addr_t mask;
149 }
150 routet;
151
152 typedef struct controls // control message
153 {
154 struct controls *next; // next in queue
155 uint16_t length; // length
156 uint8_t buf[MAXCONTROL];
157 }
158 controlt;
159
160 typedef struct
161 {
162 sessionidt next; // next session in linked list
163 sessionidt far; // far end session ID
164 tunnelidt tunnel; // near end tunnel ID
165 in_addr_t ip; // IP of session set by RADIUS response (host byte order).
166 int ip_pool_index; // index to IP pool
167 unsigned long unique_id; // unique session id
168 uint16_t nr; // next receive
169 uint16_t ns; // next send
170 uint32_t magic; // ppp magic number
171 uint32_t cin, cout; // byte counts
172 uint32_t pin, pout; // packet counts
173 uint32_t total_cin; // This counter is never reset while a session is open
174 uint32_t total_cout; // This counter is never reset while a session is open
175 uint32_t id; // session id
176 uint16_t throttle_in; // upstream throttle rate (kbps)
177 uint16_t throttle_out; // downstream throttle rate
178 clockt opened; // when started
179 clockt die; // being closed, when to finally free
180 time_t last_packet; // Last packet from the user (used for idle timeouts)
181 in_addr_t dns1, dns2; // DNS servers
182 routet route[MAXROUTE]; // static routes
183 uint16_t radius; // which radius session is being used (0 for not waiting on authentication)
184 uint16_t mru; // maximum receive unit
185 uint16_t tbf_in; // filter bucket for throttling in from the user.
186 uint16_t tbf_out; // filter bucket for throttling out to the user.
187 uint8_t l2tp_flags; // various bit flags from the ICCN on the l2tp tunnel.
188 uint8_t reserved_old_snoop; // No longer used - remove at some time
189 uint8_t walled_garden; // is this session gardened?
190 uint8_t flags1; // additional flags (currently unused);
191 char random_vector[MAXTEL];
192 int random_vector_length;
193 char user[129]; // user (needed in seesion for radius stop messages) (can we reduce this? --mo)
194 char called[MAXTEL]; // called number
195 char calling[MAXTEL]; // calling number
196 uint32_t tx_connect_speed;
197 uint32_t rx_connect_speed;
198 uint32_t flags; // Various session flags.
199 in_addr_t snoop_ip; // Interception destination IP
200 uint16_t snoop_port; // Interception destination port
201 uint16_t sid; // near end session id.
202 uint8_t filter_in; // input filter index (to ip_filters[N-1]; 0 if none)
203 uint8_t filter_out; // output filter index
204 char reserved[18]; // Space to expand structure without changing HB_VERSION
205 }
206 sessiont;
207
208 #define SF_IPCP_ACKED 1 // Has this session seen an IPCP Ack?
209 #define SF_LCP_ACKED 2 // LCP negotiated
210 #define SF_CCP_ACKED 4 // CCP negotiated
211
212 typedef struct
213 {
214 // byte counters
215 uint32_t cin;
216 uint32_t cout;
217
218 // DoS prevention
219 clockt last_packet_out;
220 uint32_t packets_out;
221 uint32_t packets_dropped;
222 } sessionlocalt;
223
224 #define SESSIONPFC 1 // PFC negotiated flags
225 #define SESSIONACFC 2 // ACFC negotiated flags
226
227 // 168 bytes per tunnel
228 typedef struct
229 {
230 tunnelidt far; // far end tunnel ID
231 in_addr_t ip; // Ip for far end
232 uint16_t port; // port for far end
233 uint16_t window; // Rx window
234 uint16_t nr; // next receive
235 uint16_t ns; // next send
236 int state; // current state (tunnelstate enum)
237 clockt last; // when last control message sent (used for resend timeout)
238 clockt retry; // when to try resenting pending control
239 clockt die; // being closed, when to finally free
240 clockt lastrec; // when the last control message was received
241 char hostname[128]; // tunnel hostname
242 char vendor[128]; // LAC vendor
243 uint8_t try; // number of retrys on a control message
244 uint16_t controlc; // outstaind messages in queue
245 controlt *controls; // oldest message
246 controlt *controle; // newest message
247 }
248 tunnelt;
249
250 // 180 bytes per radius session
251 typedef struct // outstanding RADIUS requests
252 {
253 sessionidt session; // which session this applies to
254 hasht auth; // request authenticator
255 clockt retry; // when to try next
256 char calling[MAXTEL]; // calling number
257 char pass[129]; // password
258 uint8_t id; // ID for PPP response
259 uint8_t try; // which try we are on
260 uint8_t state; // state of radius requests
261 uint8_t chap; // set if CHAP used (is CHAP identifier)
262 }
263 radiust;
264
265 typedef struct
266 {
267 in_addr_t address; // Host byte order..
268 char assigned; // 1 if assigned, 0 if free
269 sessionidt session;
270 clockt last; // last used
271 char user[129]; // user (try to have ip addresses persistent)
272 }
273 ippoolt;
274
275 #ifdef RINGBUFFER
276 struct Tringbuffer
277 {
278 struct {
279 char level;
280 sessionidt session;
281 tunnelidt tunnel;
282 char message[MAX_LOG_LENGTH];
283 } buffer[RINGBUFFER_SIZE];
284 int head;
285 int tail;
286 };
287 #endif
288
289 /*
290 * Possible tunnel states
291 * TUNNELFREE -> TUNNELOPEN -> TUNNELDIE -> TUNNELFREE
292 */
293 enum
294 {
295 TUNNELFREE, // Not in use
296 TUNNELOPEN, // Active tunnel
297 TUNNELDIE, // Currently closing
298 TUNNELOPENING, // Busy opening
299 TUNNELUNDEF, // Undefined
300 };
301
302 enum
303 {
304 RADIUSNULL, // Not in use
305 RADIUSCHAP, // sending CHAP down PPP
306 RADIUSAUTH, // sending auth to RADIUS server
307 RADIUSIPCP, // sending IPCP to end user
308 RADIUSSTART, // sending start accounting to RADIUS server
309 RADIUSSTOP, // sending stop accounting to RADIUS server
310 RADIUSWAIT, // waiting timeout before available, in case delayed replies
311 RADIUSDEAD, // errored while talking to radius server.
312 };
313
314 struct Tstats
315 {
316 time_t start_time;
317 time_t last_reset;
318
319 uint32_t tun_rx_packets;
320 uint32_t tun_tx_packets;
321 uint32_t tun_rx_bytes;
322 uint32_t tun_tx_bytes;
323 uint32_t tun_rx_errors;
324 uint32_t tun_tx_errors;
325 uint32_t tun_rx_dropped;
326
327 uint32_t tunnel_rx_packets;
328 uint32_t tunnel_tx_packets;
329 uint32_t tunnel_rx_bytes;
330 uint32_t tunnel_tx_bytes;
331 uint32_t tunnel_rx_errors;
332 uint32_t tunnel_tx_errors;
333
334 uint32_t tunnel_retries;
335 uint32_t radius_retries;
336
337 uint32_t arp_sent;
338
339 uint32_t packets_snooped;
340
341 uint32_t tunnel_created;
342 uint32_t session_created;
343 uint32_t tunnel_timeout;
344 uint32_t session_timeout;
345 uint32_t radius_timeout;
346 uint32_t radius_overflow;
347 uint32_t tunnel_overflow;
348 uint32_t session_overflow;
349
350 uint32_t ip_allocated;
351 uint32_t ip_freed;
352
353 uint32_t c_forwarded;
354 uint32_t recv_forward;
355
356 uint32_t select_called;
357 uint32_t multi_read_used;
358 uint32_t multi_read_exceeded;
359
360 #ifdef STATISTICS
361 uint32_t call_processtun;
362 uint32_t call_processipout;
363 uint32_t call_processudp;
364 uint32_t call_sessionbyip;
365 uint32_t call_sessionbyuser;
366 uint32_t call_sendarp;
367 uint32_t call_sendipcp;
368 uint32_t call_tunnelsend;
369 uint32_t call_sessionkill;
370 uint32_t call_sessionshutdown;
371 uint32_t call_tunnelkill;
372 uint32_t call_tunnelshutdown;
373 uint32_t call_assign_ip_address;
374 uint32_t call_free_ip_address;
375 uint32_t call_dump_acct_info;
376 uint32_t call_sessionsetup;
377 uint32_t call_processpap;
378 uint32_t call_processchap;
379 uint32_t call_processlcp;
380 uint32_t call_processipcp;
381 uint32_t call_processipin;
382 uint32_t call_processccp;
383 uint32_t call_sendchap;
384 uint32_t call_processrad;
385 uint32_t call_radiussend;
386 uint32_t call_radiusretry;
387 #endif
388 };
389
390 #ifdef STATISTICS
391
392 #ifdef STAT_CALLS
393 #define CSTAT(x) STAT(x)
394 #else
395 #define CSTAT(x)
396 #endif
397
398 #define STAT(x) (_statistics->x++)
399 #define INC_STAT(x,y) (_statistics->x += (y))
400 #define GET_STAT(x) (_statistics->x)
401 #define SET_STAT(x, y) (_statistics->x = (y))
402 #else
403 #define CSTAT(x)
404 #define STAT(x)
405 #define INC_STAT(x,y)
406 #define GET_STAT(x) 0
407 #define SET_STAT(x, y)
408 #endif
409
410 typedef struct
411 {
412 int debug; // debugging level
413 time_t start_time; // time when l2tpns was started
414 char bandwidth[256]; // current bandwidth
415 char pid_file[256]; // file to write PID to on startup
416 int wrote_pid;
417 clockt current_time; // 1/10ths of a second since the process started.
418 // means that we can only run a given process
419 // for 13 years without re-starting!
420
421 char config_file[128];
422 int reload_config; // flag to re-read config (set by cli)
423 int multi_read_count; // amount of packets to read per fd in processing loop
424
425 char tundevice[10]; // tun device name
426 char log_filename[128];
427 char l2tpsecret[64];
428
429 char radiussecret[64];
430 int radius_accounting;
431 in_addr_t radiusserver[MAXRADSERVER]; // radius servers
432 uint16_t radiusport[MAXRADSERVER]; // radius base ports
433 uint8_t numradiusservers; // radius server count
434 short num_radfds; // Number of radius filehandles allocated
435
436 in_addr_t default_dns1, default_dns2;
437
438 unsigned long rl_rate; // default throttle rate
439 int num_tbfs; // number of throttle buckets
440
441 int save_state;
442 char accounting_dir[128];
443 in_addr_t bind_address;
444 in_addr_t peer_address;
445 int send_garp; // Set to true to garp for vip address on startup
446
447 int target_uid;
448 int dump_speed;
449 char plugins[64][MAXPLUGINS];
450 char old_plugins[64][MAXPLUGINS];
451
452 int next_tbf; // Next HTB id available to use
453 int scheduler_fifo; // If the system has multiple CPUs, use FIFO scheduling
454 // policy for this process.
455 int lock_pages; // Lock pages into memory.
456 int icmp_rate; // Max number of ICMP unreachable per second to send
457 int max_packets; // DoS prevention: per session limit of packets/0.1s
458
459 in_addr_t cluster_address; // Multicast address of cluster.
460 // Send to this address to have everyone hear.
461 char cluster_interface[64]; // Which interface to listen for multicast on.
462 int cluster_iam_master; // Are we the cluster master???
463 int cluster_iam_uptodate; // Set if we've got a full set of state from the master.
464 in_addr_t cluster_master_address; // The network address of the cluster master.
465 // Zero if i am the cluster master.
466 int cluster_seq_number; // Sequence number of the next heartbeat we'll send out
467 // (or the seq number we're next expecting if we're a slave).
468 int cluster_undefined_sessions; // How many sessions we're yet to receive from the master.
469 int cluster_undefined_tunnels; // How many tunnels we're yet to receive from the master.
470 int cluster_highest_sessionid;
471 int cluster_highest_tunnelid;
472 clockt cluster_last_hb; // Last time we saw a heartbeat from the master.
473 int cluster_num_changes; // Number of changes queued.
474
475 int cluster_hb_interval; // How often to send a heartbeat.
476 int cluster_hb_timeout; // How many missed heartbeats trigger an election.
477 uint64_t cluster_table_version; // # state changes processed by cluster
478
479
480 int cluster_master_min_adv; // Master advertises routes while the number of up to date
481 // slaves is less than this value.
482
483 #ifdef BGP
484 #define BGP_NUM_PEERS 2
485 uint16_t as_number;
486 struct {
487 char name[64];
488 uint16_t as;
489 int keepalive;
490 int hold;
491 } neighbour[BGP_NUM_PEERS];
492 #endif
493 } configt;
494
495 enum config_typet { INT, STRING, UNSIGNED_LONG, SHORT, BOOL, IP, MAC };
496 typedef struct
497 {
498 char *key;
499 int offset;
500 int size;
501 enum config_typet type;
502 } config_descriptt;
503
504 typedef struct
505 {
506 uint8_t op; // operation
507 #define FILTER_PORT_OP_NONE 0 // all ports match
508 #define FILTER_PORT_OP_EQ 1
509 #define FILTER_PORT_OP_NEQ 2
510 #define FILTER_PORT_OP_GT 3
511 #define FILTER_PORT_OP_LT 4
512 #define FILTER_PORT_OP_RANGE 5
513 uint16_t port; // port (host byte order)
514 uint16_t port2; // range
515 } ip_filter_portt;
516
517 typedef struct
518 {
519 int action; // permit/deny
520 #define FILTER_ACTION_DENY 1
521 #define FILTER_ACTION_PERMIT 2
522 uint8_t proto; // protocol: IPPROTO_* (netinet/in.h)
523 in_addr_t src_ip; // source ip (network byte order)
524 in_addr_t src_wild;
525 ip_filter_portt src_ports;
526 in_addr_t dst_ip; // dest ip
527 in_addr_t dst_wild;
528 ip_filter_portt dst_ports;
529 uint8_t frag; // apply to non-initial fragments
530 uint8_t tcp_flag_op; // match type: any, all, established
531 #define FILTER_FLAG_OP_ANY 1
532 #define FILTER_FLAG_OP_ALL 2
533 #define FILTER_FLAG_OP_EST 3
534 uint8_t tcp_sflags; // flags set
535 uint8_t tcp_cflags; // flags clear
536 uint32_t counter; // match count
537 } ip_filter_rulet;
538
539 #define TCP_FLAG_FIN 0x01
540 #define TCP_FLAG_SYN 0x02
541 #define TCP_FLAG_RST 0x04
542 #define TCP_FLAG_PSH 0x08
543 #define TCP_FLAG_ACK 0x10
544 #define TCP_FLAG_URG 0x20
545
546 #define MAXFILTER 32
547 #define MAXFILTER_RULES 32
548 typedef struct
549 {
550 char name[32]; // ACL name
551 int extended; // type: 0 = standard, 1 = extended
552 ip_filter_rulet rules[MAXFILTER_RULES];
553 int used; // session ref count
554 } ip_filtert;
555
556 // arp.c
557 void sendarp(int ifr_idx, const unsigned char* mac, in_addr_t ip);
558
559
560 // ppp.c
561 void processpap(tunnelidt t, sessionidt s, uint8_t *p, uint16_t l);
562 void processchap(tunnelidt t, sessionidt s, uint8_t *p, uint16_t l);
563 void processlcp(tunnelidt t, sessionidt s, uint8_t *p, uint16_t l);
564 void processipcp(tunnelidt t, sessionidt s, uint8_t *p, uint16_t l);
565 void processipin(tunnelidt t, sessionidt s, uint8_t *p, uint16_t l);
566 void processccp(tunnelidt t, sessionidt s, uint8_t *p, uint16_t l);
567 void sendchap(tunnelidt t, sessionidt s);
568 uint8_t *makeppp(uint8_t *b, int size, uint8_t *p, int l, tunnelidt t, sessionidt s, uint16_t mtype);
569 void initlcp(tunnelidt t, sessionidt s);
570 void send_ipin(sessionidt s, uint8_t *buf, int len);
571
572
573 // radius.c
574 void initrad(void);
575 void radiussend(uint16_t r, uint8_t state);
576 void processrad(uint8_t *buf, int len, char socket_index);
577 void radiusretry(uint16_t r);
578 uint16_t radiusnew(sessionidt s);
579 void radiusclear(uint16_t r, sessionidt s);
580
581
582 // l2tpns.c
583 clockt backoff(uint8_t try);
584 sessionidt sessionbyip(in_addr_t ip);
585 sessionidt sessionbyuser(char *username);
586 void sessionkill(sessionidt s, char *reason);
587 void sessionshutdown(sessionidt s, char *reason);
588 void send_garp(in_addr_t ip);
589 void tunnelsend(uint8_t *buf, uint16_t l, tunnelidt t);
590 void sendipcp(tunnelidt t, sessionidt s);
591 void processudp(uint8_t *buf, int len, struct sockaddr_in *addr);
592 void snoop_send_packet(char *packet, uint16_t size, in_addr_t destination, uint16_t port);
593 int ip_filter(uint8_t *buf, int len, uint8_t filter);
594 int cmd_show_ipcache(struct cli_def *cli, char *command, char **argv, int argc);
595 int cmd_show_hist_idle(struct cli_def *cli, char *command, char **argv, int argc);
596 int cmd_show_hist_open(struct cli_def *cli, char *command, char **argv, int argc);
597
598 #undef LOG
599 #undef LOG_HEX
600 #define LOG(D, s, t, f, ...) ({ if (D <= config->debug) _log(D, s, t, f, ## __VA_ARGS__); })
601 #define LOG_HEX(D, t, d, s) ({ if (D <= config->debug) _log_hex(D, t, d, s); })
602
603 void _log(int level, sessionidt s, tunnelidt t, const char *format, ...) __attribute__((format (printf, 4, 5)));
604 void _log_hex(int level, const char *title, const char *data, int maxsize);
605
606 int sessionsetup(tunnelidt t, sessionidt s);
607 int run_plugins(int plugin_type, void *data);
608 void rebuild_address_pool(void);
609 void throttle_session(sessionidt s, int rate_in, int rate_out);
610 int load_session(sessionidt, sessiont *);
611 void become_master(void); // We're the master; kick off any required master initializations.
612
613
614 // cli.c
615 void init_cli(char *hostname);
616 void cli_do_file(FILE *fh);
617 void cli_do(int sockfd);
618 int cli_arg_help(struct cli_def *cli, int cr_ok, char *entry, ...);
619
620
621 // icmp.c
622 void host_unreachable(in_addr_t destination, uint16_t id, in_addr_t source, char *packet, int packet_len);
623
624
625 extern tunnelt *tunnel;
626 extern sessiont *session;
627 extern sessionlocalt *sess_local;
628 extern ippoolt *ip_address_pool;
629 #define sessionfree (session[0].next)
630
631 #define log_backtrace(count, max) \
632 if (count++ < max) { \
633 void *array[20]; \
634 char **strings; \
635 int size, i; \
636 LOG(0, 0, t, "Backtrace follows"); \
637 size = backtrace(array, 10); \
638 strings = backtrace_symbols(array, size); \
639 if (strings) for (i = 0; i < size; i++) \
640 { \
641 LOG(0, 0, t, "%s\n", strings[i]); \
642 } \
643 free(strings); \
644 }
645
646
647 extern configt *config;
648 extern time_t basetime; // Time when this process started.
649 extern time_t time_now; // Seconds since EPOCH.
650 extern char main_quit;
651 extern uint32_t last_id;
652 extern struct Tstats *_statistics;
653 extern in_addr_t my_address;
654 extern int tun_write(uint8_t *data, int size);
655 extern int clifd;
656
657
658 #define TIME (config->current_time)
659
660 // macros for handling help in cli commands
661 #define CLI_HELP_REQUESTED (argc > 0 && argv[argc-1][strlen(argv[argc-1])-1] == '?')
662 #define CLI_HELP_NO_ARGS (argc > 1 || argv[0][1]) ? CLI_OK : cli_arg_help(cli, 1, NULL)
663
664 // CVS identifiers (for "show version file")
665 extern char const *cvs_id_arp;
666 extern char const *cvs_id_cli;
667 extern char const *cvs_id_cluster;
668 extern char const *cvs_id_constants;
669 extern char const *cvs_id_control;
670 extern char const *cvs_id_icmp;
671 extern char const *cvs_id_l2tpns;
672 extern char const *cvs_id_ll;
673 extern char const *cvs_id_md5;
674 extern char const *cvs_id_ppp;
675 extern char const *cvs_id_radius;
676 extern char const *cvs_id_tbf;
677 extern char const *cvs_id_util;
678
679 #endif /* __L2TPNS_H__ */