MFC r1.6 r1.30 r1.28 (HEAD):
[dragonfly.git] / usr.sbin / IPXrouted / sap.h
blobc38c0b7a3dc620b413d51f0eeed8442400343c74
1 /*
2 * Copyright (c) 1995 John Hay. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * 3. All advertising materials mentioning features or use of this software
13 * must display the following acknowledgement:
14 * This product includes software developed by John Hay.
15 * 4. Neither the name of the author nor the names of any co-contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY John Hay AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL John Hay OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
31 * $FreeBSD: src/usr.sbin/IPXrouted/sap.h,v 1.7 1999/08/28 01:15:03 peter Exp $
32 * $DragonFly: src/usr.sbin/IPXrouted/sap.h,v 1.2 2003/06/17 04:29:52 dillon Exp $
34 #ifndef _SAP_H_
35 #define _SAP_H_
37 #define SAP_REQ 1
38 #define SAP_RESP 2
39 #define SAP_REQ_NEAR 3
40 #define SAP_RESP_NEAR 4
42 #define SAPCMD_MAX 5
43 #ifdef SAPCMDS
44 char *sapcmds[SAPCMD_MAX] =
45 { "#0", "REQUEST", "RESPONSE", "REQ NEAREST", "RESP NEAREST"};
46 #endif
48 #define MAXSAPENTRIES 7
49 #define SAP_WILDCARD 0xFFFF
50 #define SERVNAMELEN 48
51 typedef struct sap_info {
52 u_short ServType;
53 char ServName[SERVNAMELEN];
54 struct ipx_addr ipx;
55 u_short hops;
56 }sap_info;
58 typedef struct sap_packet {
59 u_short sap_cmd;
60 sap_info sap[0]; /* Variable length. */
61 }sap_packet;
63 typedef struct sap_entry {
64 struct sap_entry *forw;
65 struct sap_entry *back;
66 struct sap_entry *clone;
67 struct interface *ifp;
68 struct sap_info sap;
69 struct sockaddr source;
70 int hash;
71 int state;
72 int timer;
73 }sap_entry;
75 #define SAPHASHSIZ 256 /* Should be a power of 2 */
76 #define SAPHASHMASK (SAPHASHSIZ-1)
77 typedef struct sap_hash {
78 struct sap_entry *forw;
79 struct sap_entry *back;
80 }sap_hash;
82 extern sap_hash sap_head[SAPHASHSIZ];
84 extern struct sap_packet *sap_msg;
86 void sapinit(void);
87 void sap_input(struct sockaddr *from, int size);
88 void sapsndmsg(struct sockaddr *dst, int flags, struct interface *ifp,
89 int changesonly);
90 void sap_supply_toall(int changesonly);
91 void sap_supply(struct sockaddr *dst,
92 int flags,
93 struct interface *ifp,
94 int ServType,
95 int changesonly);
97 struct sap_entry *sap_lookup(u_short ServType, char *ServName);
98 struct sap_entry *sap_nearestserver(ushort ServType, struct interface *ifp);
99 void sap_add(struct sap_info *si, struct sockaddr *from);
100 void sap_change(struct sap_entry *sap,
101 struct sap_info *si,
102 struct sockaddr *from);
103 void sap_add_clone(struct sap_entry *sap,
104 struct sap_info *clone,
105 struct sockaddr *from);
106 void sap_delete(struct sap_entry *sap);
108 #endif /*_SAP_H_*/