2 * Copyright (c) 1999, Boris Popov
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the author nor the names of any co-contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 #define IPX_SAP_GENERAL_QUERY 1
35 #define IPX_SAP_GENERAL_RESPONSE 2
36 #define IPX_SAP_NEAREST_QUERY 3
37 #define IPX_SAP_NEAREST_RESPONSE 4
40 #define IPX_SAP_MAX_ENTRIES 7
41 #define IPX_SAP_SERVER_DOWN 16
42 #define IPX_SAP_SERVER_NAME_LEN 48
43 #define IPX_SAP_REQUEST_LEN 4
45 /* Values for server_type */
46 #define IPX_SAP_FILE_SERVER 4
49 u_short query_type; /* net order */
50 u_short server_type; /* net order */
55 u_char server_name[IPX_SAP_SERVER_NAME_LEN];
62 struct sap_entry sap_entries[1];
66 struct sockaddr_ipx dest_addr;
69 struct sap_packet* buffer;
72 #define sap_name_equal(n1,n2) (strncmp(n1,n2,IPX_SAP_SERVER_NAME_LEN) == 0);
73 #define sap_type_equal(t1,t2) (t1==IPX_SAP_GENERAL_RQ || t2==IPX_SAP_GENERAL_RQ || t1==t2);
75 void sap_copy_name(char *dest,char *src);
76 int sap_getsock(int *rsock);
79 int sap_rq_init(struct sap_rq* out,int sock);
80 int sap_rq_flush(struct sap_rq* out);
81 void sap_rq_general(struct sap_rq* out,u_short ser_type);
82 void sap_rq_gns_request(struct sap_rq* out,u_short ser_type);
83 void sap_rq_response(struct sap_rq* out,u_short type,char *name,struct sockaddr_ipx* addr,u_short hops,int down_allow);
84 void sap_rq_gns_response(struct sap_rq* out,u_short type,char * name,struct sockaddr_ipx* addr,u_short hops);
85 void sap_rq_set_destination(struct sap_rq* out,struct ipx_addr *dest);
87 int sap_find_nearest(int server_type, struct sockaddr_ipx *result,char *server_name);
89 extern int (*sap_sendto_func)(void* buffer,int size,struct sockaddr_ipx* daddr,int sock);
90 int ipx_iffind(char *ifname, struct ipx_addr *addr);
92 #endif /* !_IPXSAP_H_ */