sap.h revision 11820
150476Speter/*
232227Shelbig * Copyright (c) 1995 John Hay.  All rights reserved.
332227Shelbig *
432227Shelbig * Redistribution and use in source and binary forms, with or without
5174990Sache * modification, are permitted provided that the following conditions
632227Shelbig * are met:
732227Shelbig * 1. Redistributions of source code must retain the above copyright
832227Shelbig *    notice, this list of conditions and the following disclaimer.
932227Shelbig * 2. Redistributions in binary form must reproduce the above copyright
1032227Shelbig *    notice, this list of conditions and the following disclaimer in the
1132227Shelbig *    documentation and/or other materials provided with the distribution.
1232227Shelbig * 3. All advertising materials mentioning features or use of this software
1332227Shelbig *    must display the following acknowledgement:
1432227Shelbig *	This product includes software developed by John Hay.
1532227Shelbig * 4. Neither the name of the author nor the names of any co-contributors
1632227Shelbig *    may be used to endorse or promote products derived from this software
1732227Shelbig *    without specific prior written permission.
1832227Shelbig *
1932227Shelbig * THIS SOFTWARE IS PROVIDED BY John Hay AND CONTRIBUTORS ``AS IS'' AND
20174990Sache * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2132227Shelbig * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2232227Shelbig * ARE DISCLAIMED.  IN NO EVENT SHALL John Hay OR CONTRIBUTORS BE LIABLE
2332227Shelbig * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2432227Shelbig * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2532227Shelbig * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2632227Shelbig * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2732227Shelbig * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2832227Shelbig * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2932227Shelbig * SUCH DAMAGE.
3032227Shelbig *
3132227Shelbig * $Id: sap.h,v 1.5 1995/10/11 18:57:26 jhay Exp $
3232227Shelbig */
3332227Shelbig#ifndef _SAP_H_
3432227Shelbig#define _SAP_H_
3532227Shelbig
3674606Sache#define SAP_REQ			1
3732227Shelbig#define SAP_RESP		2
3832227Shelbig#define SAP_REQ_NEAR		3
3932227Shelbig#define SAP_RESP_NEAR		4
4032227Shelbig
4132227Shelbig#define SAPCMD_MAX		5
4232227Shelbig#ifdef SAPCMDS
4332227Shelbigchar *sapcmds[SAPCMD_MAX] =
4432227Shelbig	{ "#0", "REQUEST", "RESPONSE", "REQ NEAREST", "RESP NEAREST"};
4532227Shelbig#endif
4632227Shelbig
4732227Shelbig#define SAP_WILDCARD		0xFFFF
4832227Shelbig#define SERVNAMELEN		48
4932227Shelbigtypedef struct sap_info {
5032227Shelbig	u_short ServType;
5132227Shelbig	char    ServName[SERVNAMELEN];
5232227Shelbig	struct ipx_addr ipx;
5332227Shelbig	u_short hops;
5432227Shelbig	}sap_info;
5532227Shelbig
5632227Shelbigtypedef struct sap_packet {
5732227Shelbig	u_short sap_cmd;
5832227Shelbig	sap_info sap[0]; /* Variable length. */
5932227Shelbig	}sap_packet;
6032227Shelbig
61104729Sachetypedef struct sap_entry {
6232227Shelbig	struct sap_entry *forw;
6332227Shelbig	struct sap_entry *back;
6432227Shelbig	struct sap_entry *clone;
6554090Sache	struct interface *ifp;
6632227Shelbig	struct sap_info   sap;
6732227Shelbig	struct sockaddr   source;
6832227Shelbig	int hash;
6932227Shelbig	int state;
7032227Shelbig	int timer;
7132227Shelbig	int metric;
7232227Shelbig	}sap_entry;
7332227Shelbig
7432227Shelbig#define SAPHASHSIZ		32		/* Should be a power of 2 */
7532227Shelbig#define SAPHASHMASK		(SAPHASHSIZ-1)
7632227Shelbigtypedef struct sap_hash {
7754090Sache	struct sap_entry *forw;
7853943Sache	struct sap_entry *back;
79174990Sache	}sap_hash;
8053943Sache
8153943Sacheextern sap_hash sap_head[SAPHASHSIZ];
8253943Sache
8353943Sacheextern struct   sap_packet *sap_msg;
8453943Sache
8553943Sachevoid sapinit(void);
8653943Sachevoid sap_input(struct sockaddr *from, int size);
8753943Sachevoid sapsndmsg(struct sockaddr *dst, int flags, struct interface *ifp);
8853943Sachevoid sap_supply_toall(void);
8953943Sachevoid sap_supply(struct sockaddr *dst,
9053943Sache                int flags,
9153943Sache		struct interface *ifp,
9253943Sache		int ServType);
9353943Sache
9474413Sachestruct sap_entry *sap_lookup(u_short ServType, char *ServName);
9553943Sachestruct sap_entry *sap_nearestserver(ushort ServType, struct interface *ifp);
9674413Sachevoid sap_add(struct sap_info *si, struct sockaddr *from);
9753961Sachevoid sap_change(struct sap_entry *sap,
9874413Sache                struct sap_info *si,
9953961Sache		struct sockaddr *from);
10074413Sachevoid sap_add_clone(struct sap_entry *sap,
10174413Sache                   struct sap_info *clone,
102		   struct sockaddr *from);
103void sap_delete(struct sap_entry *sap);
104
105#endif /*_SAP_H_*/
106
107