xref: /original-bsd/sys/netinet/in_pcb.h (revision c3e32dec)
1 /*
2  * Copyright (c) 1982, 1986, 1990 Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)in_pcb.h	7.9 (Berkeley) 06/04/93
8  */
9 
10 /*
11  * Common structure pcb for internet protocol implementation.
12  * Here are stored pointers to local and foreign host table
13  * entries, local and foreign socket numbers, and pointers
14  * up (to a socket structure) and down (to a protocol-specific)
15  * control block.
16  */
17 struct inpcb {
18 	struct	inpcb *inp_next,*inp_prev;
19 					/* pointers to other pcb's */
20 	struct	inpcb *inp_head;	/* pointer back to chain of inpcb's
21 					   for this protocol */
22 	struct	in_addr inp_faddr;	/* foreign host table entry */
23 	u_short	inp_fport;		/* foreign port */
24 	struct	in_addr inp_laddr;	/* local host table entry */
25 	u_short	inp_lport;		/* local port */
26 	struct	socket *inp_socket;	/* back pointer to socket */
27 	caddr_t	inp_ppcb;		/* pointer to per-protocol pcb */
28 	struct	route inp_route;	/* placeholder for routing entry */
29 	int	inp_flags;		/* generic IP/datagram flags */
30 	struct	ip inp_ip;		/* header prototype; should have more */
31 	struct	mbuf *inp_options;	/* IP options */
32 	struct	ip_moptions *inp_moptions; /* IP multicast options */
33 };
34 
35 /* flags in inp_flags: */
36 #define	INP_RECVOPTS		0x01	/* receive incoming IP options */
37 #define	INP_RECVRETOPTS		0x02	/* receive IP options for reply */
38 #define	INP_RECVDSTADDR		0x04	/* receive IP dst address */
39 #define	INP_CONTROLOPTS		(INP_RECVOPTS|INP_RECVRETOPTS|INP_RECVDSTADDR)
40 #define	INP_HDRINCL		0x08	/* user supplies entire IP header */
41 
42 #define	INPLOOKUP_WILDCARD	1
43 #define	INPLOOKUP_SETLOCAL	2
44 
45 #define	sotoinpcb(so)	((struct inpcb *)(so)->so_pcb)
46 
47 #ifdef KERNEL
48 int	 in_losing __P((struct inpcb *));
49 int	 in_pcballoc __P((struct socket *, struct inpcb *));
50 int	 in_pcbbind __P((struct inpcb *, struct mbuf *));
51 int	 in_pcbconnect __P((struct inpcb *, struct mbuf *));
52 int	 in_pcbdetach __P((struct inpcb *));
53 int	 in_pcbdisconnect __P((struct inpcb *));
54 struct inpcb *
55 	 in_pcblookup __P((struct inpcb *,
56 	    struct in_addr, u_int, struct in_addr, u_int, int));
57 int	 in_pcbnotify __P((struct inpcb *, struct sockaddr *,
58 	    u_int, struct in_addr, u_int, int, void (*)(struct inpcb *, int)));
59 void	 in_rtchange __P((struct inpcb *, int));
60 int	 in_setpeeraddr __P((struct inpcb *, struct mbuf *));
61 int	 in_setsockaddr __P((struct inpcb *, struct mbuf *));
62 #endif
63