Initial import from FreeBSD RELENG_4:
[dragonfly.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  *
28  */
29
30 /*
31  * Server Cache Synchronization Protocol (SCSP) Support
32  * ----------------------------------------------------
33  *
34  * SCSP-ATMARP server interface: control blocks
35  *
36  */
37
38 #ifndef _ATMARP_ATMARP_VAR_H
39 #define _ATMARP_ATMARP_VAR_H
40
41 #ifndef TRUE
42 #define TRUE    1
43 #endif
44
45 #ifndef FALSE
46 #define FALSE   0
47 #endif
48
49 /*
50  * Operational constants
51  */
52 #define ATMARP_DIR                      "/tmp"
53 #define ATMARP_SOCK_PREFIX              "AA_"
54 #define ATMARP_CACHE_INTERVAL           50
55 #define ATMARP_PERM_INTERVAL            600
56 #define ATMARP_KEEPALIVE_INTERVAL       5
57
58
59 /*
60  * Macros for manipulating ATMARP tables and entries
61  */
62 #define ATMARP_HASHSIZ          19      /* Hash table size */
63
64 #define ATMARP_HASH(ip) ((u_long)(ip) % ATMARP_HASHSIZ)
65
66 #define ATMARP_ADD(ai, aa)                                      \
67 {                                                               \
68         Atmarp  **h;                                            \
69         h = &ai->ai_arptbl[ATMARP_HASH((aa)->aa_dstip.s_addr)]; \
70         LINK2TAIL((aa), Atmarp, *h, aa_next);                   \
71 }
72
73 #define ATMARP_DELETE(ai, aa)                                   \
74 {                                                               \
75         Atmarp  **h;                                            \
76         h = &ai->ai_arptbl[ATMARP_HASH((aa)->aa_dstip.s_addr)]; \
77         UNLINK((aa), Atmarp, *h, aa_next);                      \
78 }
79
80 #define ATMARP_LOOKUP(ai, ip, aa)                               \
81 {                                                               \
82         for ((aa) = (ai)->ai_arptbl[ATMARP_HASH(ip)];           \
83                                 (aa); (aa) = (aa)->aa_next) {   \
84                 if ((aa)->aa_dstip.s_addr == (ip))              \
85                         break;                                  \
86         }                                                       \
87 }
88
89
90 /*
91  * Macro to compare originator ID structures
92  */
93 #define OID_EQUAL(id1, id2)                                     \
94         (((id1)->id_len == (id2)->id_len) &&                    \
95         (bcmp((caddr_t)(id1)->id,                               \
96                 (caddr_t)(id2)->id,                             \
97                 (id1)->id_len) == 0))
98
99 #define KEY_EQUAL(key1, key2)                                   \
100         (((key1)->key_len == (key2)->key_len) &&                \
101         (bcmp((caddr_t)(key1)->key,                             \
102                 (caddr_t)(key2)->key,                           \
103                 (key1)->key_len) == 0))
104
105
106 /*
107  * Interface entry for ATMARP SCSP interface daemon
108  */
109 struct atmarp_intf {
110         struct atmarp_intf      *ai_next;       /* Next chained I/F */
111         char            ai_intf[IFNAMSIZ];      /* Network I/F name */
112         struct in_addr  ai_ip_addr;             /* IP address */
113         struct in_addr  ai_subnet_mask;         /* Subnet mask */
114         int             ai_mtu;                 /* IP MTU */
115         Atm_addr        ai_atm_addr;            /* ATM address */
116         Atm_addr        ai_atm_subaddr;         /* ATM subaddress */
117         int             ai_scsp_sock;           /* Socket to SCSP */
118         Harp_timer      ai_keepalive_t;         /* Keepalive timer */
119         char            *ai_scsp_sockname;      /* Socket name */
120         u_char          ai_state;               /* Interface state */
121         u_char          ai_mark;
122         struct atmarp   *ai_arptbl[ATMARP_HASHSIZ];     /* ARP cache */
123 };
124 typedef struct atmarp_intf      Atmarp_intf;
125
126 #define AI_STATE_NULL   0
127 #define AI_STATE_UP     1
128
129
130 /*
131  * Super-LIS control block for ATMARP server daemon
132  */
133 struct atmarp_slis {
134         struct atmarp_slis      *as_next;       /* Next super-LIS */
135         char                    *as_name;       /* Name of super-LIS */
136         int                     as_cnt;         /* LIS count */
137         Atmarp_intf             *as_intfs;      /* List of intfs */
138 };
139 typedef struct atmarp_slis      Atmarp_slis;
140
141
142 /*
143  * ATMARP cache entry format
144  */
145 struct atmarp {
146         struct atmarp   *aa_next;       /* Hash chain link */
147         struct in_addr  aa_dstip;       /* Destination IP addr */
148         Atm_addr        aa_dstatm;      /* Destination ATM addr */
149         Atm_addr        aa_dstatmsub;   /* Destination ATM subaddr */
150         struct scsp_ckey aa_key;        /* SCSP cache key */
151         struct scsp_id  aa_oid;         /* SCSP originator ID */
152         long            aa_seq;         /* SCSP sequence no. */
153         Atmarp_intf     *aa_intf;       /* Interface for entry */
154         u_char          aa_flags;       /* Flags (see below) */
155         u_char          aa_origin;      /* Entry origin */
156         char            aa_mark;        /* Mark */
157 };
158 typedef struct atmarp   Atmarp;
159
160 /*
161  * ATMARP Entry Flags
162  */
163 #define AAF_PERM        0x01    /* Entry is permanent */
164 #define AAF_SERVER      0x02    /* Entry is for the server */
165
166
167 /*
168  * Global variables
169  */
170 extern char             *prog;
171 extern int              atmarp_debug_mode;
172 extern int              atmarp_max_socket;
173 extern Atmarp_intf      *atmarp_intf_head;
174 extern Atmarp_slis      *atmarp_slis_head;
175 extern FILE             *atmarp_log_file;
176
177
178 /*
179  * Function definitions
180  */
181
182 /* atmarp_config.c */
183 extern int      atmarp_cfg_netif __P((char *));
184
185 /* atmarp_log.c */
186 #if __STDC__
187 extern void     atmarp_log __P((const int, const char *, ...));
188 #else
189 extern void     atmarp_log __P((int, char *, va_alist));
190 #endif
191 extern void     atmarp_mem_err __P((char *));
192
193 /* atmarp_scsp.c */
194 extern int      atmarp_scsp_cache __P((Atmarp_intf *, Scsp_if_msg *));
195 extern int      atmarp_scsp_update __P((Atmarp *, int));
196 extern int      atmarp_scsp_update_in __P((Atmarp_intf *,
197                         Scsp_if_msg *));
198 extern int      atmarp_scsp_read __P((Atmarp_intf *));
199 extern int      atmarp_scsp_out __P((Atmarp_intf *, char *, int));
200 extern int      atmarp_scsp_connect __P((Atmarp_intf *));
201 extern void     atmarp_scsp_close __P((Atmarp_intf *));
202 extern int      atmarp_scsp_disconnect __P((Atmarp_intf *));
203
204 /* atmarp_subr.c */
205 extern Atmarp_intf       *atmarp_find_intf_sock __P((int));
206 extern Atmarp_intf       *atmarp_find_intf_name __P((char *));
207 extern void     atmarp_clear_marks __P(());
208 extern int      atmarp_is_server __P((Atmarp_intf *));
209 extern int      atmarp_if_ready __P((Atmarp_intf *));
210 extern Atmarp * atmarp_copy_cache_entry __P((struct air_arp_rsp *));
211 extern int      atmarp_update_kernel __P((Atmarp *));
212 extern void     atmarp_get_updated_cache __P(());
213 extern void     atmarp_process_cache_entry __P((struct air_arp_rsp *));
214 extern void     print_atmarp_intf __P((FILE *, Atmarp_intf *));
215 extern void     print_atmarp_cache __P((FILE *, Atmarp *));
216 extern void     dump_atmarp_cache __P((FILE *, Atmarp_intf *));
217 extern void     atmarp_sigint __P((int));
218
219 /* atmarp_timer.c */
220 extern void     atmarp_cache_timeout __P((Harp_timer *));
221 extern void     atmarp_perm_timeout __P((Harp_timer *));
222 extern void     atmarp_keepalive_timeout __P((Harp_timer *));
223
224
225 #endif  /* _ATMARP_ATMARP_VAR_H */