fdff57ff843fe6d24fde4489fe855f1427b1172e
[games.git] / usr.sbin / atm / atmarpd / atmarp_var.h
1 /*
2  *
3  * ===================================
4  * HARP  |  Host ATM Research Platform
5  * ===================================
6  *
7  *
8  * This Host ATM Research Platform ("HARP") file (the "Software") is
9  * made available by Network Computing Services, Inc. ("NetworkCS")
10  * "AS IS".  NetworkCS does not provide maintenance, improvements or
11  * support of any kind.
12  *
13  * NETWORKCS MAKES NO WARRANTIES OR REPRESENTATIONS, EXPRESS OR IMPLIED,
14  * INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
15  * AND FITNESS FOR A PARTICULAR PURPOSE, AS TO ANY ELEMENT OF THE
16  * SOFTWARE OR ANY SUPPORT PROVIDED IN CONNECTION WITH THIS SOFTWARE.
17  * In no event shall NetworkCS be responsible for any damages, including
18  * but not limited to consequential damages, arising from or relating to
19  * any use of the Software or related support.
20  *
21  * Copyright 1994-1998 Network Computing Services, Inc.
22  *
23  * Copies of this Software may be made, however, the above copyright
24  * notice must be reproduced on all copies.
25  *
26  *      @(#) $FreeBSD: src/usr.sbin/atm/atmarpd/atmarp_var.h,v 1.3 1999/08/28 01:15:31 peter Exp $
27  *      @(#) $DragonFly: src/usr.sbin/atm/atmarpd/atmarp_var.h,v 1.3 2003/11/03 19:31:35 eirikn Exp $
28  *
29  */
30
31 /*
32  * Server Cache Synchronization Protocol (SCSP) Support
33  * ----------------------------------------------------
34  *
35  * SCSP-ATMARP server interface: control blocks
36  *
37  */
38
39 #ifndef _ATMARP_ATMARP_VAR_H
40 #define _ATMARP_ATMARP_VAR_H
41
42 #ifndef TRUE
43 #define TRUE    1
44 #endif
45
46 #ifndef FALSE
47 #define FALSE   0
48 #endif
49
50 /*
51  * Operational constants
52  */
53 #define ATMARP_DIR                      "/tmp"
54 #define ATMARP_SOCK_PREFIX              "AA_"
55 #define ATMARP_CACHE_INTERVAL           50
56 #define ATMARP_PERM_INTERVAL            600
57 #define ATMARP_KEEPALIVE_INTERVAL       5
58
59
60 /*
61  * Macros for manipulating ATMARP tables and entries
62  */
63 #define ATMARP_HASHSIZ          19      /* Hash table size */
64
65 #define ATMARP_HASH(ip) ((u_long)(ip) % ATMARP_HASHSIZ)
66
67 #define ATMARP_ADD(ai, aa)                                      \
68 {                                                               \
69         Atmarp  **h;                                            \
70         h = &ai->ai_arptbl[ATMARP_HASH((aa)->aa_dstip.s_addr)]; \
71         LINK2TAIL((aa), Atmarp, *h, aa_next);                   \
72 }
73
74 #define ATMARP_DELETE(ai, aa)                                   \
75 {                                                               \
76         Atmarp  **h;                                            \
77         h = &ai->ai_arptbl[ATMARP_HASH((aa)->aa_dstip.s_addr)]; \
78         UNLINK((aa), Atmarp, *h, aa_next);                      \
79 }
80
81 #define ATMARP_LOOKUP(ai, ip, aa)                               \
82 {                                                               \
83         for ((aa) = (ai)->ai_arptbl[ATMARP_HASH(ip)];           \
84                                 (aa); (aa) = (aa)->aa_next) {   \
85                 if ((aa)->aa_dstip.s_addr == (ip))              \
86                         break;                                  \
87         }                                                       \
88 }
89
90
91 /*
92  * Macro to compare originator ID structures
93  */
94 #define OID_EQUAL(id1, id2)                                     \
95         (((id1)->id_len == (id2)->id_len) &&                    \
96         (bcmp((caddr_t)(id1)->id,                               \
97                 (caddr_t)(id2)->id,                             \
98                 (id1)->id_len) == 0))
99
100 #define KEY_EQUAL(key1, key2)                                   \
101         (((key1)->key_len == (key2)->key_len) &&                \
102         (bcmp((caddr_t)(key1)->key,                             \
103                 (caddr_t)(key2)->key,                           \
104                 (key1)->key_len) == 0))
105
106
107 /*
108  * Interface entry for ATMARP SCSP interface daemon
109  */
110 struct atmarp_intf {
111         struct atmarp_intf      *ai_next;       /* Next chained I/F */
112         char            ai_intf[IFNAMSIZ];      /* Network I/F name */
113         struct in_addr  ai_ip_addr;             /* IP address */
114         struct in_addr  ai_subnet_mask;         /* Subnet mask */
115         int             ai_mtu;                 /* IP MTU */
116         Atm_addr        ai_atm_addr;            /* ATM address */
117         Atm_addr        ai_atm_subaddr;         /* ATM subaddress */
118         int             ai_scsp_sock;           /* Socket to SCSP */
119         Harp_timer      ai_keepalive_t;         /* Keepalive timer */
120         char            *ai_scsp_sockname;      /* Socket name */
121         u_char          ai_state;               /* Interface state */
122         u_char          ai_mark;
123         struct atmarp   *ai_arptbl[ATMARP_HASHSIZ];     /* ARP cache */
124 };
125 typedef struct atmarp_intf      Atmarp_intf;
126
127 #define AI_STATE_NULL   0
128 #define AI_STATE_UP     1
129
130
131 /*
132  * Super-LIS control block for ATMARP server daemon
133  */
134 struct atmarp_slis {
135         struct atmarp_slis      *as_next;       /* Next super-LIS */
136         char                    *as_name;       /* Name of super-LIS */
137         int                     as_cnt;         /* LIS count */
138         Atmarp_intf             *as_intfs;      /* List of intfs */
139 };
140 typedef struct atmarp_slis      Atmarp_slis;
141
142
143 /*
144  * ATMARP cache entry format
145  */
146 struct atmarp {
147         struct atmarp   *aa_next;       /* Hash chain link */
148         struct in_addr  aa_dstip;       /* Destination IP addr */
149         Atm_addr        aa_dstatm;      /* Destination ATM addr */
150         Atm_addr        aa_dstatmsub;   /* Destination ATM subaddr */
151         struct scsp_ckey aa_key;        /* SCSP cache key */
152         struct scsp_id  aa_oid;         /* SCSP originator ID */
153         long            aa_seq;         /* SCSP sequence no. */
154         Atmarp_intf     *aa_intf;       /* Interface for entry */
155         u_char          aa_flags;       /* Flags (see below) */
156         u_char          aa_origin;      /* Entry origin */
157         char            aa_mark;        /* Mark */
158 };
159 typedef struct atmarp   Atmarp;
160
161 /*
162  * ATMARP Entry Flags
163  */
164 #define AAF_PERM        0x01    /* Entry is permanent */
165 #define AAF_SERVER      0x02    /* Entry is for the server */
166
167
168 /*
169  * Global variables
170  */
171 extern char             *prog;
172 extern int              atmarp_debug_mode;
173 extern int              atmarp_max_socket;
174 extern Atmarp_intf      *atmarp_intf_head;
175 extern Atmarp_slis      *atmarp_slis_head;
176 extern FILE             *atmarp_log_file;
177
178
179 /*
180  * Function definitions
181  */
182
183 /* atmarp_config.c */
184 extern int      atmarp_cfg_netif(char *);
185
186 /* atmarp_log.c */
187 #if __STDC__
188 extern void     atmarp_log(const int, const char *, ...);
189 #else
190 extern void     atmarp_log(int, char *, va_alist);
191 #endif
192 extern void     atmarp_mem_err(char *);
193
194 /* atmarp_scsp.c */
195 extern int      atmarp_scsp_cache(Atmarp_intf *, Scsp_if_msg *);
196 extern int      atmarp_scsp_update(Atmarp *, int);
197 extern int      atmarp_scsp_update_in(Atmarp_intf *,
198                         Scsp_if_msg *);
199 extern int      atmarp_scsp_read(Atmarp_intf *);
200 extern int      atmarp_scsp_out(Atmarp_intf *, char *, int);
201 extern int      atmarp_scsp_connect(Atmarp_intf *);
202 extern void     atmarp_scsp_close(Atmarp_intf *);
203 extern int      atmarp_scsp_disconnect(Atmarp_intf *);
204
205 /* atmarp_subr.c */
206 extern Atmarp_intf       *atmarp_find_intf_sock(int);
207 extern Atmarp_intf       *atmarp_find_intf_name(char *);
208 extern void     atmarp_clear_marks();
209 extern int      atmarp_is_server(Atmarp_intf *);
210 extern int      atmarp_if_ready(Atmarp_intf *);
211 extern Atmarp * atmarp_copy_cache_entry(struct air_arp_rsp *);
212 extern int      atmarp_update_kernel(Atmarp *);
213 extern void     atmarp_get_updated_cache();
214 extern void     atmarp_process_cache_entry(struct air_arp_rsp *);
215 extern void     print_atmarp_intf(FILE *, Atmarp_intf *);
216 extern void     print_atmarp_cache(FILE *, Atmarp *);
217 extern void     dump_atmarp_cache(FILE *, Atmarp_intf *);
218 extern void     atmarp_sigint(int);
219
220 /* atmarp_timer.c */
221 extern void     atmarp_cache_timeout(Harp_timer *);
222 extern void     atmarp_perm_timeout(Harp_timer *);
223 extern void     atmarp_keepalive_timeout(Harp_timer *);
224
225
226 #endif  /* _ATMARP_ATMARP_VAR_H */