sap.h revision 15248
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 * 3115248Sjhay * $Id: sap.h,v 1.2 1995/10/27 10:48:31 julian Exp $ 3211820Sjulian */ 3311820Sjulian#ifndef _SAP_H_ 3411820Sjulian#define _SAP_H_ 3511820Sjulian 3611840Sjulian#define IPXPROTO_SAP IPXPROTO_PXP 3711840Sjulian 3811820Sjulian#define SAP_REQ 1 3911820Sjulian#define SAP_RESP 2 4011820Sjulian#define SAP_REQ_NEAR 3 4111820Sjulian#define SAP_RESP_NEAR 4 4211820Sjulian 4311820Sjulian#define SAPCMD_MAX 5 4411820Sjulian#ifdef SAPCMDS 4511820Sjulianchar *sapcmds[SAPCMD_MAX] = 4611820Sjulian { "#0", "REQUEST", "RESPONSE", "REQ NEAREST", "RESP NEAREST"}; 4711820Sjulian#endif 4811820Sjulian 4915248Sjhay#define MAXSAPENTRIES 7 5011820Sjulian#define SAP_WILDCARD 0xFFFF 5111820Sjulian#define SERVNAMELEN 48 5211820Sjuliantypedef struct sap_info { 5311820Sjulian u_short ServType; 5411820Sjulian char ServName[SERVNAMELEN]; 5511820Sjulian struct ipx_addr ipx; 5611820Sjulian u_short hops; 5711820Sjulian }sap_info; 5811820Sjulian 5911820Sjuliantypedef struct sap_packet { 6011820Sjulian u_short sap_cmd; 6111820Sjulian sap_info sap[0]; /* Variable length. */ 6211820Sjulian }sap_packet; 6311820Sjulian 6411820Sjuliantypedef struct sap_entry { 6511820Sjulian struct sap_entry *forw; 6611820Sjulian struct sap_entry *back; 6711820Sjulian struct sap_entry *clone; 6811820Sjulian struct interface *ifp; 6911820Sjulian struct sap_info sap; 7011820Sjulian struct sockaddr source; 7111820Sjulian int hash; 7211820Sjulian int state; 7311820Sjulian int timer; 7411820Sjulian int metric; 7511820Sjulian }sap_entry; 7611820Sjulian 7711820Sjulian#define SAPHASHSIZ 32 /* Should be a power of 2 */ 7811820Sjulian#define SAPHASHMASK (SAPHASHSIZ-1) 7911820Sjuliantypedef struct sap_hash { 8011820Sjulian struct sap_entry *forw; 8111820Sjulian struct sap_entry *back; 8211820Sjulian }sap_hash; 8311820Sjulian 8411820Sjulianextern sap_hash sap_head[SAPHASHSIZ]; 8511820Sjulian 8611820Sjulianextern struct sap_packet *sap_msg; 8711820Sjulian 8811820Sjulianvoid sapinit(void); 8911820Sjulianvoid sap_input(struct sockaddr *from, int size); 9011820Sjulianvoid sapsndmsg(struct sockaddr *dst, int flags, struct interface *ifp); 9111820Sjulianvoid sap_supply_toall(void); 9211820Sjulianvoid sap_supply(struct sockaddr *dst, 9311820Sjulian int flags, 9411820Sjulian struct interface *ifp, 9511820Sjulian int ServType); 9611820Sjulian 9711820Sjulianstruct sap_entry *sap_lookup(u_short ServType, char *ServName); 9811820Sjulianstruct sap_entry *sap_nearestserver(ushort ServType, struct interface *ifp); 9911820Sjulianvoid sap_add(struct sap_info *si, struct sockaddr *from); 10011820Sjulianvoid sap_change(struct sap_entry *sap, 10111820Sjulian struct sap_info *si, 10211820Sjulian struct sockaddr *from); 10311820Sjulianvoid sap_add_clone(struct sap_entry *sap, 10411820Sjulian struct sap_info *clone, 10511820Sjulian struct sockaddr *from); 10611820Sjulianvoid sap_delete(struct sap_entry *sap); 10711820Sjulian 10811820Sjulian#endif /*_SAP_H_*/ 10911820Sjulian 110