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 * Misc stuff...
13 */
14
15#ifndef _MISC_H
16#define _MISC_H
17
18struct tunnel;
19struct buffer
20{
21    int type;
22    void *rstart;
23    void *rend;
24    void *start;
25    int len;
26    int maxlen;
27#if 0
28    unsigned int addr;
29    int port;
30#else
31    struct sockaddr_in peer;
32#endif
33    struct tunnel *tunnel;      /* Who owns this packet, if it's a control */
34    int retries;                /* Again, if a control packet, how many retries? */
35};
36
37struct ppp_opts
38{
39    char option[MAXSTRLEN];
40    struct ppp_opts *next;
41};
42
43#define IPADDY(a) inet_ntoa(*((struct in_addr *)&(a)))
44
45#define DEBUG c ? c->debug || t->debug : t->debug
46
47#ifdef USE_SWAPS_INSTEAD
48#define SWAPS(a) ((((a) & 0xFF) << 8 ) | (((a) >> 8) & 0xFF))
49#ifdef htons
50#undef htons
51#endif
52#ifdef ntohs
53#undef htons
54#endif
55#define htons(a) SWAPS(a)
56#define ntohs(a) SWAPS(a)
57#endif
58
59#define LOG_DEBUG 7
60#define LOG_LOG   6
61#define LOG_WARN  4
62#define LOG_CRIT  2
63
64#define halt() printf("Halted.\n") ; for(;;)
65
66extern char hostname[];
67extern void log (int level, const char *fmt, ...);
68extern struct buffer *new_buf (int);
69extern void udppush_handler (int);
70extern int addfcs (struct buffer *buf);
71extern inline void swaps (void *, int);
72extern void do_packet_dump (struct buffer *);
73extern void status (const char *fmt, ...);
74extern void status_handler (int signal);
75extern int getPtyMaster (char *a, char *b);
76extern void do_control (char *cmd);
77extern void recycle_buf (struct buffer *);
78extern void safe_copy (char *, char *, int);
79extern void opt_destroy (struct ppp_opts *);
80extern struct ppp_opts *add_opt (struct ppp_opts *, char *, ...);
81#endif
82