1139823Simp/*- 211819Sjulian * Copyright (c) 1984, 1985, 1986, 1987, 1993 3165899Srwatson * The Regents of the University of California. 4157128Srwatson * Copyright (c) 2004-2006 Robert N. M. Watson 5165899Srwatson * All rights reserved. 611819Sjulian * 711819Sjulian * Redistribution and use in source and binary forms, with or without 811819Sjulian * modification, are permitted provided that the following conditions 911819Sjulian * are met: 1011819Sjulian * 1. Redistributions of source code must retain the above copyright 1111819Sjulian * notice, this list of conditions and the following disclaimer. 1211819Sjulian * 2. Redistributions in binary form must reproduce the above copyright 1311819Sjulian * notice, this list of conditions and the following disclaimer in the 1411819Sjulian * documentation and/or other materials provided with the distribution. 15165899Srwatson * 4. Neither the name of the University nor the names of its contributors 16165899Srwatson * may be used to endorse or promote products derived from this software 17165899Srwatson * without specific prior written permission. 18165899Srwatson * 19165899Srwatson * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20165899Srwatson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21165899Srwatson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22165899Srwatson * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23165899Srwatson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24165899Srwatson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25165899Srwatson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26165899Srwatson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27165899Srwatson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28165899Srwatson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29165899Srwatson * SUCH DAMAGE. 30165899Srwatson * 31165899Srwatson * Copyright (c) 1995, Mike Mitchell 32165899Srwatson * All rights reserved. 33165899Srwatson * 34165899Srwatson * Redistribution and use in source and binary forms, with or without 35165899Srwatson * modification, are permitted provided that the following conditions 36165899Srwatson * are met: 37165899Srwatson * 1. Redistributions of source code must retain the above copyright 38165899Srwatson * notice, this list of conditions and the following disclaimer. 39165899Srwatson * 2. Redistributions in binary form must reproduce the above copyright 40165899Srwatson * notice, this list of conditions and the following disclaimer in the 41165899Srwatson * documentation and/or other materials provided with the distribution. 4211819Sjulian * 3. All advertising materials mentioning features or use of this software 4311819Sjulian * must display the following acknowledgement: 4411819Sjulian * This product includes software developed by the University of 4511819Sjulian * California, Berkeley and its contributors. 4611819Sjulian * 4. Neither the name of the University nor the names of its contributors 4711819Sjulian * may be used to endorse or promote products derived from this software 4811819Sjulian * without specific prior written permission. 4911819Sjulian * 5011819Sjulian * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 5111819Sjulian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 5211819Sjulian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 5311819Sjulian * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 5411819Sjulian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 5511819Sjulian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 5611819Sjulian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 5711819Sjulian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 5811819Sjulian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 5911819Sjulian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 6011819Sjulian * SUCH DAMAGE. 6111819Sjulian * 6212057Sjulian * @(#)ipx_pcb.h 6312057Sjulian * 6450477Speter * $FreeBSD$ 6511819Sjulian */ 6611819Sjulian 6711819Sjulian#ifndef _NETIPX_IPX_PCB_H_ 6812470Sbde#define _NETIPX_IPX_PCB_H_ 6911819Sjulian 7011819Sjulian/* 7111819Sjulian * IPX protocol interface control block. 7211819Sjulian */ 7311819Sjulianstruct ipxpcb { 74139444Srwatson LIST_ENTRY(ipxpcb) ipxp_list; 7511819Sjulian struct socket *ipxp_socket; /* back pointer to socket */ 7611819Sjulian struct ipx_addr ipxp_faddr; /* destination address */ 7711819Sjulian struct ipx_addr ipxp_laddr; /* socket's address */ 7811819Sjulian caddr_t ipxp_pcb; /* protocol specific stuff */ 7911819Sjulian struct route ipxp_route; /* routing information */ 8011819Sjulian struct ipx_addr ipxp_lastdst; /* validate cached route for dg socks*/ 8111819Sjulian short ipxp_flags; 8211819Sjulian u_char ipxp_dpt; /* default packet type for ipx_output */ 8311819Sjulian u_char ipxp_rpt; /* last received packet type by ipx_input() */ 84139925Srwatson struct mtx ipxp_mtx; 8511819Sjulian}; 8611819Sjulian 87139444Srwatson/* 88139444Srwatson * Additional IPX pcb-related types and variables. 89139444Srwatson */ 90139444SrwatsonLIST_HEAD(ipxpcbhead, ipxpcb); 91139444Srwatsonextern struct ipxpcbhead ipxpcb_list; 92139444Srwatsonextern struct ipxpcbhead ipxrawpcb_list; 93139444Srwatson 94139925Srwatson#ifdef _KERNEL 95139925Srwatsonextern struct mtx ipxpcb_list_mtx; 96139925Srwatson#endif 97139925Srwatson 98157128Srwatson/* 99157128Srwatson * IPX/SPX PCB flags. 100157128Srwatson */ 101157128Srwatson#define IPXP_IN_ABORT 0x1 /* Calling abort through socket. */ 102157128Srwatson#define IPXP_RAWIN 0x2 /* Show headers on input. */ 103157128Srwatson#define IPXP_RAWOUT 0x4 /* Show header on output. */ 104157128Srwatson#define IPXP_ALL_PACKETS 0x8 /* Turn off higher proto processing. */ 105157128Srwatson#define IPXP_CHECKSUM 0x10 /* Use checksum on this socket. */ 106157128Srwatson#define IPXP_DROPPED 0x20 /* Connection dropped. */ 107157145Srwatson#define IPXP_SPX 0x40 /* SPX PCB. */ 10811819Sjulian 10925652Sjhay#define IPX_WILDCARD 1 11011819Sjulian 11111819Sjulian#define ipxp_lport ipxp_laddr.x_port 11211819Sjulian#define ipxp_fport ipxp_faddr.x_port 11311819Sjulian 11411819Sjulian#define sotoipxpcb(so) ((struct ipxpcb *)((so)->so_pcb)) 11511819Sjulian 11611819Sjulian/* 117108533Sschweikh * Nominal space allocated to an IPX socket. 11811819Sjulian */ 11919947Sjhay#define IPXSNDQ 16384 12019947Sjhay#define IPXRCVQ 40960 12111819Sjulian 12255205Speter#ifdef _KERNEL 123139444Srwatsonint ipx_pcballoc(struct socket *so, struct ipxpcbhead *head, 124169463Srwatson struct thread *p); 12592745Salfredint ipx_pcbbind(struct ipxpcb *ipxp, struct sockaddr *nam, 126169463Srwatson struct thread *p); 12792745Salfredint ipx_pcbconnect(struct ipxpcb *ipxp, struct sockaddr *nam, 128169463Srwatson struct thread *p); 12992745Salfredvoid ipx_pcbdetach(struct ipxpcb *ipxp); 13092745Salfredvoid ipx_pcbdisconnect(struct ipxpcb *ipxp); 131157128Srwatsonvoid ipx_pcbfree(struct ipxpcb *ipxp); 132169463Srwatsonstruct ipxpcb *ipx_pcblookup(struct ipx_addr *faddr, u_short lport, int wildp); 133169462Srwatsonvoid ipx_getpeeraddr(struct ipxpcb *ipxp, struct sockaddr **nam); 134169462Srwatsonvoid ipx_getsockaddr(struct ipxpcb *ipxp, struct sockaddr **nam); 135139925Srwatson 136139925Srwatson#define IPX_LIST_LOCK_INIT() mtx_init(&ipxpcb_list_mtx, "ipx_list_mtx", \ 137139925Srwatson NULL, MTX_DEF | MTX_RECURSE) 138139925Srwatson#define IPX_LIST_LOCK() mtx_lock(&ipxpcb_list_mtx) 139139925Srwatson#define IPX_LIST_UNLOCK() mtx_unlock(&ipxpcb_list_mtx) 140139925Srwatson#define IPX_LIST_LOCK_ASSERT() mtx_assert(&ipxpcb_list_mtx, MA_OWNED) 141139925Srwatson 142139925Srwatson#define IPX_LOCK_INIT(ipx) mtx_init(&(ipx)->ipxp_mtx, "ipx_mtx", NULL, \ 143139925Srwatson MTX_DEF) 144139925Srwatson#define IPX_LOCK_DESTROY(ipx) mtx_destroy(&(ipx)->ipxp_mtx) 145139925Srwatson#define IPX_LOCK(ipx) mtx_lock(&(ipx)->ipxp_mtx) 146139925Srwatson#define IPX_UNLOCK(ipx) mtx_unlock(&(ipx)->ipxp_mtx) 147139925Srwatson#define IPX_LOCK_ASSERT(ipx) mtx_assert(&(ipx)->ipxp_mtx, MA_OWNED) 14855205Speter#endif /* _KERNEL */ 14911819Sjulian 15026965Sjhay#endif /* !_NETIPX_IPX_PCB_H_ */ 151