Initial import from FreeBSD RELENG_4:
[dragonfly.git] / lib / libncp / ipxsap.h
1 /*
2  * Copyright (c) 1999, Boris Popov
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
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. All advertising materials mentioning features or use of this software
14  *    must display the following acknowledgement:
15  *    This product includes software developed by Boris Popov.
16  * 4. Neither the name of the author nor the names of any co-contributors
17  *    may be used to endorse or promote products derived from this software
18  *    without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30  * SUCH DAMAGE.
31  *
32  * $FreeBSD: src/lib/libncp/ipxsap.h,v 1.1 1999/10/12 11:56:37 bp Exp $
33  */
34 #ifndef _IPXSAP_H_
35 #define _IPXSAP_H_
36
37 #define IPX_SAP_GENERAL_QUERY           1
38 #define IPX_SAP_GENERAL_RESPONSE        2
39 #define IPX_SAP_NEAREST_QUERY           3
40 #define IPX_SAP_NEAREST_RESPONSE        4
41
42
43 #define IPX_SAP_MAX_ENTRIES             7
44 #define IPX_SAP_SERVER_DOWN             16
45 #define IPX_SAP_SERVER_NAME_LEN         48
46 #define IPX_SAP_REQUEST_LEN             4
47
48 /* Values for server_type */
49 #define IPX_SAP_FILE_SERVER             4
50
51 struct sap_query {
52         u_short         query_type;     /* net order */
53         u_short         server_type;    /* net order */
54 };
55
56 struct sap_entry {
57         u_short         server_type;
58         u_char          server_name[IPX_SAP_SERVER_NAME_LEN];
59         struct ipx_addr ipx;
60         u_short         hops;
61 };
62
63 struct sap_packet {
64         u_short         operation;
65         struct sap_entry sap_entries[1];
66 };
67
68 struct sap_rq {
69         struct sockaddr_ipx dest_addr;
70         int             sock;
71         int             entries;
72         struct sap_packet* buffer;
73 };
74 /*
75 #define sap_name_equal(n1,n2)   (strncmp(n1,n2,IPX_SAP_SERVER_NAME_LEN) == 0);
76 #define sap_type_equal(t1,t2)   (t1==IPX_SAP_GENERAL_RQ || t2==IPX_SAP_GENERAL_RQ || t1==t2);
77 */
78 void sap_copy_name(char *dest,char *src); 
79 int  sap_getsock(int *rsock);
80
81
82 int  sap_rq_init(struct sap_rq* out,int sock);
83 int  sap_rq_flush(struct sap_rq* out);
84 void sap_rq_general(struct sap_rq* out,u_short ser_type);
85 void sap_rq_gns_request(struct sap_rq* out,u_short ser_type);
86 void sap_rq_response(struct sap_rq* out,u_short type,char *name,struct sockaddr_ipx* addr,u_short hops,int down_allow);
87 void sap_rq_gns_response(struct sap_rq* out,u_short type,char * name,struct sockaddr_ipx* addr,u_short hops);
88 void sap_rq_set_destination(struct sap_rq* out,struct ipx_addr *dest);
89
90 int  sap_find_nearest(int server_type, struct sockaddr_ipx *result,char *server_name);
91
92 extern int (*sap_sendto_func)(void* buffer,int size,struct sockaddr_ipx* daddr,int sock);
93 int  ipx_iffind(char *ifname, struct ipx_addr *addr);
94
95 #endif /* !_IPXSAP_H_ */