]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/netipx/ipx_pcb.h
This commit was generated by cvs2svn to compensate for changes in r160814,
[FreeBSD/FreeBSD.git] / sys / netipx / ipx_pcb.h
1 /*-
2  * Copyright (c) 1984, 1985, 1986, 1987, 1993
3  *      The Regents of the University of California.  All rights reserved.
4  * Copyright (c) 1995, Mike Mitchell
5  * Copyright (c) 2004-2006 Robert N. M. Watson
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. All advertising materials mentioning features or use of this software
16  *    must display the following acknowledgement:
17  *      This product includes software developed by the University of
18  *      California, Berkeley and its contributors.
19  * 4. Neither the name of the University nor the names of its contributors
20  *    may be used to endorse or promote products derived from this software
21  *    without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33  * SUCH DAMAGE.
34  *
35  *      @(#)ipx_pcb.h
36  *
37  * $FreeBSD$
38  */
39
40 #ifndef _NETIPX_IPX_PCB_H_
41 #define _NETIPX_IPX_PCB_H_
42
43 /*
44  * IPX protocol interface control block.
45  */
46 struct ipxpcb {
47         LIST_ENTRY(ipxpcb) ipxp_list;
48         struct  socket *ipxp_socket;    /* back pointer to socket */
49         struct  ipx_addr ipxp_faddr;    /* destination address */
50         struct  ipx_addr ipxp_laddr;    /* socket's address */
51         caddr_t ipxp_pcb;               /* protocol specific stuff */
52         struct  route ipxp_route;       /* routing information */
53         struct  ipx_addr ipxp_lastdst;  /* validate cached route for dg socks*/
54         short   ipxp_flags;
55         u_char  ipxp_dpt;               /* default packet type for ipx_output */
56         u_char  ipxp_rpt;               /* last received packet type by ipx_input() */
57         struct  mtx ipxp_mtx;
58 };
59
60 /*
61  * Additional IPX pcb-related types and variables.
62  */
63 LIST_HEAD(ipxpcbhead, ipxpcb);
64 extern struct ipxpcbhead ipxpcb_list;
65 extern struct ipxpcbhead ipxrawpcb_list;
66
67 #ifdef _KERNEL
68 extern struct mtx       ipxpcb_list_mtx;
69 #endif
70
71 /*
72  * IPX/SPX PCB flags.
73  */
74 #define IPXP_IN_ABORT           0x1     /* Calling abort through socket. */
75 #define IPXP_RAWIN              0x2     /* Show headers on input. */
76 #define IPXP_RAWOUT             0x4     /* Show header on output. */
77 #define IPXP_ALL_PACKETS        0x8     /* Turn off higher proto processing. */
78 #define IPXP_CHECKSUM           0x10    /* Use checksum on this socket. */
79 #define IPXP_DROPPED            0x20    /* Connection dropped. */
80 #define IPXP_SPX                0x40    /* SPX PCB. */
81
82 #define IPX_WILDCARD            1
83
84 #define ipxp_lport ipxp_laddr.x_port
85 #define ipxp_fport ipxp_faddr.x_port
86
87 #define sotoipxpcb(so)          ((struct ipxpcb *)((so)->so_pcb))
88
89 /*
90  * Nominal space allocated to an IPX socket.
91  */
92 #define IPXSNDQ         16384
93 #define IPXRCVQ         40960
94
95 #ifdef _KERNEL
96 int     ipx_pcballoc(struct socket *so, struct ipxpcbhead *head,
97                           struct thread *p);
98 int     ipx_pcbbind(struct ipxpcb *ipxp, struct sockaddr *nam,
99                          struct thread *p);
100 int     ipx_pcbconnect(struct ipxpcb *ipxp, struct sockaddr *nam,
101                             struct thread *p);
102 void    ipx_pcbdetach(struct ipxpcb *ipxp);
103 void    ipx_pcbdisconnect(struct ipxpcb *ipxp);
104 void    ipx_pcbfree(struct ipxpcb *ipxp);
105 struct ipxpcb *
106         ipx_pcblookup(struct ipx_addr *faddr, int lport, int wildp);
107 void    ipx_setpeeraddr(struct ipxpcb *ipxp, struct sockaddr **nam);
108 void    ipx_setsockaddr(struct ipxpcb *ipxp, struct sockaddr **nam);
109
110 #define IPX_LIST_LOCK_INIT()    mtx_init(&ipxpcb_list_mtx, "ipx_list_mtx", \
111                                     NULL, MTX_DEF | MTX_RECURSE)
112 #define IPX_LIST_LOCK()         mtx_lock(&ipxpcb_list_mtx)
113 #define IPX_LIST_UNLOCK()       mtx_unlock(&ipxpcb_list_mtx)
114 #define IPX_LIST_LOCK_ASSERT()  mtx_assert(&ipxpcb_list_mtx, MA_OWNED)
115
116 #define IPX_LOCK_INIT(ipx)      mtx_init(&(ipx)->ipxp_mtx, "ipx_mtx", NULL, \
117                                     MTX_DEF)
118 #define IPX_LOCK_DESTROY(ipx)   mtx_destroy(&(ipx)->ipxp_mtx)
119 #define IPX_LOCK(ipx)           mtx_lock(&(ipx)->ipxp_mtx)
120 #define IPX_UNLOCK(ipx)         mtx_unlock(&(ipx)->ipxp_mtx)
121 #define IPX_LOCK_ASSERT(ipx)    mtx_assert(&(ipx)->ipxp_mtx, MA_OWNED)
122 #endif /* _KERNEL */
123
124 #endif /* !_NETIPX_IPX_PCB_H_ */