Statistics
| Branch: | Revision:

root / slirp / socket.h @ 8b7968f7

History | View | Annotate | Download (3.4 kB)

1 f0cbd3ec bellard
/*
2 f0cbd3ec bellard
 * Copyright (c) 1995 Danny Gasparovski.
3 5fafdf24 ths
 *
4 5fafdf24 ths
 * 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
#ifndef _SLIRP_SOCKET_H_
9 f0cbd3ec bellard
#define _SLIRP_SOCKET_H_
10 f0cbd3ec bellard
11 f0cbd3ec bellard
#define SO_EXPIRE 240000
12 f0cbd3ec bellard
#define SO_EXPIREFAST 10000
13 f0cbd3ec bellard
14 f0cbd3ec bellard
/*
15 f0cbd3ec bellard
 * Our socket structure
16 f0cbd3ec bellard
 */
17 f0cbd3ec bellard
18 f0cbd3ec bellard
struct socket {
19 f0cbd3ec bellard
  struct socket *so_next,*so_prev;      /* For a linked list of sockets */
20 f0cbd3ec bellard
21 f0cbd3ec bellard
  int s;                           /* The actual socket */
22 f0cbd3ec bellard
23 460fec67 Jan Kiszka
  Slirp *slirp;                           /* managing slirp instance */
24 460fec67 Jan Kiszka
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 b6dce92e Stefan Weil
  uint16_t so_fport;                   /* foreign port */
35 b6dce92e Stefan Weil
  uint16_t so_lport;                   /* local port */
36 3b46e624 ths
37 b6dce92e Stefan Weil
  uint8_t        so_iptos;        /* Type of service */
38 b6dce92e Stefan Weil
  uint8_t        so_emu;                /* Is the socket emulated? */
39 3b46e624 ths
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 3b46e624 ths
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 3b46e624 ths
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 5fafdf24 ths
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_FWDRAIN                0x040        /* We received a FIN, drain data and set SS_FCANTSENDMORE */
68 f0cbd3ec bellard
69 f0cbd3ec bellard
#define SS_CTL                        0x080
70 f0cbd3ec bellard
#define SS_FACCEPTCONN                0x100        /* Socket is accepting connections from a host on the internet */
71 f0cbd3ec bellard
#define SS_FACCEPTONCE                0x200        /* If set, the SS_FACCEPTCONN socket will die after one accept */
72 f0cbd3ec bellard
73 f932b6ce Jan Kiszka
#define SS_PERSISTENT_MASK        0xf000        /* Unremovable state bits */
74 6dd5ffb6 Jan Kiszka
#define SS_HOSTFWD                0x1000        /* Socket describes host->guest forwarding */
75 4a82347a Jan Kiszka
#define SS_INCOMING                0x2000        /* Connection was initiated by a host on the internet */
76 f932b6ce Jan Kiszka
77 6cb9c6d3 Blue Swirl
struct socket * solookup(struct socket *, struct in_addr, u_int, struct in_addr, u_int);
78 6cb9c6d3 Blue Swirl
struct socket * socreate(Slirp *);
79 6cb9c6d3 Blue Swirl
void sofree(struct socket *);
80 6cb9c6d3 Blue Swirl
int soread(struct socket *);
81 6cb9c6d3 Blue Swirl
void sorecvoob(struct socket *);
82 6cb9c6d3 Blue Swirl
int sosendoob(struct socket *);
83 6cb9c6d3 Blue Swirl
int sowrite(struct socket *);
84 6cb9c6d3 Blue Swirl
void sorecvfrom(struct socket *);
85 6cb9c6d3 Blue Swirl
int sosendto(struct socket *, struct mbuf *);
86 b6dce92e Stefan Weil
struct socket * tcp_listen(Slirp *, uint32_t, u_int, uint32_t, u_int,
87 6cb9c6d3 Blue Swirl
                               int);
88 6cb9c6d3 Blue Swirl
void soisfconnecting(register struct socket *);
89 6cb9c6d3 Blue Swirl
void soisfconnected(register struct socket *);
90 6cb9c6d3 Blue Swirl
void sofwdrain(struct socket *);
91 b9e82a59 blueswir1
struct iovec; /* For win32 */
92 e1c5a2b3 aliguori
size_t sopreprbuf(struct socket *so, struct iovec *iov, int *np);
93 e1c5a2b3 aliguori
int soreadbuf(struct socket *so, const char *buf, int size);
94 f0cbd3ec bellard
95 f0cbd3ec bellard
#endif /* _SOCKET_H_ */