]> Git Repo - qemu.git/blame - slirp/socket.h
pc: acpi: SRAT: create only valid processor lapic entries
[qemu.git] / slirp / socket.h
CommitLineData
f0cbd3ec
FB
1/*
2 * Copyright (c) 1995 Danny Gasparovski.
5fafdf24
TS
3 *
4 * Please read the file COPYRIGHT for the
f0cbd3ec
FB
5 * terms and conditions of the copyright.
6 */
7
f0cbd3ec
FB
8#ifndef _SLIRP_SOCKET_H_
9#define _SLIRP_SOCKET_H_
10
11#define SO_EXPIRE 240000
12#define SO_EXPIREFAST 10000
13
14/*
15 * Our socket structure
16 */
17
18struct socket {
19 struct socket *so_next,*so_prev; /* For a linked list of sockets */
20
21 int s; /* The actual socket */
22
8917c3bd
SH
23 int pollfds_idx; /* GPollFD GArray index */
24
460fec67
JK
25 Slirp *slirp; /* managing slirp instance */
26
f0cbd3ec
FB
27 /* XXX union these with not-yet-used sbuf params */
28 struct mbuf *so_m; /* Pointer to the original SYN packet,
29 * for non-blocking connect()'s, and
30 * PING reply's */
31 struct tcpiphdr *so_ti; /* Pointer to the original ti within
32 * so_mconn, for non-blocking connections */
33 int so_urgc;
eae303ff
GS
34 union { /* foreign host */
35 struct sockaddr_storage ss;
36 struct sockaddr_in sin;
37 } fhost;
38#define so_faddr fhost.sin.sin_addr
39#define so_fport fhost.sin.sin_port
40#define so_ffamily fhost.ss.ss_family
41
42 union { /* local host */
43 struct sockaddr_storage ss;
44 struct sockaddr_in sin;
45 } lhost;
46#define so_laddr lhost.sin.sin_addr
47#define so_lport lhost.sin.sin_port
48#define so_lfamily lhost.ss.ss_family
3b46e624 49
b6dce92e
SW
50 uint8_t so_iptos; /* Type of service */
51 uint8_t so_emu; /* Is the socket emulated? */
3b46e624 52
f0cbd3ec
FB
53 u_char so_type; /* Type of socket, UDP or TCP */
54 int so_state; /* internal state flags SS_*, below */
3b46e624 55
f0cbd3ec
FB
56 struct tcpcb *so_tcpcb; /* pointer to TCP protocol control block */
57 u_int so_expire; /* When the socket will expire */
3b46e624 58
f0cbd3ec
FB
59 int so_queued; /* Number of packets queued from this socket */
60 int so_nqueued; /* Number of packets queued in a row
61 * Used to determine when to "downgrade" a session
62 * from fastq to batchq */
5fafdf24 63
f0cbd3ec
FB
64 struct sbuf so_rcv; /* Receive buffer */
65 struct sbuf so_snd; /* Send buffer */
66 void * extra; /* Extra pointer */
67};
68
69
70/*
71 * Socket state bits. (peer means the host on the Internet,
72 * local host means the host on the other end of the modem)
73 */
74#define SS_NOFDREF 0x001 /* No fd reference */
75
76#define SS_ISFCONNECTING 0x002 /* Socket is connecting to peer (non-blocking connect()'s) */
77#define SS_ISFCONNECTED 0x004 /* Socket is connected to peer */
78#define SS_FCANTRCVMORE 0x008 /* Socket can't receive more from peer (for half-closes) */
79#define SS_FCANTSENDMORE 0x010 /* Socket can't send more to peer (for half-closes) */
f0cbd3ec
FB
80#define SS_FWDRAIN 0x040 /* We received a FIN, drain data and set SS_FCANTSENDMORE */
81
82#define SS_CTL 0x080
83#define SS_FACCEPTCONN 0x100 /* Socket is accepting connections from a host on the internet */
84#define SS_FACCEPTONCE 0x200 /* If set, the SS_FACCEPTCONN socket will die after one accept */
85
f932b6ce 86#define SS_PERSISTENT_MASK 0xf000 /* Unremovable state bits */
6dd5ffb6 87#define SS_HOSTFWD 0x1000 /* Socket describes host->guest forwarding */
4a82347a 88#define SS_INCOMING 0x2000 /* Connection was initiated by a host on the internet */
f932b6ce 89
8a87f121
GS
90static inline int sockaddr_equal(struct sockaddr_storage *a,
91 struct sockaddr_storage *b)
92{
93 if (a->ss_family != b->ss_family) {
94 return 0;
95 }
96
97 switch (a->ss_family) {
98 case AF_INET:
99 {
100 struct sockaddr_in *a4 = (struct sockaddr_in *) a;
101 struct sockaddr_in *b4 = (struct sockaddr_in *) b;
102 return a4->sin_addr.s_addr == b4->sin_addr.s_addr
103 && a4->sin_port == b4->sin_port;
104 }
105 default:
106 g_assert_not_reached();
107 }
108
109 return 0;
110}
111
a5fd24aa 112struct socket *solookup(struct socket **, struct socket *,
8a87f121 113 struct sockaddr_storage *, struct sockaddr_storage *);
a5fd24aa 114struct socket *socreate(Slirp *);
6cb9c6d3
BS
115void sofree(struct socket *);
116int soread(struct socket *);
117void sorecvoob(struct socket *);
118int sosendoob(struct socket *);
119int sowrite(struct socket *);
120void sorecvfrom(struct socket *);
121int sosendto(struct socket *, struct mbuf *);
b6dce92e 122struct socket * tcp_listen(Slirp *, uint32_t, u_int, uint32_t, u_int,
6cb9c6d3
BS
123 int);
124void soisfconnecting(register struct socket *);
125void soisfconnected(register struct socket *);
126void sofwdrain(struct socket *);
b9e82a59 127struct iovec; /* For win32 */
e1c5a2b3
AL
128size_t sopreprbuf(struct socket *so, struct iovec *iov, int *np);
129int soreadbuf(struct socket *so, const char *buf, int size);
f0cbd3ec 130
5379229a
GS
131void sotranslate_out(struct socket *, struct sockaddr_storage *);
132void sotranslate_in(struct socket *, struct sockaddr_storage *);
133void sotranslate_accept(struct socket *);
134
135
f0cbd3ec 136#endif /* _SOCKET_H_ */
This page took 0.766748 seconds and 4 git commands to generate.