/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
*
- * @APPLE_LICENSE_HEADER_START@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License"). You may not use this file except in compliance with the
- * License. Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
*
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
- * @APPLE_LICENSE_HEADER_END@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/* Copyright (c) 1998, 1999 Apple Computer, Inc. All Rights Reserved */
/* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
* SUCH DAMAGE.
*
* @(#)protosw.h 8.1 (Berkeley) 6/2/93
+ * $FreeBSD: src/sys/sys/protosw.h,v 1.28.2.2 2001/07/03 11:02:01 ume Exp $
*/
+#ifndef _SYS_PROTOSW_H_
+#define _SYS_PROTOSW_H_
+
+#include <sys/appleapiopts.h>
+#include <sys/cdefs.h>
+
+#define PR_SLOWHZ 2 /* 2 slow timeouts per second */
+#define PR_FASTHZ 5 /* 5 fast timeouts per second */
+
+#ifdef PRIVATE
+
+/* Forward declare these structures referenced from prototypes below. */
+struct mbuf;
+struct proc;
+struct sockaddr;
+struct socket;
+struct sockopt;
+struct socket_filter;
+
+/*#ifdef _KERNEL*/
/*
* Protocol switch table.
*
*
* Protocols pass data between themselves as chains of mbufs using
* the pr_input and pr_output hooks. Pr_input passes data up (towards
- * UNIX) and pr_output passes it down (towards the imps); control
+ * the users) and pr_output passes it down (towards the interfaces); control
* information passes up and down on pr_ctlinput and pr_ctloutput.
* The protocol is responsible for the space occupied by any the
* arguments to these entries and must dispose it.
* described below.
*/
-#ifndef _SYS_PROTOSW_H_
-#define _SYS_PROTOSW_H_
-
#include <sys/socketvar.h>
#include <sys/queue.h>
+#ifdef KERNEL
+#include <kern/locks.h>
+#endif /* KERNEL */
+
+#if __DARWIN_ALIGN_POWER
+#pragma options align=power
+#endif
struct protosw {
short pr_type; /* socket type used for */
short pr_protocol; /* protocol number */
unsigned int pr_flags; /* see below */
/* protocol-protocol hooks */
- void (*pr_input) __P((struct mbuf *, int len));
+ void (*pr_input)(struct mbuf *, int len);
/* input to protocol (from below) */
- int (*pr_output) __P((struct mbuf *m, struct socket *so));
+ int (*pr_output)(struct mbuf *m, struct socket *so);
/* output to protocol (from above) */
- void (*pr_ctlinput)__P((int, struct sockaddr *, void *));
+ void (*pr_ctlinput)(int, struct sockaddr *, void *);
/* control input (from below) */
- int (*pr_ctloutput)__P((struct socket *, struct sockopt *));
+ int (*pr_ctloutput)(struct socket *, struct sockopt *);
/* control output (from above) */
/* user-protocol hook */
void *pr_ousrreq;
/* utility hooks */
- void (*pr_init) __P((void)); /* initialization hook */
- void (*pr_fasttimo) __P((void));
+ void (*pr_init)(void); /* initialization hook */
+ void (*pr_fasttimo)(void);
/* fast timeout (200ms) */
- void (*pr_slowtimo) __P((void));
+ void (*pr_slowtimo)(void);
/* slow timeout (500ms) */
- void (*pr_drain) __P((void));
+ void (*pr_drain)(void);
/* flush any excess space possible */
-
- int (*pr_sysctl)(); /* sysctl for protocol */
-
+#if __APPLE__
+ int (*pr_sysctl)(int *, u_int, void *, size_t *, void *, size_t);
+ /* sysctl for protocol */
+#endif
struct pr_usrreqs *pr_usrreqs; /* supersedes pr_usrreq() */
+#if __APPLE__
+ int (*pr_lock) (struct socket *so, int locktype, int debug); /* lock function for protocol */
+ int (*pr_unlock) (struct socket *so, int locktype, int debug); /* unlock for protocol */
+#ifdef _KERN_LOCKS_H_
+ lck_mtx_t * (*pr_getlock) (struct socket *so, int locktype);
+#else
+ void * (*pr_getlock) (struct socket *so, int locktype);
+#endif
+#endif
+#if __APPLE__
/* Implant hooks */
- TAILQ_HEAD(pr_sfilter, NFDescriptor) pr_sfilter;
+ TAILQ_HEAD(, socket_filter) pr_filter_head;
struct protosw *pr_next; /* Chain for domain */
+ u_long reserved[1]; /* Padding for future use */
+#endif
};
-#define PR_SLOWHZ 2 /* 2 slow timeouts per second */
-#define PR_FASTHZ 5 /* 5 fast timeouts per second */
+#if __DARWIN_ALIGN_POWER
+#pragma options align=reset
+#endif
/*
* Values for pr_flags.
* PR_ADDR requires PR_ATOMIC;
* PR_ADDR and PR_CONNREQUIRED are mutually exclusive.
+ * PR_IMPLOPCL means that the protocol allows sendto without prior connect,
+ * and the protocol understands the MSG_EOF flag. The first property is
+ * is only relevant if PR_CONNREQUIRED is set (otherwise sendto is allowed
+ * anyhow).
*/
-#define PR_ATOMIC 0x01 /* exchange atomic messages only */
-#define PR_ADDR 0x02 /* addresses given with messages */
+#define PR_ATOMIC 0x01 /* exchange atomic messages only */
+#define PR_ADDR 0x02 /* addresses given with messages */
#define PR_CONNREQUIRED 0x04 /* connection required by protocol */
-#define PR_WANTRCVD 0x08 /* want PRU_RCVD calls */
-#define PR_RIGHTS 0x10 /* passes capabilities */
-#define PR_IMPLOPCL 0x20 /* implied open/close */
+#define PR_WANTRCVD 0x08 /* want PRU_RCVD calls */
+#define PR_RIGHTS 0x10 /* passes capabilities */
+#define PR_IMPLOPCL 0x20 /* implied open/close */
+#define PR_LASTHDR 0x40 /* enforce ipsec policy; last header */
+#define PR_PROTOLOCK 0x80 /* protocol takes care of it's own locking */
+#define PR_PCBLOCK 0x100 /* protocol supports per pcb finer grain locking */
+#define PR_DISPOSE 0x200 /* protocol requires late lists disposal */
/*
* The arguments to usrreq are:
* migrate this stuff back into the main structure.
*/
struct pr_usrreqs {
- int (*pru_abort) __P((struct socket *so));
- int (*pru_accept) __P((struct socket *so, struct sockaddr **nam));
- int (*pru_attach) __P((struct socket *so, int proto,
- struct proc *p));
- int (*pru_bind) __P((struct socket *so, struct sockaddr *nam,
- struct proc *p));
- int (*pru_connect) __P((struct socket *so, struct sockaddr *nam,
- struct proc *p));
- int (*pru_connect2) __P((struct socket *so1, struct socket *so2));
- int (*pru_control) __P((struct socket *so, u_long cmd, caddr_t data,
- struct ifnet *ifp, struct proc *p));
- int (*pru_detach) __P((struct socket *so));
- int (*pru_disconnect) __P((struct socket *so));
- int (*pru_listen) __P((struct socket *so, struct proc *p));
- int (*pru_peeraddr) __P((struct socket *so,
- struct sockaddr **nam));
- int (*pru_rcvd) __P((struct socket *so, int flags));
- int (*pru_rcvoob) __P((struct socket *so, struct mbuf *m,
- int flags));
- int (*pru_send) __P((struct socket *so, int flags, struct mbuf *m,
+ int (*pru_abort)(struct socket *so);
+ int (*pru_accept)(struct socket *so, struct sockaddr **nam);
+ int (*pru_attach)(struct socket *so, int proto, struct proc *p);
+ int (*pru_bind)(struct socket *so, struct sockaddr *nam,
+ struct proc *p);
+ int (*pru_connect)(struct socket *so, struct sockaddr *nam,
+ struct proc *p);
+ int (*pru_connect2)(struct socket *so1, struct socket *so2);
+ int (*pru_control)(struct socket *so, u_long cmd, caddr_t data,
+ struct ifnet *ifp, struct proc *p);
+ int (*pru_detach)(struct socket *so);
+ int (*pru_disconnect)(struct socket *so);
+ int (*pru_listen)(struct socket *so, struct proc *p);
+ int (*pru_peeraddr)(struct socket *so, struct sockaddr **nam);
+ int (*pru_rcvd)(struct socket *so, int flags);
+ int (*pru_rcvoob)(struct socket *so, struct mbuf *m, int flags);
+ int (*pru_send)(struct socket *so, int flags, struct mbuf *m,
struct sockaddr *addr, struct mbuf *control,
- struct proc *p));
+ struct proc *p);
#define PRUS_OOB 0x1
#define PRUS_EOF 0x2
#define PRUS_MORETOCOME 0x4
- int (*pru_sense) __P((struct socket *so, struct stat *sb));
- int (*pru_shutdown) __P((struct socket *so));
- int (*pru_sockaddr) __P((struct socket *so,
- struct sockaddr **nam));
+ int (*pru_sense)(struct socket *so, struct stat *sb);
+ int (*pru_shutdown)(struct socket *so);
+ int (*pru_sockaddr)(struct socket *so, struct sockaddr **nam);
/*
* These three added later, so they are out of order. They are used
* through these entry points. For protocols which still use
* the generic code, these just point to those routines.
*/
- int (*pru_sosend) __P((struct socket *so, struct sockaddr *addr,
+ int (*pru_sosend)(struct socket *so, struct sockaddr *addr,
struct uio *uio, struct mbuf *top,
- struct mbuf *control, int flags));
- int (*pru_soreceive) __P((struct socket *so,
+ struct mbuf *control, int flags);
+ int (*pru_soreceive)(struct socket *so,
struct sockaddr **paddr,
struct uio *uio, struct mbuf **mp0,
- struct mbuf **controlp, int *flagsp));
- int (*pru_sopoll) __P((struct socket *so, int events,
- struct ucred *cred));
+ struct mbuf **controlp, int *flagsp);
+ int (*pru_sopoll)(struct socket *so, int events,
+ struct ucred *cred, void *);
};
+__BEGIN_DECLS
extern int pru_abort_notsupp(struct socket *so);
extern int pru_accept_notsupp(struct socket *so, struct sockaddr **nam);
struct uio *uio, struct mbuf **mp0,
struct mbuf **controlp, int *flagsp);
extern int pru_sopoll_notsupp(struct socket *so, int events,
- struct ucred *cred);
+ struct ucred *cred, void *);
+__END_DECLS
#endif /* KERNEL */
#define PRC_TIMXCEED_INTRANS 18 /* packet lifetime expired in transit */
#define PRC_TIMXCEED_REASS 19 /* lifetime expired on reass q */
#define PRC_PARAMPROB 20 /* header incorrect */
+#define PRC_UNREACH_ADMIN_PROHIB 21 /* packet administrativly prohibited */
-#define PRC_NCMDS 21
+#define PRC_NCMDS 22
#define PRC_IS_REDIRECT(cmd) \
((cmd) >= PRC_REDIRECT_NET && (cmd) <= PRC_REDIRECT_TOSHOST)
"NET-UNREACH", "HOST-UNREACH", "PROTO-UNREACH", "PORT-UNREACH",
"#12", "SRCFAIL-UNREACH", "NET-REDIRECT", "HOST-REDIRECT",
"TOSNET-REDIRECT", "TOSHOST-REDIRECT", "TX-INTRANS", "TX-REASS",
- "PARAMPROB"
+ "PARAMPROB", "ADMIN-UNREACH"
};
#endif
#endif
#ifdef KERNEL
-void pfctlinput __P((int, struct sockaddr *));
-struct protosw *pffindproto __P((int family, int protocol, int type));
-struct protosw *pffindtype __P((int family, int type));
+
+__BEGIN_DECLS
+
+void pfctlinput(int, struct sockaddr *);
+void pfctlinput2(int, struct sockaddr *, void *);
+struct protosw *pffindproto(int family, int protocol, int type);
+struct protosw *pffindproto_locked(int family, int protocol, int type);
+struct protosw *pffindtype(int family, int type);
extern int net_add_proto(struct protosw *, struct domain *);
extern int net_del_proto(int, int, struct domain *);
+__END_DECLS
+
/* Temp hack to link static domains together */
#define LINK_PROTOS(psw) \
}
#endif
+
+#endif /* PRIVATE */
#endif /* !_SYS_PROTOSW_H_ */