root / slirp / socket.h @ 86cc1ce0
History | View | Annotate | Download (3.5 kB)
1 | f0cbd3ec | bellard | /*
|
---|---|---|---|
2 | f0cbd3ec | bellard | * Copyright (c) 1995 Danny Gasparovski.
|
3 | f0cbd3ec | bellard | *
|
4 | f0cbd3ec | bellard | * Please read the file COPYRIGHT for the
|
5 | f0cbd3ec | bellard | * terms and conditions of the copyright.
|
6 | f0cbd3ec | bellard | */
|
7 | f0cbd3ec | bellard | |
8 | f0cbd3ec | bellard | /* MINE */
|
9 | f0cbd3ec | bellard | |
10 | f0cbd3ec | bellard | #ifndef _SLIRP_SOCKET_H_
|
11 | f0cbd3ec | bellard | #define _SLIRP_SOCKET_H_
|
12 | f0cbd3ec | bellard | |
13 | f0cbd3ec | bellard | #define SO_EXPIRE 240000 |
14 | f0cbd3ec | bellard | #define SO_EXPIREFAST 10000 |
15 | f0cbd3ec | bellard | |
16 | f0cbd3ec | bellard | /*
|
17 | f0cbd3ec | bellard | * Our socket structure
|
18 | f0cbd3ec | bellard | */
|
19 | f0cbd3ec | bellard | |
20 | f0cbd3ec | bellard | struct socket {
|
21 | f0cbd3ec | bellard | struct socket *so_next,*so_prev; /* For a linked list of sockets */ |
22 | f0cbd3ec | bellard | |
23 | f0cbd3ec | bellard | int s; /* The actual socket */ |
24 | f0cbd3ec | bellard | |
25 | f0cbd3ec | bellard | /* XXX union these with not-yet-used sbuf params */
|
26 | f0cbd3ec | bellard | struct mbuf *so_m; /* Pointer to the original SYN packet, |
27 | f0cbd3ec | bellard | * for non-blocking connect()'s, and
|
28 | f0cbd3ec | bellard | * PING reply's */
|
29 | f0cbd3ec | bellard | struct tcpiphdr *so_ti; /* Pointer to the original ti within |
30 | f0cbd3ec | bellard | * so_mconn, for non-blocking connections */
|
31 | f0cbd3ec | bellard | int so_urgc;
|
32 | f0cbd3ec | bellard | struct in_addr so_faddr; /* foreign host table entry */ |
33 | f0cbd3ec | bellard | struct in_addr so_laddr; /* local host table entry */ |
34 | f0cbd3ec | bellard | u_int16_t so_fport; /* foreign port */
|
35 | f0cbd3ec | bellard | u_int16_t so_lport; /* local port */
|
36 | f0cbd3ec | bellard | |
37 | f0cbd3ec | bellard | u_int8_t so_iptos; /* Type of service */
|
38 | f0cbd3ec | bellard | u_int8_t so_emu; /* Is the socket emulated? */
|
39 | f0cbd3ec | bellard | |
40 | f0cbd3ec | bellard | u_char so_type; /* Type of socket, UDP or TCP */
|
41 | f0cbd3ec | bellard | int so_state; /* internal state flags SS_*, below */ |
42 | f0cbd3ec | bellard | |
43 | f0cbd3ec | bellard | struct tcpcb *so_tcpcb; /* pointer to TCP protocol control block */ |
44 | f0cbd3ec | bellard | u_int so_expire; /* When the socket will expire */
|
45 | f0cbd3ec | bellard | |
46 | f0cbd3ec | bellard | int so_queued; /* Number of packets queued from this socket */ |
47 | f0cbd3ec | bellard | int so_nqueued; /* Number of packets queued in a row |
48 | f0cbd3ec | bellard | * Used to determine when to "downgrade" a session
|
49 | f0cbd3ec | bellard | * from fastq to batchq */
|
50 | f0cbd3ec | bellard | |
51 | f0cbd3ec | bellard | struct sbuf so_rcv; /* Receive buffer */ |
52 | f0cbd3ec | bellard | struct sbuf so_snd; /* Send buffer */ |
53 | f0cbd3ec | bellard | void * extra; /* Extra pointer */ |
54 | f0cbd3ec | bellard | }; |
55 | f0cbd3ec | bellard | |
56 | f0cbd3ec | bellard | |
57 | f0cbd3ec | bellard | /*
|
58 | f0cbd3ec | bellard | * Socket state bits. (peer means the host on the Internet,
|
59 | f0cbd3ec | bellard | * local host means the host on the other end of the modem)
|
60 | f0cbd3ec | bellard | */
|
61 | f0cbd3ec | bellard | #define SS_NOFDREF 0x001 /* No fd reference */ |
62 | f0cbd3ec | bellard | |
63 | f0cbd3ec | bellard | #define SS_ISFCONNECTING 0x002 /* Socket is connecting to peer (non-blocking connect()'s) */ |
64 | f0cbd3ec | bellard | #define SS_ISFCONNECTED 0x004 /* Socket is connected to peer */ |
65 | f0cbd3ec | bellard | #define SS_FCANTRCVMORE 0x008 /* Socket can't receive more from peer (for half-closes) */ |
66 | f0cbd3ec | bellard | #define SS_FCANTSENDMORE 0x010 /* Socket can't send more to peer (for half-closes) */ |
67 | f0cbd3ec | bellard | /* #define SS_ISFDISCONNECTED 0x020*/ /* Socket has disconnected from peer, in 2MSL state */ |
68 | f0cbd3ec | bellard | #define SS_FWDRAIN 0x040 /* We received a FIN, drain data and set SS_FCANTSENDMORE */ |
69 | f0cbd3ec | bellard | |
70 | f0cbd3ec | bellard | #define SS_CTL 0x080 |
71 | f0cbd3ec | bellard | #define SS_FACCEPTCONN 0x100 /* Socket is accepting connections from a host on the internet */ |
72 | f0cbd3ec | bellard | #define SS_FACCEPTONCE 0x200 /* If set, the SS_FACCEPTCONN socket will die after one accept */ |
73 | f0cbd3ec | bellard | |
74 | f0cbd3ec | bellard | extern struct socket tcb; |
75 | f0cbd3ec | bellard | |
76 | f0cbd3ec | bellard | |
77 | f0cbd3ec | bellard | #if defined(DECLARE_IOVEC) && !defined(HAVE_READV)
|
78 | f0cbd3ec | bellard | struct iovec {
|
79 | f0cbd3ec | bellard | char *iov_base;
|
80 | f0cbd3ec | bellard | size_t iov_len; |
81 | f0cbd3ec | bellard | }; |
82 | f0cbd3ec | bellard | #endif
|
83 | f0cbd3ec | bellard | |
84 | f0cbd3ec | bellard | void so_init _P((void)); |
85 | f0cbd3ec | bellard | struct socket * solookup _P((struct socket *, struct in_addr, u_int, struct in_addr, u_int)); |
86 | f0cbd3ec | bellard | struct socket * socreate _P((void)); |
87 | f0cbd3ec | bellard | void sofree _P((struct socket *)); |
88 | f0cbd3ec | bellard | int soread _P((struct socket *)); |
89 | f0cbd3ec | bellard | void sorecvoob _P((struct socket *)); |
90 | f0cbd3ec | bellard | int sosendoob _P((struct socket *)); |
91 | f0cbd3ec | bellard | int sowrite _P((struct socket *)); |
92 | f0cbd3ec | bellard | void sorecvfrom _P((struct socket *)); |
93 | f0cbd3ec | bellard | int sosendto _P((struct socket *, struct mbuf *)); |
94 | f0cbd3ec | bellard | struct socket * solisten _P((u_int, u_int32_t, u_int, int)); |
95 | f0cbd3ec | bellard | void sorwakeup _P((struct socket *)); |
96 | f0cbd3ec | bellard | void sowwakeup _P((struct socket *)); |
97 | f0cbd3ec | bellard | void soisfconnecting _P((register struct socket *)); |
98 | f0cbd3ec | bellard | void soisfconnected _P((register struct socket *)); |
99 | f0cbd3ec | bellard | void sofcantrcvmore _P((struct socket *)); |
100 | f0cbd3ec | bellard | void sofcantsendmore _P((struct socket *)); |
101 | f0cbd3ec | bellard | void soisfdisconnected _P((struct socket *)); |
102 | f0cbd3ec | bellard | void sofwdrain _P((struct socket *)); |
103 | f0cbd3ec | bellard | |
104 | f0cbd3ec | bellard | #endif /* _SOCKET_H_ */ |