2 // $Id: l2tpns.h,v 1.100 2005-11-25 02:18:40 bodea Exp $
7 #include <netinet/in.h>
12 #include <netinet/in.h>
13 #include <sys/socket.h>
14 #include <arpa/inet.h>
15 #include <sys/types.h>
18 #define VERSION "2.1.13"
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.
25 #define RADIUS_SHIFT 6
26 #define RADIUS_FDS (1 << RADIUS_SHIFT)
27 #define RADIUS_MASK ((1 << RADIUS_SHIFT) - 1)
28 #define MAXRADIUS (1 << (8 + RADIUS_SHIFT))
30 #define T_UNDEF (0xffff) // A tunnel ID that won't ever be used. Mark session as undefined.
31 #define T_FREE (0) // A tunnel ID that won't ever be used. Mark session as free.
33 #define MAXCONTROL 1000 // max length control message we ever send...
34 #define MINMTU 576 // minimum recommended MTU (rfc1063)
35 #define PPPMTU 1500 // default PPP MTU
36 #define MAXMTU 2600 // arbitrary maximum MTU
37 #define MAXETHER (MAXMTU+18) // max packet we try sending to tun
38 #define MAXTEL 96 // telephone number
39 #define MAXUSER 128 // username
40 #define MAXPASS 128 // password
41 #define MAXPLUGINS 20 // maximum number of plugins to load
42 #define MAXRADSERVER 10 // max radius servers
43 #define MAXROUTE 10 // max static routes per session
44 #define MAXIPPOOL 131072 // max number of ip addresses in pool
45 #define RINGBUFFER_SIZE 10000 // Number of ringbuffer entries to allocate
46 #define MAX_LOG_LENGTH 512 // Maximum size of log message
47 #define ECHO_TIMEOUT 60 // Time between last packet sent and LCP ECHO generation
48 #define IDLE_TIMEOUT 240 // Time between last packet sent and LCP ECHO generation
49 #define BUSY_WAIT_TIME 3000 // 5 minutes in 1/10th seconds to wait for radius to cleanup on shutdown
53 #define ETCDIR "/etc/l2tpns"
57 #define LIBDIR "/usr/lib/l2tpns"
61 #define PLUGINDIR LIBDIR // Plugins
65 #define PLUGINCONF ETCDIR // Plugin config dir
69 #define FLASHDIR ETCDIR
72 #define TUNDEVICE "/dev/net/tun"
73 #define RANDOMDEVICE "/dev/urandom" // default, not as secure as /dev/random but non-blocking
74 #define CONFIGFILE FLASHDIR "/startup-config" // Configuration file
75 #define CLIUSERS FLASHDIR "/users" // CLI Users file
76 #define IPPOOLFILE FLASHDIR "/ip_pool" // Address pool configuration
77 #define ACCT_TIME 3000 // 5 minute accounting interval
78 #define ACCT_SHUT_TIME 600 // 1 minute for counters of shutdown sessions
79 #define L2TPPORT 1701 // L2TP port
80 #define RADPORT 1645 // old radius port...
81 #define DAEPORT 3799 // DAE port
82 #define PKTARP 0x0806 // ARP packet type
83 #define PKTIP 0x0800 // IPv4 packet type
84 #define PKTIPV6 0x86DD // IPv6 packet type
86 #define PPPCHAP 0xC223
88 #define PPPIPCP 0x8021
89 #define PPPIPV6CP 0x8057
92 #define PPPIPV6 0x0057
94 #define MIN_IP_SIZE 0x19
117 AccessChallenge
= 11,
118 DisconnectRequest
= 40,
149 // reset state machine counters
150 #define initialise_restart_count(_s, _fsm) \
151 sess_local[_s]._fsm.conf_sent = sess_local[_s]._fsm.nak_sent = 0
153 // increment ConfReq counter and reset timer
154 #define restart_timer(_s, _fsm) ({ \
155 sess_local[_s]._fsm.conf_sent++; \
156 sess_local[_s]._fsm.restart = \
157 time_now + config->ppp_restart_time; \
160 // stop timer on change to state where timer does not run
161 #define change_state(_s, _fsm, _new) ({ \
162 if (_new != session[_s].ppp._fsm) \
171 sess_local[_s]._fsm.restart = 0; \
172 initialise_restart_count(_s, _fsm); \
174 session[_s].ppp._fsm = _new; \
175 cluster_send_session(_s); \
180 typedef uint16_t sessionidt
;
181 typedef uint16_t tunnelidt
;
182 typedef uint32_t clockt
;
183 typedef uint8_t hasht
[16];
186 struct cli_session_actions
{
196 #define CLI_SESS_KILL 0x01
197 #define CLI_SESS_SNOOP 0x02
198 #define CLI_SESS_NOSNOOP 0x04
199 #define CLI_SESS_THROTTLE 0x08
200 #define CLI_SESS_NOTHROTTLE 0x10
201 #define CLI_SESS_FILTER 0x20
202 #define CLI_SESS_NOFILTER 0x40
204 struct cli_tunnel_actions
{
208 #define CLI_TUN_KILL 0x01
211 typedef struct // route
218 typedef struct controls
// control message
220 struct controls
*next
; // next in queue
221 uint16_t length
; // length
222 uint8_t buf
[MAXCONTROL
];
228 sessionidt next
; // next session in linked list
229 sessionidt far
; // far end session ID
230 tunnelidt tunnel
; // near end tunnel ID
231 uint8_t flags
; // session flags: see SESSION_*
233 uint8_t phase
; // PPP phase
234 uint8_t lcp
:4; // LCP state
235 uint8_t ipcp
:4; // IPCP state
236 uint8_t ipv6cp
:4; // IPV6CP state
237 uint8_t ccp
:4; // CCP state
238 uint8_t pad
; // unused
240 in_addr_t ip
; // IP of session set by RADIUS response (host byte order).
241 int ip_pool_index
; // index to IP pool
242 uint32_t unique_id
; // unique session id
243 uint16_t nr
; // next receive
244 uint16_t ns
; // next send
245 uint32_t magic
; // ppp magic number
246 uint32_t pin
, pout
; // packet counts
247 uint32_t cin
, cout
; // byte counts
248 uint32_t cin_wrap
, cout_wrap
; // byte counter wrap count (RADIUS accounting giagawords)
249 uint32_t cin_delta
, cout_delta
; // byte count changes (for dump_session())
250 uint16_t throttle_in
; // upstream throttle rate (kbps)
251 uint16_t throttle_out
; // downstream throttle rate
252 uint8_t filter_in
; // input filter index (to ip_filters[N-1]; 0 if none)
253 uint8_t filter_out
; // output filter index
254 uint16_t mru
; // maximum receive unit
255 clockt opened
; // when started
256 clockt die
; // being closed, when to finally free
257 time_t last_packet
; // Last packet from the user (used for idle timeouts)
258 in_addr_t dns1
, dns2
; // DNS servers
259 routet route
[MAXROUTE
]; // static routes
260 uint16_t tbf_in
; // filter bucket for throttling in from the user.
261 uint16_t tbf_out
; // filter bucket for throttling out to the user.
262 int random_vector_length
;
263 uint8_t random_vector
[MAXTEL
];
264 char user
[MAXUSER
]; // user (needed in seesion for radius stop messages)
265 char called
[MAXTEL
]; // called number
266 char calling
[MAXTEL
]; // calling number
267 uint32_t tx_connect_speed
;
268 uint32_t rx_connect_speed
;
269 in_addr_t snoop_ip
; // Interception destination IP
270 uint16_t snoop_port
; // Interception destination port
271 uint8_t walled_garden
; // is this session gardened?
272 uint8_t ipv6prefixlen
; // IPv6 route prefix length
273 struct in6_addr ipv6route
; // Static IPv6 route
274 char reserved
[11]; // Space to expand structure without changing HB_VERSION
278 #define AUTHPAP 1 // allow PAP
279 #define AUTHCHAP 2 // allow CHAP
291 // PPP restart timer/counters
296 } lcp
, ipcp
, ipv6cp
, ccp
;
298 // identifier for Protocol-Reject, Code-Reject
301 // authentication to use
308 clockt last_packet_out
;
309 uint32_t packets_out
;
310 uint32_t packets_dropped
;
312 // RADIUS session in use
323 #define SESSION_PFC (1 << 0) // use Protocol-Field-Compression
324 #define SESSION_ACFC (1 << 1) // use Address-and-Control-Field-Compression
325 #define SESSION_STARTED (1 << 2) // RADIUS Start record sent
327 // 168 bytes per tunnel
330 tunnelidt far
; // far end tunnel ID
331 in_addr_t ip
; // Ip for far end
332 uint16_t port
; // port for far end
333 uint16_t window
; // Rx window
334 uint16_t nr
; // next receive
335 uint16_t ns
; // next send
336 int state
; // current state (tunnelstate enum)
337 clockt last
; // when last control message sent (used for resend timeout)
338 clockt retry
; // when to try resending pending control
339 clockt die
; // being closed, when to finally free
340 clockt lastrec
; // when the last control message was received
341 char hostname
[128]; // tunnel hostname
342 char vendor
[128]; // LAC vendor
343 uint8_t try; // number of retrys on a control message
344 uint16_t controlc
; // outstaind messages in queue
345 controlt
*controls
; // oldest message
346 controlt
*controle
; // newest message
350 // 160 bytes per radius session
351 typedef struct // outstanding RADIUS requests
353 sessionidt session
; // which session this applies to
354 hasht auth
; // request authenticator
355 clockt retry
; // when to try next
356 char pass
[129]; // password
357 uint8_t id
; // ID for PPP response
358 uint8_t try; // which try we are on
359 uint8_t state
; // state of radius requests
360 uint8_t chap
; // set if CHAP used (is CHAP identifier)
366 in_addr_t address
; // Host byte order..
367 char assigned
; // 1 if assigned, 0 if free
369 clockt last
; // last used
370 char user
[129]; // user (try to have ip addresses persistent)
381 char message
[MAX_LOG_LENGTH
];
382 } buffer
[RINGBUFFER_SIZE
];
389 * Possible tunnel states
390 * TUNNELFREE -> TUNNELOPEN -> TUNNELDIE -> TUNNELFREE
394 TUNNELFREE
, // Not in use
395 TUNNELOPEN
, // Active tunnel
396 TUNNELDIE
, // Currently closing
397 TUNNELOPENING
, // Busy opening
398 TUNNELUNDEF
, // Undefined
403 RADIUSNULL
, // Not in use
404 RADIUSCHAP
, // sending CHAP down PPP
405 RADIUSAUTH
, // sending auth to RADIUS server
406 RADIUSSTART
, // sending start accounting to RADIUS server
407 RADIUSSTOP
, // sending stop accounting to RADIUS server
408 RADIUSINTERIM
, // sending interim accounting to RADIUS server
409 RADIUSWAIT
, // waiting timeout before available, in case delayed replies
417 uint32_t tun_rx_packets
;
418 uint32_t tun_tx_packets
;
419 uint32_t tun_rx_bytes
;
420 uint32_t tun_tx_bytes
;
421 uint32_t tun_rx_errors
;
422 uint32_t tun_tx_errors
;
423 uint32_t tun_rx_dropped
;
425 uint32_t tunnel_rx_packets
;
426 uint32_t tunnel_tx_packets
;
427 uint32_t tunnel_rx_bytes
;
428 uint32_t tunnel_tx_bytes
;
429 uint32_t tunnel_rx_errors
;
430 uint32_t tunnel_tx_errors
;
432 uint32_t tunnel_retries
;
433 uint32_t radius_retries
;
437 uint32_t packets_snooped
;
439 uint32_t tunnel_created
;
440 uint32_t session_created
;
441 uint32_t tunnel_timeout
;
442 uint32_t session_timeout
;
443 uint32_t radius_timeout
;
444 uint32_t radius_overflow
;
445 uint32_t tunnel_overflow
;
446 uint32_t session_overflow
;
448 uint32_t ip_allocated
;
451 uint32_t c_forwarded
;
452 uint32_t recv_forward
;
454 uint32_t select_called
;
455 uint32_t multi_read_used
;
456 uint32_t multi_read_exceeded
;
459 uint32_t call_processtun
;
460 uint32_t call_processipout
;
461 uint32_t call_processipv6out
;
462 uint32_t call_processudp
;
463 uint32_t call_sessionbyip
;
464 uint32_t call_sessionbyipv6
;
465 uint32_t call_sessionbyuser
;
466 uint32_t call_sendarp
;
467 uint32_t call_sendipcp
;
468 uint32_t call_sendipv6cp
;
469 uint32_t call_processipv6cp
;
470 uint32_t call_tunnelsend
;
471 uint32_t call_sessionkill
;
472 uint32_t call_sessionshutdown
;
473 uint32_t call_tunnelkill
;
474 uint32_t call_tunnelshutdown
;
475 uint32_t call_assign_ip_address
;
476 uint32_t call_free_ip_address
;
477 uint32_t call_dump_acct_info
;
478 uint32_t call_sessionsetup
;
479 uint32_t call_processpap
;
480 uint32_t call_processchap
;
481 uint32_t call_processlcp
;
482 uint32_t call_processipcp
;
483 uint32_t call_processipin
;
484 uint32_t call_processipv6in
;
485 uint32_t call_processccp
;
486 uint32_t call_sendchap
;
487 uint32_t call_processrad
;
488 uint32_t call_radiussend
;
489 uint32_t call_radiusretry
;
490 uint32_t call_random_data
;
497 #define CSTAT(x) STAT(call_ ## x)
502 #define STAT(x) (_statistics->x++)
503 #define INC_STAT(x,y) (_statistics->x += (y))
504 #define GET_STAT(x) (_statistics->x)
505 #define SET_STAT(x, y) (_statistics->x = (y))
509 #define INC_STAT(x,y)
510 #define GET_STAT(x) 0
511 #define SET_STAT(x, y)
516 int debug
; // debugging level
517 time_t start_time
; // time when l2tpns was started
518 char bandwidth
[256]; // current bandwidth
519 char pid_file
[256]; // file to write PID to on startup
521 clockt current_time
; // 1/10ths of a second since the process started.
522 // means that we can only run a given process
523 // for 13 years without re-starting!
525 char config_file
[128];
526 int reload_config
; // flag to re-read config (set by cli)
527 int multi_read_count
; // amount of packets to read per fd in processing loop
529 char tundevice
[10]; // tun device name
530 char log_filename
[128];
532 char l2tp_secret
[64]; // L2TP shared secret
533 int l2tp_mtu
; // MTU of interface used for L2TP
535 char random_device
[256]; // random device path, defaults to RANDOMDEVICE
537 int ppp_restart_time
; // timeout for PPP restart
538 int ppp_max_configure
; // max lcp configure requests to send
539 int ppp_max_failure
; // max lcp configure naks to send
541 char radiussecret
[64];
542 int radius_accounting
;
544 in_addr_t radiusserver
[MAXRADSERVER
]; // radius servers
545 uint16_t radiusport
[MAXRADSERVER
]; // radius base ports
546 uint8_t numradiusservers
; // radius server count
548 uint16_t radius_dae_port
; // local port for radius dae
550 char radius_authtypes_s
[32]; // list of valid authentication types (chap, pap) in order of preference
551 int radius_authtypes
;
552 int radius_authprefer
;
554 int allow_duplicate_users
; // allow multiple logins with the same username
556 in_addr_t default_dns1
, default_dns2
;
558 unsigned long rl_rate
; // default throttle rate
559 int num_tbfs
; // number of throttle buckets
561 char accounting_dir
[128];
562 in_addr_t bind_address
;
563 in_addr_t peer_address
;
564 int send_garp
; // Set to true to garp for vip address on startup
568 char plugins
[64][MAXPLUGINS
];
569 char old_plugins
[64][MAXPLUGINS
];
571 int next_tbf
; // Next HTB id available to use
572 int scheduler_fifo
; // If the system has multiple CPUs, use FIFO scheduling
573 // policy for this process.
574 int lock_pages
; // Lock pages into memory.
575 int icmp_rate
; // Max number of ICMP unreachable per second to send
576 int max_packets
; // DoS prevention: per session limit of packets/0.1s
578 in_addr_t cluster_address
; // Multicast address of cluster.
579 // Send to this address to have everyone hear.
580 char cluster_interface
[64]; // Which interface to listen for multicast on.
581 int cluster_iam_master
; // Are we the cluster master???
582 int cluster_iam_uptodate
; // Set if we've got a full set of state from the master.
583 in_addr_t cluster_master_address
; // The network address of the cluster master.
584 // Zero if i am the cluster master.
585 int cluster_seq_number
; // Sequence number of the next heartbeat we'll send out
586 // (or the seq number we're next expecting if we're a slave).
587 int cluster_undefined_sessions
; // How many sessions we're yet to receive from the master.
588 int cluster_undefined_tunnels
; // How many tunnels we're yet to receive from the master.
589 int cluster_highest_sessionid
;
590 int cluster_highest_tunnelid
;
591 clockt cluster_last_hb
; // Last time we saw a heartbeat from the master.
592 int cluster_last_hb_ver
; // Heartbeat version last seen from master
593 int cluster_num_changes
; // Number of changes queued.
595 int cluster_mcast_ttl
; // TTL for multicast packets
596 int cluster_hb_interval
; // How often to send a heartbeat.
597 int cluster_hb_timeout
; // How many missed heartbeats trigger an election.
598 uint64_t cluster_table_version
; // # state changes processed by cluster
600 struct in6_addr ipv6_prefix
; // Our IPv6 network pool.
603 int cluster_master_min_adv
; // Master advertises routes while the number of up to date
604 // slaves is less than this value.
607 #define BGP_NUM_PEERS 2
614 } neighbour
[BGP_NUM_PEERS
];
618 enum config_typet
{ INT
, STRING
, UNSIGNED_LONG
, SHORT
, BOOL
, IPv4
, IPv6
, MAC
};
624 enum config_typet type
;
629 uint8_t op
; // operation
630 #define FILTER_PORT_OP_NONE 0 // all ports match
631 #define FILTER_PORT_OP_EQ 1
632 #define FILTER_PORT_OP_NEQ 2
633 #define FILTER_PORT_OP_GT 3
634 #define FILTER_PORT_OP_LT 4
635 #define FILTER_PORT_OP_RANGE 5
636 uint16_t port
; // port (host byte order)
637 uint16_t port2
; // range
642 int action
; // permit/deny
643 #define FILTER_ACTION_DENY 1
644 #define FILTER_ACTION_PERMIT 2
645 uint8_t proto
; // protocol: IPPROTO_* (netinet/in.h)
646 in_addr_t src_ip
; // source ip (network byte order)
648 ip_filter_portt src_ports
;
649 in_addr_t dst_ip
; // dest ip
651 ip_filter_portt dst_ports
;
652 uint8_t frag
; // apply to non-initial fragments
653 uint8_t tcp_flag_op
; // match type: any, all, established
654 #define FILTER_FLAG_OP_ANY 1
655 #define FILTER_FLAG_OP_ALL 2
656 #define FILTER_FLAG_OP_EST 3
657 uint8_t tcp_sflags
; // flags set
658 uint8_t tcp_cflags
; // flags clear
659 uint32_t counter
; // match count
662 #define TCP_FLAG_FIN 0x01
663 #define TCP_FLAG_SYN 0x02
664 #define TCP_FLAG_RST 0x04
665 #define TCP_FLAG_PSH 0x08
666 #define TCP_FLAG_ACK 0x10
667 #define TCP_FLAG_URG 0x20
670 #define MAXFILTER_RULES 32
673 char name
[32]; // ACL name
674 int extended
; // type: 0 = standard, 1 = extended
675 ip_filter_rulet rules
[MAXFILTER_RULES
];
676 int used
; // session ref count
680 void sendarp(int ifr_idx
, const unsigned char* mac
, in_addr_t ip
);
684 void processpap(sessionidt s
, tunnelidt t
, uint8_t *p
, uint16_t l
);
685 void processchap(sessionidt s
, tunnelidt t
, uint8_t *p
, uint16_t l
);
686 void lcp_open(sessionidt s
, tunnelidt t
);
687 void processlcp(sessionidt s
, tunnelidt t
, uint8_t *p
, uint16_t l
);
688 void processipcp(sessionidt s
, tunnelidt t
, uint8_t *p
, uint16_t l
);
689 void processipv6cp(sessionidt s
, tunnelidt t
, uint8_t *p
, uint16_t l
);
690 void processipin(sessionidt s
, tunnelidt t
, uint8_t *p
, uint16_t l
);
691 void processipv6in(sessionidt s
, tunnelidt t
, uint8_t *p
, uint16_t l
);
692 void processccp(sessionidt s
, tunnelidt t
, uint8_t *p
, uint16_t l
);
693 void sendchap(sessionidt s
, tunnelidt t
);
694 uint8_t *makeppp(uint8_t *b
, int size
, uint8_t *p
, int l
, sessionidt s
, tunnelidt t
, uint16_t mtype
);
695 void sendlcp(sessionidt s
, tunnelidt t
);
696 void send_ipin(sessionidt s
, uint8_t *buf
, int len
);
697 void sendccp(sessionidt s
, tunnelidt t
);
702 void radiussend(uint16_t r
, uint8_t state
);
703 void processrad(uint8_t *buf
, int len
, char socket_index
);
704 void radiusretry(uint16_t r
);
705 uint16_t radiusnew(sessionidt s
);
706 void radiusclear(uint16_t r
, sessionidt s
);
707 void processdae(uint8_t *buf
, int len
, struct sockaddr_in
*addr
, int alen
);
711 clockt
backoff(uint8_t try);
712 void send_ipv6_ra(sessionidt s
, tunnelidt t
, struct in6_addr
*ip
);
713 void route6set(sessionidt s
, struct in6_addr ip
, int prefixlen
, int add
);
714 sessionidt
sessionbyip(in_addr_t ip
);
715 sessionidt
sessionbyipv6(struct in6_addr ip
);
716 sessionidt
sessionbyuser(char *username
);
717 void increment_counter(uint32_t *counter
, uint32_t *wrap
, uint32_t delta
);
718 void random_data(uint8_t *buf
, int len
);
719 void sessionkill(sessionidt s
, char *reason
);
720 void sessionshutdown(sessionidt s
, char *reason
, int result
, int error
);
721 void filter_session(sessionidt s
, int filter_in
, int filter_out
);
722 void send_garp(in_addr_t ip
);
723 void tunnelsend(uint8_t *buf
, uint16_t l
, tunnelidt t
);
724 int tun_write(uint8_t *data
, int size
);
725 void adjust_tcp_mss(sessionidt s
, tunnelidt t
, uint8_t *buf
, int len
, uint8_t *tcp
);
726 void sendipcp(sessionidt s
, tunnelidt t
);
727 void sendipv6cp(sessionidt s
, tunnelidt t
);
728 void processudp(uint8_t *buf
, int len
, struct sockaddr_in
*addr
);
729 void snoop_send_packet(uint8_t *packet
, uint16_t size
, in_addr_t destination
, uint16_t port
);
730 int find_filter(char const *name
, size_t len
);
731 int ip_filter(uint8_t *buf
, int len
, uint8_t filter
);
732 int cmd_show_ipcache(struct cli_def
*cli
, char *command
, char **argv
, int argc
);
733 int cmd_show_hist_idle(struct cli_def
*cli
, char *command
, char **argv
, int argc
);
734 int cmd_show_hist_open(struct cli_def
*cli
, char *command
, char **argv
, int argc
);
738 #define LOG(D, s, t, f, ...) ({ if (D <= config->debug) _log(D, s, t, f, ## __VA_ARGS__); })
739 #define LOG_HEX(D, t, d, s) ({ if (D <= config->debug) _log_hex(D, t, d, s); })
741 void _log(int level
, sessionidt s
, tunnelidt t
, const char *format
, ...) __attribute__((format (printf
, 4, 5)));
742 void _log_hex(int level
, const char *title
, const uint8_t *data
, int maxsize
);
744 int sessionsetup(sessionidt s
, tunnelidt t
);
745 int run_plugins(int plugin_type
, void *data
);
746 void rebuild_address_pool(void);
747 void throttle_session(sessionidt s
, int rate_in
, int rate_out
);
748 int load_session(sessionidt
, sessiont
*);
749 void become_master(void); // We're the master; kick off any required master initializations.
753 void init_cli(char *hostname
);
754 void cli_do_file(FILE *fh
);
755 void cli_do(int sockfd
);
756 int cli_arg_help(struct cli_def
*cli
, int cr_ok
, char *entry
, ...);
760 void host_unreachable(in_addr_t destination
, uint16_t id
, in_addr_t source
, uint8_t *packet
, int packet_len
);
763 extern tunnelt
*tunnel
;
764 extern sessiont
*session
;
765 extern sessionlocalt
*sess_local
;
766 extern ippoolt
*ip_address_pool
;
767 #define sessionfree (session[0].next)
769 #define log_backtrace(count, max) \
770 if (count++ < max) { \
774 LOG(0, 0, t, "Backtrace follows:\n"); \
775 size = backtrace(array, 10); \
776 strings = backtrace_symbols(array, size); \
777 if (strings) for (i = 0; i < size; i++) \
779 LOG(0, 0, t, " %s\n", strings[i]); \
785 extern configt
*config
;
786 extern time_t basetime
; // Time when this process started.
787 extern time_t time_now
; // Seconds since EPOCH.
788 extern char main_quit
;
789 extern uint32_t last_id
;
790 extern struct Tstats
*_statistics
;
791 extern in_addr_t my_address
;
806 int index
; // for RADIUS, BGP
809 #define TIME (config->current_time)
814 // macros for handling help in cli commands
815 #define CLI_HELP_REQUESTED (argc > 0 && argv[argc-1][strlen(argv[argc-1])-1] == '?')
816 #define CLI_HELP_NO_ARGS (argc > 1 || argv[0][1]) ? CLI_OK : cli_arg_help(cli, 1, NULL)
818 // CVS identifiers (for "show version file")
819 extern char const *cvs_id_arp
;
820 extern char const *cvs_id_cli
;
821 extern char const *cvs_id_cluster
;
822 extern char const *cvs_id_constants
;
823 extern char const *cvs_id_control
;
824 extern char const *cvs_id_icmp
;
825 extern char const *cvs_id_l2tpns
;
826 extern char const *cvs_id_ll
;
827 extern char const *cvs_id_md5
;
828 extern char const *cvs_id_ppp
;
829 extern char const *cvs_id_radius
;
830 extern char const *cvs_id_tbf
;
831 extern char const *cvs_id_util
;
833 #endif /* __L2TPNS_H__ */