summaryrefslogtreecommitdiffstats
path: root/usr.sbin/atm/atmarpd/atmarp_var.h
blob: 708dc63a63b491126419a284a0226284a9078782 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
/*
 *
 * ===================================
 * HARP  |  Host ATM Research Platform
 * ===================================
 *
 *
 * This Host ATM Research Platform ("HARP") file (the "Software") is
 * made available by Network Computing Services, Inc. ("NetworkCS")
 * "AS IS".  NetworkCS does not provide maintenance, improvements or
 * support of any kind.
 *
 * NETWORKCS MAKES NO WARRANTIES OR REPRESENTATIONS, EXPRESS OR IMPLIED,
 * INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE, AS TO ANY ELEMENT OF THE
 * SOFTWARE OR ANY SUPPORT PROVIDED IN CONNECTION WITH THIS SOFTWARE.
 * In no event shall NetworkCS be responsible for any damages, including
 * but not limited to consequential damages, arising from or relating to
 * any use of the Software or related support.
 *
 * Copyright 1994-1998 Network Computing Services, Inc.
 *
 * Copies of this Software may be made, however, the above copyright
 * notice must be reproduced on all copies.
 *
 *	@(#) $Id: atmarp_var.h,v 1.1 1998/09/15 08:23:15 phk Exp $
 *
 */

/*
 * Server Cache Synchronization Protocol (SCSP) Support
 * ----------------------------------------------------
 *
 * SCSP-ATMARP server interface: control blocks
 *
 */

#ifndef _ATMARP_ATMARP_VAR_H
#define _ATMARP_ATMARP_VAR_H

#ifndef TRUE
#define	TRUE	1
#endif

#ifndef FALSE
#define	FALSE	0
#endif

/*
 * Operational constants
 */
#define	ATMARP_DIR			"/tmp"
#define	ATMARP_SOCK_PREFIX		"AA_"
#define	ATMARP_CACHE_INTERVAL		50
#define	ATMARP_PERM_INTERVAL		600
#define	ATMARP_KEEPALIVE_INTERVAL	5


/*
 * Macros for manipulating ATMARP tables and entries
 */
#define	ATMARP_HASHSIZ		19	/* Hash table size */

#define	ATMARP_HASH(ip)	((u_long)(ip) % ATMARP_HASHSIZ)

#define ATMARP_ADD(ai, aa)					\
{								\
	Atmarp	**h;						\
	h = &ai->ai_arptbl[ATMARP_HASH((aa)->aa_dstip.s_addr)];	\
	LINK2TAIL((aa), Atmarp, *h, aa_next);			\
}

#define ATMARP_DELETE(ai, aa)					\
{								\
	Atmarp	**h;						\
	h = &ai->ai_arptbl[ATMARP_HASH((aa)->aa_dstip.s_addr)];	\
	UNLINK((aa), Atmarp, *h, aa_next);			\
}

#define ATMARP_LOOKUP(ai, ip, aa)				\
{								\
	for ((aa) = (ai)->ai_arptbl[ATMARP_HASH(ip)];		\
				(aa); (aa) = (aa)->aa_next) {	\
		if ((aa)->aa_dstip.s_addr == (ip))		\
			break;					\
	}							\
}


/*
 * Macro to compare originator ID structures
 */
#define	OID_EQUAL(id1, id2)					\
	(((id1)->id_len == (id2)->id_len) &&			\
	(bcmp((caddr_t)(id1)->id,				\
	 	(caddr_t)(id2)->id,				\
		(id1)->id_len) == 0))

#define	KEY_EQUAL(key1, key2)					\
	(((key1)->key_len == (key2)->key_len) &&		\
	(bcmp((caddr_t)(key1)->key,				\
	 	(caddr_t)(key2)->key,				\
		(key1)->key_len) == 0))


/*
 * Interface entry for ATMARP SCSP interface daemon
 */
struct atmarp_intf {
	struct atmarp_intf	*ai_next;	/* Next chained I/F */
	char		ai_intf[IFNAMSIZ];	/* Network I/F name */
	struct in_addr	ai_ip_addr;		/* IP address */
	struct in_addr 	ai_subnet_mask;        	/* Subnet mask */
	int		ai_mtu;			/* IP MTU */
	Atm_addr	ai_atm_addr;		/* ATM address */
	Atm_addr	ai_atm_subaddr;		/* ATM subaddress */
	int		ai_scsp_sock;		/* Socket to SCSP */
	Harp_timer	ai_keepalive_t;		/* Keepalive timer */
	char		*ai_scsp_sockname;	/* Socket name */
	u_char		ai_state;		/* Interface state */
	u_char		ai_mark;
	struct atmarp	*ai_arptbl[ATMARP_HASHSIZ];	/* ARP cache */
};
typedef	struct atmarp_intf	Atmarp_intf;

#define	AI_STATE_NULL	0
#define	AI_STATE_UP	1


/*
 * Super-LIS control block for ATMARP server daemon
 */
struct atmarp_slis {
	struct atmarp_slis	*as_next;	/* Next super-LIS */
	char			*as_name;	/* Name of super-LIS */
	int			as_cnt;		/* LIS count */
	Atmarp_intf		*as_intfs;	/* List of intfs */
};
typedef	struct atmarp_slis	Atmarp_slis;


/*
 * ATMARP cache entry format
 */
struct atmarp {
	struct atmarp	*aa_next;	/* Hash chain link */
	struct in_addr	aa_dstip;	/* Destination IP addr */
	Atm_addr	aa_dstatm;	/* Destination ATM addr */
	Atm_addr	aa_dstatmsub;	/* Destination ATM subaddr */
	struct scsp_ckey aa_key;	/* SCSP cache key */
	struct scsp_id	aa_oid;		/* SCSP originator ID */
	long		aa_seq;		/* SCSP sequence no. */
	Atmarp_intf	*aa_intf;	/* Interface for entry */
	u_char		aa_flags;	/* Flags (see below) */
	u_char		aa_origin;	/* Entry origin */
	char		aa_mark;	/* Mark */
};
typedef	struct atmarp	Atmarp;

/*
 * ATMARP Entry Flags
 */
#define	AAF_PERM	0x01	/* Entry is permanent */
#define	AAF_SERVER	0x02	/* Entry is for the server */


/*
 * Global variables
 */
extern char		*prog;
extern int		atmarp_debug_mode;
extern int		atmarp_max_socket;
extern Atmarp_intf	*atmarp_intf_head;
extern Atmarp_slis	*atmarp_slis_head;
extern FILE		*atmarp_log_file;


/*
 * Function definitions
 */

/* atmarp_config.c */
extern int	atmarp_cfg_netif __P((char *));

/* atmarp_log.c */
#if __STDC__
extern void	atmarp_log __P((const int, const char *, ...));
#else
extern void	atmarp_log __P((int, char *, va_alist));
#endif
extern void	atmarp_mem_err __P((char *));

/* atmarp_scsp.c */
extern int	atmarp_scsp_cache __P((Atmarp_intf *, Scsp_if_msg *));
extern int	atmarp_scsp_update __P((Atmarp *, int));
extern int	atmarp_scsp_update_in __P((Atmarp_intf *,
			Scsp_if_msg *));
extern int	atmarp_scsp_read __P((Atmarp_intf *));
extern int	atmarp_scsp_out __P((Atmarp_intf *, char *, int));
extern int	atmarp_scsp_connect __P((Atmarp_intf *));
extern void	atmarp_scsp_close __P((Atmarp_intf *));
extern int	atmarp_scsp_disconnect __P((Atmarp_intf *));

/* atmarp_subr.c */
extern Atmarp_intf	 *atmarp_find_intf_sock __P((int));
extern Atmarp_intf	 *atmarp_find_intf_name __P((char *));
extern void	atmarp_clear_marks __P(());
extern int	atmarp_is_server __P((Atmarp_intf *));
extern int	atmarp_if_ready __P((Atmarp_intf *));
extern Atmarp *	atmarp_copy_cache_entry __P((struct air_arp_rsp *));
extern int	atmarp_update_kernel __P((Atmarp *));
extern void	atmarp_get_updated_cache __P(());
extern void	atmarp_process_cache_entry __P((struct air_arp_rsp *));
extern void	print_atmarp_intf __P((FILE *, Atmarp_intf *));
extern void	print_atmarp_cache __P((FILE *, Atmarp *));
extern void	dump_atmarp_cache __P((FILE *, Atmarp_intf *));
extern void	atmarp_sigint __P((int));

/* atmarp_timer.c */
extern void	atmarp_cache_timeout __P((Harp_timer *));
extern void	atmarp_perm_timeout __P((Harp_timer *));
extern void	atmarp_keepalive_timeout __P((Harp_timer *));


#endif	/* _ATMARP_ATMARP_VAR_H */
OpenPOWER on IntegriCloud