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