sap.h revision 11820
111820Sjulian/*
211820Sjulian * Copyright (c) 1995 John Hay.  All rights reserved.
311820Sjulian *
411820Sjulian * Redistribution and use in source and binary forms, with or without
511820Sjulian * modification, are permitted provided that the following conditions
611820Sjulian * are met:
711820Sjulian * 1. Redistributions of source code must retain the above copyright
811820Sjulian *    notice, this list of conditions and the following disclaimer.
911820Sjulian * 2. Redistributions in binary form must reproduce the above copyright
1011820Sjulian *    notice, this list of conditions and the following disclaimer in the
1111820Sjulian *    documentation and/or other materials provided with the distribution.
1211820Sjulian * 3. All advertising materials mentioning features or use of this software
1311820Sjulian *    must display the following acknowledgement:
1411820Sjulian *	This product includes software developed by John Hay.
1511820Sjulian * 4. Neither the name of the author nor the names of any co-contributors
1611820Sjulian *    may be used to endorse or promote products derived from this software
1711820Sjulian *    without specific prior written permission.
1811820Sjulian *
1911820Sjulian * THIS SOFTWARE IS PROVIDED BY John Hay AND CONTRIBUTORS ``AS IS'' AND
2011820Sjulian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2111820Sjulian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2211820Sjulian * ARE DISCLAIMED.  IN NO EVENT SHALL John Hay OR CONTRIBUTORS BE LIABLE
2311820Sjulian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2411820Sjulian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2511820Sjulian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2611820Sjulian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2711820Sjulian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2811820Sjulian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2911820Sjulian * SUCH DAMAGE.
3011820Sjulian *
3111820Sjulian * $Id: sap.h,v 1.5 1995/10/11 18:57:26 jhay Exp $
3211820Sjulian */
3311820Sjulian#ifndef _SAP_H_
3411820Sjulian#define _SAP_H_
3511820Sjulian
3611820Sjulian#define SAP_REQ			1
3711820Sjulian#define SAP_RESP		2
3811820Sjulian#define SAP_REQ_NEAR		3
3911820Sjulian#define SAP_RESP_NEAR		4
4011820Sjulian
4111820Sjulian#define SAPCMD_MAX		5
4211820Sjulian#ifdef SAPCMDS
4311820Sjulianchar *sapcmds[SAPCMD_MAX] =
4411820Sjulian	{ "#0", "REQUEST", "RESPONSE", "REQ NEAREST", "RESP NEAREST"};
4511820Sjulian#endif
4611820Sjulian
4711820Sjulian#define SAP_WILDCARD		0xFFFF
4811820Sjulian#define SERVNAMELEN		48
4911820Sjuliantypedef struct sap_info {
5011820Sjulian	u_short ServType;
5111820Sjulian	char    ServName[SERVNAMELEN];
5211820Sjulian	struct ipx_addr ipx;
5311820Sjulian	u_short hops;
5411820Sjulian	}sap_info;
5511820Sjulian
5611820Sjuliantypedef struct sap_packet {
5711820Sjulian	u_short sap_cmd;
5811820Sjulian	sap_info sap[0]; /* Variable length. */
5911820Sjulian	}sap_packet;
6011820Sjulian
6111820Sjuliantypedef struct sap_entry {
6211820Sjulian	struct sap_entry *forw;
6311820Sjulian	struct sap_entry *back;
6411820Sjulian	struct sap_entry *clone;
6511820Sjulian	struct interface *ifp;
6611820Sjulian	struct sap_info   sap;
6711820Sjulian	struct sockaddr   source;
6811820Sjulian	int hash;
6911820Sjulian	int state;
7011820Sjulian	int timer;
7111820Sjulian	int metric;
7211820Sjulian	}sap_entry;
7311820Sjulian
7411820Sjulian#define SAPHASHSIZ		32		/* Should be a power of 2 */
7511820Sjulian#define SAPHASHMASK		(SAPHASHSIZ-1)
7611820Sjuliantypedef struct sap_hash {
7711820Sjulian	struct sap_entry *forw;
7811820Sjulian	struct sap_entry *back;
7911820Sjulian	}sap_hash;
8011820Sjulian
8111820Sjulianextern sap_hash sap_head[SAPHASHSIZ];
8211820Sjulian
8311820Sjulianextern struct   sap_packet *sap_msg;
8411820Sjulian
8511820Sjulianvoid sapinit(void);
8611820Sjulianvoid sap_input(struct sockaddr *from, int size);
8711820Sjulianvoid sapsndmsg(struct sockaddr *dst, int flags, struct interface *ifp);
8811820Sjulianvoid sap_supply_toall(void);
8911820Sjulianvoid sap_supply(struct sockaddr *dst,
9011820Sjulian                int flags,
9111820Sjulian		struct interface *ifp,
9211820Sjulian		int ServType);
9311820Sjulian
9411820Sjulianstruct sap_entry *sap_lookup(u_short ServType, char *ServName);
9511820Sjulianstruct sap_entry *sap_nearestserver(ushort ServType, struct interface *ifp);
9611820Sjulianvoid sap_add(struct sap_info *si, struct sockaddr *from);
9711820Sjulianvoid sap_change(struct sap_entry *sap,
9811820Sjulian                struct sap_info *si,
9911820Sjulian		struct sockaddr *from);
10011820Sjulianvoid sap_add_clone(struct sap_entry *sap,
10111820Sjulian                   struct sap_info *clone,
10211820Sjulian		   struct sockaddr *from);
10311820Sjulianvoid sap_delete(struct sap_entry *sap);
10411820Sjulian
10511820Sjulian#endif /*_SAP_H_*/
10611820Sjulian
107