1 /* ipip.h general configuration info
3 * $Id: ipip.h,v 1.8 1995/03/19 17:21:06 bdale Exp $
5 * Copyright 1991, Michael Westerhof, Sun Microsystems, Inc.
6 * This software may be freely used, distributed, or modified, providing
7 * this header is not removed.
9 * Added support for Linux - Ron Atkinson N8FOW
12 /* setup the log class to be used when calling syslog - probably LOG_LOCALn */
13 #define IPIP_SYSLOG LOG_LOCAL0
15 /* and the location of the file to log the daemon's pid to */
16 #define PIDLOG "/var/run/ipip.pid"
18 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
19 /* The strtoul routine converts a string to a long unsigned integer.
20 * Some system (SunOS for instance) don't have this routine; they tend
21 * to allow long unsigned implicitly. If your system supports the strtoul
22 * routine, use it! Otherwise, try defining "NO_STRTOUL" below...
23 * you'll get an immediate bomb-out on execution of the resultant binary
24 * if strtol("0xffffffff",NULL,0) != 0xffffffff
31 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
32 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
35 #define strtoul(a,b,c) strtol(a,b,c)
38 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
40 #define DEFAULTCONFIG "/etc/ipip/config"
41 #define DEFAULTROUTE "/etc/ipip/routes"
43 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
45 #define MAX_SIZE 2048 /* largest IP packet we will handle */
46 #define MAX_IFACES 8 /* Total number of interfaces we support */
47 #define MAX_ROUTES 1024 /* Max entries in the route table */
49 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
53 extern char progname[];
54 extern int no_timestamp;
55 extern int stat_interval;
57 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
59 /* The main per-interface data structure */
63 int type; /* The type of interface this is */
64 #define IF_TYPE_NONE 0
65 #define IF_TYPE_IPIP 1
66 #define IF_TYPE_IPUDP 2
67 #define IF_TYPE_SLIP 3
70 int status; /* status flags for this interface */
71 #define IF_STAT_OPEN 1
72 #define IF_STAT_CALL_AGAIN 2 /* call even though no data on the fd! */
73 char *id; /* The name assigned to this interface */
75 char *devname; /* (opt) the device name (/dev/ttya) */
76 int unit; /* IP prot ID, udp port, baud rate, etc */
78 int fd; /* the file descriptor to use */
79 char *private; /* (opt) pointer to private data struct */
81 int (*ifopen)(); /* routine to call to open */
82 int (*ifread)(); /* routine to call to read a packet */
83 int (*ifsend)(); /* routine to call to send a packet */
85 long in; /* count of packets in */
86 long out; /* count of packets out */
87 long out_overruns; /* count of output overrun errors */
88 long martians_in; /* count of bogus packets coming in */
89 long looped_in; /* count of packets looped */
90 long bogus_in; /* count of bogus packets in */
93 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
94 /* Note: the ip addresses and the port numbers are always in net order */
97 int length; /* number of characters in packet */
98 struct interface *from_if; /* the interface this came from */
99 struct interface *to_if; /* the interface this goes to */
100 unsigned long fip; /* ip address from (IP/UDP only) */
101 unsigned long tip; /* ip address to (IP/UDP only) */
102 unsigned short fport; /* port number from (UDP only) */
103 unsigned short tport; /* port number to (UDP only) */
104 unsigned char msg[MAX_SIZE]; /* the packet itself */
107 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
114 unsigned long ipaddr; /* the ip address (network order) */
115 unsigned long mask; /* the bit-mask to apply */
116 struct interface *destif; /* the destination interface */
117 unsigned long destaddr; /* the destination ip address */
118 unsigned short destport; /* the destination udp port */
119 long hits; /* number of times route selected */
122 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
125 extern struct ipip_route rts[MAX_ROUTES];
127 struct route rts[MAX_ROUTES];
131 extern struct interface ifs[MAX_IFACES];
134 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
136 * Our version of the perror routine... just make sure we ID things first!
138 #define PERR(x) {(void)syslog(LOG_ERR,x);}
140 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
142 * Some driver routing error checking macros...
143 * Note that these require that the symbol IF_NAME be defined as the
144 * name of the driver; e.g. #define IF_NAME "slip"
147 #define CK_MNULL(x) \
149 (void)fprintf(stderr,"%sInternal error: NULL message buffer passed to %s driver\n",progname,IF_NAME);\
153 #define CK_IFNULL(x) \
155 (void)fprintf(stderr,"%sInternal error: NULL interface passed to %s driver\n",progname,IF_NAME);\
159 #define CK_IFTYPE(x,y) \
160 if((x)->type != (y)){ \
161 (void)fprintf(stderr,"%sInternal error: incorrect interface type passed to %s driver\n",progname,IF_NAME);\
165 #define CK_IFTYPE2(x,y,z) \
166 if(((x)->type != (y)) && ((x)->type != (z))){ \
167 (void)fprintf(stderr,"%sInternal error: incorrect interface type passed to %s driver\n",progname,IF_NAME);\
171 #define CK_IFOPEN(x) \
172 if(((x)->status & IF_STAT_OPEN)==0){ \
173 (void)fprintf(stderr,"%sInternal error: interface has not been opened (%s driver)\n",progname,IF_NAME);\
177 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */