Annotation of qemu/slirp/slirp.h, revision 1.1.1.7

1.1       root        1: #ifndef __COMMON_H__
                      2: #define __COMMON_H__
                      3: 
1.1.1.2   root        4: #include "config-host.h"
1.1       root        5: #include "slirp_config.h"
                      6: 
                      7: #ifdef _WIN32
                      8: # include <inttypes.h>
                      9: 
                     10: typedef char *caddr_t;
                     11: 
                     12: # include <windows.h>
                     13: # include <winsock2.h>
1.1.1.3   root       14: # include <ws2tcpip.h>
1.1       root       15: # include <sys/timeb.h>
                     16: # include <iphlpapi.h>
                     17: 
                     18: # define EWOULDBLOCK WSAEWOULDBLOCK
                     19: # define EINPROGRESS WSAEINPROGRESS
                     20: # define ENOTCONN WSAENOTCONN
                     21: # define EHOSTUNREACH WSAEHOSTUNREACH
                     22: # define ENETUNREACH WSAENETUNREACH
                     23: # define ECONNREFUSED WSAECONNREFUSED
                     24: #else
                     25: # define ioctlsocket ioctl
                     26: # define closesocket(s) close(s)
1.1.1.7 ! root       27: # if !defined(__HAIKU__)
        !            28: #  define O_BINARY 0
        !            29: # endif
1.1       root       30: #endif
                     31: 
                     32: #include <sys/types.h>
                     33: #ifdef HAVE_SYS_BITYPES_H
                     34: # include <sys/bitypes.h>
                     35: #endif
                     36: 
                     37: #include <sys/time.h>
                     38: 
                     39: #ifdef HAVE_UNISTD_H
                     40: # include <unistd.h>
                     41: #endif
                     42: 
                     43: #ifdef HAVE_STDLIB_H
                     44: # include <stdlib.h>
                     45: #endif
                     46: 
                     47: #include <stdio.h>
                     48: #include <errno.h>
                     49: 
                     50: #ifndef HAVE_MEMMOVE
                     51: #define memmove(x, y, z) bcopy(y, x, z)
                     52: #endif
                     53: 
                     54: #if TIME_WITH_SYS_TIME
                     55: # include <sys/time.h>
                     56: # include <time.h>
                     57: #else
1.1.1.3   root       58: # ifdef HAVE_SYS_TIME_H
1.1       root       59: #  include <sys/time.h>
                     60: # else
                     61: #  include <time.h>
                     62: # endif
                     63: #endif
                     64: 
                     65: #ifdef HAVE_STRING_H
                     66: # include <string.h>
                     67: #else
                     68: # include <strings.h>
                     69: #endif
                     70: 
                     71: #ifndef _WIN32
                     72: #include <sys/uio.h>
                     73: #endif
                     74: 
                     75: #ifndef _WIN32
                     76: #include <netinet/in.h>
                     77: #include <arpa/inet.h>
                     78: #endif
                     79: 
                     80: /* Systems lacking strdup() definition in <string.h>. */
                     81: #if defined(ultrix)
1.1.1.4   root       82: char *strdup(const char *);
1.1       root       83: #endif
                     84: 
                     85: /* Systems lacking malloc() definition in <stdlib.h>. */
                     86: #if defined(ultrix) || defined(hcx)
1.1.1.4   root       87: void *malloc(size_t arg);
                     88: void free(void *ptr);
1.1       root       89: #endif
                     90: 
                     91: #ifndef HAVE_INET_ATON
1.1.1.4   root       92: int inet_aton(const char *cp, struct in_addr *ia);
1.1       root       93: #endif
                     94: 
                     95: #include <fcntl.h>
                     96: #ifndef NO_UNIX_SOCKETS
                     97: #include <sys/un.h>
                     98: #endif
                     99: #include <signal.h>
                    100: #ifdef HAVE_SYS_SIGNAL_H
                    101: # include <sys/signal.h>
                    102: #endif
                    103: #ifndef _WIN32
                    104: #include <sys/socket.h>
                    105: #endif
                    106: 
                    107: #if defined(HAVE_SYS_IOCTL_H)
                    108: # include <sys/ioctl.h>
                    109: #endif
                    110: 
                    111: #ifdef HAVE_SYS_SELECT_H
                    112: # include <sys/select.h>
                    113: #endif
                    114: 
                    115: #ifdef HAVE_SYS_WAIT_H
                    116: # include <sys/wait.h>
                    117: #endif
                    118: 
                    119: #ifdef HAVE_SYS_FILIO_H
                    120: # include <sys/filio.h>
                    121: #endif
                    122: 
                    123: #ifdef USE_PPP
                    124: #include <ppp/slirppp.h>
                    125: #endif
                    126: 
                    127: #ifdef __STDC__
                    128: #include <stdarg.h>
                    129: #else
                    130: #include <varargs.h>
                    131: #endif
                    132: 
                    133: #include <sys/stat.h>
                    134: 
                    135: /* Avoid conflicting with the libc insque() and remque(), which
                    136:    have different prototypes. */
                    137: #define insque slirp_insque
                    138: #define remque slirp_remque
                    139: 
                    140: #ifdef HAVE_SYS_STROPTS_H
                    141: #include <sys/stropts.h>
                    142: #endif
                    143: 
                    144: #include "debug.h"
                    145: 
1.1.1.5   root      146: #include "qemu-queue.h"
1.1.1.4   root      147: 
                    148: #include "libslirp.h"
1.1       root      149: #include "ip.h"
                    150: #include "tcp.h"
                    151: #include "tcp_timer.h"
                    152: #include "tcp_var.h"
                    153: #include "tcpip.h"
                    154: #include "udp.h"
                    155: #include "mbuf.h"
                    156: #include "sbuf.h"
                    157: #include "socket.h"
                    158: #include "if.h"
                    159: #include "main.h"
                    160: #include "misc.h"
                    161: #ifdef USE_PPP
                    162: #include "ppp/pppd.h"
                    163: #include "ppp/ppp.h"
                    164: #endif
                    165: 
                    166: #include "bootp.h"
                    167: #include "tftp.h"
                    168: 
1.1.1.5   root      169: /* osdep.c */
                    170: int qemu_socket(int domain, int type, int protocol);
                    171: 
                    172: 
1.1.1.4   root      173: struct Slirp {
1.1.1.5   root      174:     QTAILQ_ENTRY(Slirp) entry;
1.1.1.4   root      175: 
                    176:     /* virtual network configuration */
                    177:     struct in_addr vnetwork_addr;
                    178:     struct in_addr vnetwork_mask;
                    179:     struct in_addr vhost_addr;
                    180:     struct in_addr vdhcp_startaddr;
                    181:     struct in_addr vnameserver_addr;
                    182: 
                    183:     /* ARP cache for the guest IP addresses (XXX: allow many entries) */
                    184:     uint8_t client_ethaddr[6];
                    185: 
                    186:     struct in_addr client_ipaddr;
                    187:     char client_hostname[33];
                    188: 
                    189:     int restricted;
                    190:     struct timeval tt;
                    191:     struct ex_list *exec_list;
                    192: 
                    193:     /* mbuf states */
                    194:     struct mbuf m_freelist, m_usedlist;
                    195:     int mbuf_alloced;
                    196: 
                    197:     /* if states */
                    198:     int if_queued;          /* number of packets queued so far */
                    199:     struct mbuf if_fastq;   /* fast queue (for interactive data) */
                    200:     struct mbuf if_batchq;  /* queue for non-interactive data */
                    201:     struct mbuf *next_m;    /* pointer to next mbuf to output */
                    202: 
                    203:     /* ip states */
                    204:     struct ipq ipq;         /* ip reass. queue */
1.1.1.6   root      205:     uint16_t ip_id;         /* ip packet ctr, for ids */
1.1.1.4   root      206: 
                    207:     /* bootp/dhcp states */
                    208:     BOOTPClient bootp_clients[NB_BOOTP_CLIENTS];
                    209:     char *bootp_filename;
                    210: 
                    211:     /* tcp states */
                    212:     struct socket tcb;
                    213:     struct socket *tcp_last_so;
                    214:     tcp_seq tcp_iss;        /* tcp initial send seq # */
1.1.1.6   root      215:     uint32_t tcp_now;       /* for RFC 1323 timestamps */
1.1.1.4   root      216: 
                    217:     /* udp states */
                    218:     struct socket udb;
                    219:     struct socket *udp_last_so;
                    220: 
                    221:     /* tftp states */
                    222:     char *tftp_prefix;
                    223:     struct tftp_session tftp_sessions[TFTP_SESSIONS_MAX];
                    224: 
                    225:     void *opaque;
                    226: };
                    227: 
                    228: extern Slirp *slirp_instance;
1.1       root      229: 
                    230: #ifndef NULL
                    231: #define NULL (void *)0
                    232: #endif
                    233: 
                    234: #ifndef FULL_BOLT
1.1.1.4   root      235: void if_start(Slirp *);
1.1       root      236: #else
1.1.1.4   root      237: void if_start(struct ttys *);
1.1       root      238: #endif
                    239: 
                    240: #ifndef HAVE_STRERROR
1.1.1.7 ! root      241:  char *strerror(int error);
1.1       root      242: #endif
                    243: 
                    244: #ifndef HAVE_INDEX
1.1.1.4   root      245:  char *index(const char *, int);
1.1       root      246: #endif
                    247: 
                    248: #ifndef HAVE_GETHOSTID
1.1.1.4   root      249:  long gethostid(void);
1.1       root      250: #endif
                    251: 
1.1.1.7 ! root      252: void lprint(const char *, ...) GCC_FMT_ATTR(1, 2);
1.1       root      253: 
                    254: #ifndef _WIN32
                    255: #include <netdb.h>
                    256: #endif
                    257: 
                    258: #define DEFAULT_BAUD 115200
                    259: 
1.1.1.2   root      260: #define SO_OPTIONS DO_KEEPALIVE
                    261: #define TCP_MAXIDLE (TCPTV_KEEPCNT * TCPTV_KEEPINTVL)
                    262: 
1.1       root      263: /* cksum.c */
                    264: int cksum(struct mbuf *m, int len);
                    265: 
                    266: /* if.c */
1.1.1.4   root      267: void if_init(Slirp *);
                    268: void if_output(struct socket *, struct mbuf *);
1.1       root      269: 
                    270: /* ip_input.c */
1.1.1.4   root      271: void ip_init(Slirp *);
                    272: void ip_input(struct mbuf *);
                    273: void ip_slowtimo(Slirp *);
                    274: void ip_stripoptions(register struct mbuf *, struct mbuf *);
1.1       root      275: 
                    276: /* ip_output.c */
1.1.1.4   root      277: int ip_output(struct socket *, struct mbuf *);
1.1       root      278: 
                    279: /* tcp_input.c */
1.1.1.4   root      280: void tcp_input(register struct mbuf *, int, struct socket *);
                    281: int tcp_mss(register struct tcpcb *, u_int);
1.1       root      282: 
                    283: /* tcp_output.c */
1.1.1.4   root      284: int tcp_output(register struct tcpcb *);
                    285: void tcp_setpersist(register struct tcpcb *);
1.1       root      286: 
                    287: /* tcp_subr.c */
1.1.1.4   root      288: void tcp_init(Slirp *);
                    289: void tcp_template(struct tcpcb *);
                    290: void tcp_respond(struct tcpcb *, register struct tcpiphdr *, register struct mbuf *, tcp_seq, tcp_seq, int);
                    291: struct tcpcb * tcp_newtcpcb(struct socket *);
                    292: struct tcpcb * tcp_close(register struct tcpcb *);
                    293: void tcp_sockclosed(struct tcpcb *);
                    294: int tcp_fconnect(struct socket *);
                    295: void tcp_connect(struct socket *);
                    296: int tcp_attach(struct socket *);
1.1.1.6   root      297: uint8_t tcp_tos(struct socket *);
1.1.1.4   root      298: int tcp_emu(struct socket *, struct mbuf *);
                    299: int tcp_ctl(struct socket *);
1.1       root      300: struct tcpcb *tcp_drop(struct tcpcb *tp, int err);
                    301: 
                    302: #ifdef USE_PPP
                    303: #define MIN_MRU MINMRU
                    304: #define MAX_MRU MAXMRU
                    305: #else
                    306: #define MIN_MRU 128
                    307: #define MAX_MRU 16384
                    308: #endif
                    309: 
                    310: #ifndef _WIN32
                    311: #define min(x,y) ((x) < (y) ? (x) : (y))
                    312: #define max(x,y) ((x) > (y) ? (x) : (y))
                    313: #endif
                    314: 
                    315: #ifdef _WIN32
                    316: #undef errno
                    317: #define errno (WSAGetLastError())
                    318: #endif
                    319: 
                    320: #endif

unix.superglobalmegacorp.com