slirp: prefer c99 types over BSD kind
Replace: - u_char -> uint8_t - u_short -> uint16_t - u_long -> uint32_t - u_int -> unsigned - caddr_t -> char * Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
This commit is contained in:
		
							parent
							
								
									a9d8b3ec43
								
							
						
					
					
						commit
						d7df0b41dc
					
				@ -240,7 +240,7 @@ end_error:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#define ICMP_MAXDATALEN (IP_MSS-28)
 | 
					#define ICMP_MAXDATALEN (IP_MSS-28)
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
icmp_send_error(struct mbuf *msrc, u_char type, u_char code, int minsize,
 | 
					icmp_send_error(struct mbuf *msrc, uint8_t type, uint8_t code, int minsize,
 | 
				
			||||||
           const char *message)
 | 
					           const char *message)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  unsigned hlen, shlen, s_ip_len;
 | 
					  unsigned hlen, shlen, s_ip_len;
 | 
				
			||||||
@ -388,7 +388,7 @@ icmp_reflect(struct mbuf *m)
 | 
				
			|||||||
     * Strip out original options by copying rest of first
 | 
					     * Strip out original options by copying rest of first
 | 
				
			||||||
     * mbuf's data back, and adjust the IP length.
 | 
					     * mbuf's data back, and adjust the IP length.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    memmove((caddr_t)(ip + 1), (caddr_t)ip + hlen,
 | 
					    memmove((char *)(ip + 1), (char *)ip + hlen,
 | 
				
			||||||
	    (unsigned )(m->m_len - hlen));
 | 
						    (unsigned )(m->m_len - hlen));
 | 
				
			||||||
    hlen -= optlen;
 | 
					    hlen -= optlen;
 | 
				
			||||||
    ip->ip_hl = hlen >> 2;
 | 
					    ip->ip_hl = hlen >> 2;
 | 
				
			||||||
@ -412,7 +412,7 @@ void icmp_receive(struct socket *so)
 | 
				
			|||||||
    struct mbuf *m = so->so_m;
 | 
					    struct mbuf *m = so->so_m;
 | 
				
			||||||
    struct ip *ip = mtod(m, struct ip *);
 | 
					    struct ip *ip = mtod(m, struct ip *);
 | 
				
			||||||
    int hlen = ip->ip_hl << 2;
 | 
					    int hlen = ip->ip_hl << 2;
 | 
				
			||||||
    u_char error_code;
 | 
					    uint8_t error_code;
 | 
				
			||||||
    struct icmp *icp;
 | 
					    struct icmp *icp;
 | 
				
			||||||
    int id, len;
 | 
					    int id, len;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -44,22 +44,22 @@ typedef uint32_t n_time;
 | 
				
			|||||||
 * Structure of an icmp header.
 | 
					 * Structure of an icmp header.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
struct icmp {
 | 
					struct icmp {
 | 
				
			||||||
	u_char	icmp_type;		/* type of message, see below */
 | 
						uint8_t	icmp_type;		/* type of message, see below */
 | 
				
			||||||
	u_char	icmp_code;		/* type sub code */
 | 
						uint8_t	icmp_code;		/* type sub code */
 | 
				
			||||||
	u_short	icmp_cksum;		/* ones complement cksum of struct */
 | 
						uint16_t	icmp_cksum;		/* ones complement cksum of struct */
 | 
				
			||||||
	union {
 | 
						union {
 | 
				
			||||||
		u_char ih_pptr;			/* ICMP_PARAMPROB */
 | 
							uint8_t ih_pptr;			/* ICMP_PARAMPROB */
 | 
				
			||||||
		struct in_addr ih_gwaddr;	/* ICMP_REDIRECT */
 | 
							struct in_addr ih_gwaddr;	/* ICMP_REDIRECT */
 | 
				
			||||||
		struct ih_idseq {
 | 
							struct ih_idseq {
 | 
				
			||||||
			u_short	icd_id;
 | 
								uint16_t	icd_id;
 | 
				
			||||||
			u_short	icd_seq;
 | 
								uint16_t	icd_seq;
 | 
				
			||||||
		} ih_idseq;
 | 
							} ih_idseq;
 | 
				
			||||||
		int ih_void;
 | 
							int ih_void;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */
 | 
							/* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */
 | 
				
			||||||
		struct ih_pmtu {
 | 
							struct ih_pmtu {
 | 
				
			||||||
			u_short ipm_void;
 | 
								uint16_t ipm_void;
 | 
				
			||||||
			u_short ipm_nextmtu;
 | 
								uint16_t ipm_nextmtu;
 | 
				
			||||||
		} ih_pmtu;
 | 
							} ih_pmtu;
 | 
				
			||||||
	} icmp_hun;
 | 
						} icmp_hun;
 | 
				
			||||||
#define	icmp_pptr	icmp_hun.ih_pptr
 | 
					#define	icmp_pptr	icmp_hun.ih_pptr
 | 
				
			||||||
@ -156,7 +156,7 @@ struct icmp {
 | 
				
			|||||||
void icmp_init(Slirp *slirp);
 | 
					void icmp_init(Slirp *slirp);
 | 
				
			||||||
void icmp_cleanup(Slirp *slirp);
 | 
					void icmp_cleanup(Slirp *slirp);
 | 
				
			||||||
void icmp_input(struct mbuf *, int);
 | 
					void icmp_input(struct mbuf *, int);
 | 
				
			||||||
void icmp_send_error(struct mbuf *msrc, u_char type, u_char code, int minsize,
 | 
					void icmp_send_error(struct mbuf *msrc, uint8_t type, uint8_t code, int minsize,
 | 
				
			||||||
                     const char *message);
 | 
					                     const char *message);
 | 
				
			||||||
void icmp_reflect(struct mbuf *);
 | 
					void icmp_reflect(struct mbuf *);
 | 
				
			||||||
void icmp_receive(struct socket *so);
 | 
					void icmp_receive(struct socket *so);
 | 
				
			||||||
 | 
				
			|||||||
@ -458,11 +458,11 @@ ip_stripoptions(register struct mbuf *m, struct mbuf *mopt)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	register int i;
 | 
						register int i;
 | 
				
			||||||
	struct ip *ip = mtod(m, struct ip *);
 | 
						struct ip *ip = mtod(m, struct ip *);
 | 
				
			||||||
	register caddr_t opts;
 | 
						register char *opts;
 | 
				
			||||||
	int olen;
 | 
						int olen;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	olen = (ip->ip_hl<<2) - sizeof (struct ip);
 | 
						olen = (ip->ip_hl<<2) - sizeof (struct ip);
 | 
				
			||||||
	opts = (caddr_t)(ip + 1);
 | 
						opts = (char *)(ip + 1);
 | 
				
			||||||
	i = m->m_len - (sizeof (struct ip) + olen);
 | 
						i = m->m_len - (sizeof (struct ip) + olen);
 | 
				
			||||||
	memcpy(opts, opts  + olen, (unsigned)i);
 | 
						memcpy(opts, opts  + olen, (unsigned)i);
 | 
				
			||||||
	m->m_len -= olen;
 | 
						m->m_len -= olen;
 | 
				
			||||||
 | 
				
			|||||||
@ -8,7 +8,7 @@
 | 
				
			|||||||
#ifndef SLIRP_MAIN_H
 | 
					#ifndef SLIRP_MAIN_H
 | 
				
			||||||
#define SLIRP_MAIN_H
 | 
					#define SLIRP_MAIN_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern u_int curtime;
 | 
					extern unsigned curtime;
 | 
				
			||||||
extern struct in_addr loopback_addr;
 | 
					extern struct in_addr loopback_addr;
 | 
				
			||||||
extern unsigned long loopback_mask;
 | 
					extern unsigned long loopback_mask;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -85,7 +85,7 @@ struct mbuf {
 | 
				
			|||||||
	int	m_size;			/* Size of mbuf, from m_dat or m_ext */
 | 
						int	m_size;			/* Size of mbuf, from m_dat or m_ext */
 | 
				
			||||||
	struct	socket *m_so;
 | 
						struct	socket *m_so;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	caddr_t	m_data;			/* Current location of data */
 | 
						char *m_data;			/* Current location of data */
 | 
				
			||||||
	int	m_len;			/* Amount of data in this mbuf, from m_data */
 | 
						int	m_len;			/* Amount of data in this mbuf, from m_data */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Slirp *slirp;
 | 
						Slirp *slirp;
 | 
				
			||||||
 | 
				
			|||||||
@ -46,7 +46,7 @@ static const uint8_t special_ethaddr[ETH_ALEN] = {
 | 
				
			|||||||
    0x52, 0x55, 0x00, 0x00, 0x00, 0x00
 | 
					    0x52, 0x55, 0x00, 0x00, 0x00, 0x00
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
u_int curtime;
 | 
					unsigned curtime;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static QTAILQ_HEAD(, Slirp) slirp_instances =
 | 
					static QTAILQ_HEAD(, Slirp) slirp_instances =
 | 
				
			||||||
    QTAILQ_HEAD_INITIALIZER(slirp_instances);
 | 
					    QTAILQ_HEAD_INITIALIZER(slirp_instances);
 | 
				
			||||||
@ -55,9 +55,9 @@ static struct in_addr dns_addr;
 | 
				
			|||||||
#ifndef _WIN32
 | 
					#ifndef _WIN32
 | 
				
			||||||
static struct in6_addr dns6_addr;
 | 
					static struct in6_addr dns6_addr;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
static u_int dns_addr_time;
 | 
					static unsigned dns_addr_time;
 | 
				
			||||||
#ifndef _WIN32
 | 
					#ifndef _WIN32
 | 
				
			||||||
static u_int dns6_addr_time;
 | 
					static unsigned dns6_addr_time;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define TIMEOUT_FAST 2  /* milliseconds */
 | 
					#define TIMEOUT_FAST 2  /* milliseconds */
 | 
				
			||||||
@ -92,7 +92,7 @@ int get_dns_addr(struct in_addr *pdns_addr)
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if ((ret = GetNetworkParams(FixedInfo, &BufLen)) != ERROR_SUCCESS) {
 | 
					    if ((ret = GetNetworkParams(FixedInfo, &BufLen)) != ERROR_SUCCESS) {
 | 
				
			||||||
        printf("GetNetworkParams failed. ret = %08x\n", (u_int)ret );
 | 
					        printf("GetNetworkParams failed. ret = %08x\n", (unsigned)ret );
 | 
				
			||||||
        if (FixedInfo) {
 | 
					        if (FixedInfo) {
 | 
				
			||||||
            GlobalFree(FixedInfo);
 | 
					            GlobalFree(FixedInfo);
 | 
				
			||||||
            FixedInfo = NULL;
 | 
					            FixedInfo = NULL;
 | 
				
			||||||
@ -126,7 +126,7 @@ static void winsock_cleanup(void)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static int get_dns_addr_cached(void *pdns_addr, void *cached_addr,
 | 
					static int get_dns_addr_cached(void *pdns_addr, void *cached_addr,
 | 
				
			||||||
                               socklen_t addrlen,
 | 
					                               socklen_t addrlen,
 | 
				
			||||||
                               struct stat *cached_stat, u_int *cached_time)
 | 
					                               struct stat *cached_stat, unsigned *cached_time)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    struct stat old_stat;
 | 
					    struct stat old_stat;
 | 
				
			||||||
    if (curtime - *cached_time < TIMEOUT_DEFAULT) {
 | 
					    if (curtime - *cached_time < TIMEOUT_DEFAULT) {
 | 
				
			||||||
@ -149,7 +149,7 @@ static int get_dns_addr_cached(void *pdns_addr, void *cached_addr,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static int get_dns_addr_resolv_conf(int af, void *pdns_addr, void *cached_addr,
 | 
					static int get_dns_addr_resolv_conf(int af, void *pdns_addr, void *cached_addr,
 | 
				
			||||||
                                    socklen_t addrlen, uint32_t *scope_id,
 | 
					                                    socklen_t addrlen, uint32_t *scope_id,
 | 
				
			||||||
                                    u_int *cached_time)
 | 
					                                    unsigned *cached_time)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    char buff[512];
 | 
					    char buff[512];
 | 
				
			||||||
    char buff2[257];
 | 
					    char buff2[257];
 | 
				
			||||||
 | 
				
			|||||||
@ -12,8 +12,6 @@
 | 
				
			|||||||
#define WIN32_LEAN_AND_MEAN
 | 
					#define WIN32_LEAN_AND_MEAN
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef char *caddr_t;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# include <winsock2.h>
 | 
					# include <winsock2.h>
 | 
				
			||||||
# include <windows.h>
 | 
					# include <windows.h>
 | 
				
			||||||
# include <ws2tcpip.h>
 | 
					# include <ws2tcpip.h>
 | 
				
			||||||
@ -124,8 +122,8 @@ bool ndp_table_search(Slirp *slirp, struct in6_addr ip_addr,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
struct Slirp {
 | 
					struct Slirp {
 | 
				
			||||||
    QTAILQ_ENTRY(Slirp) entry;
 | 
					    QTAILQ_ENTRY(Slirp) entry;
 | 
				
			||||||
    u_int time_fasttimo;
 | 
					    unsigned time_fasttimo;
 | 
				
			||||||
    u_int last_slowtimo;
 | 
					    unsigned last_slowtimo;
 | 
				
			||||||
    bool do_slowtimo;
 | 
					    bool do_slowtimo;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    bool in_enabled, in6_enabled;
 | 
					    bool in_enabled, in6_enabled;
 | 
				
			||||||
@ -245,7 +243,7 @@ int ip6_output(struct socket *, struct mbuf *, int fast);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/* tcp_input.c */
 | 
					/* tcp_input.c */
 | 
				
			||||||
void tcp_input(register struct mbuf *, int, struct socket *, unsigned short af);
 | 
					void tcp_input(register struct mbuf *, int, struct socket *, unsigned short af);
 | 
				
			||||||
int tcp_mss(register struct tcpcb *, u_int);
 | 
					int tcp_mss(register struct tcpcb *, unsigned);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* tcp_output.c */
 | 
					/* tcp_output.c */
 | 
				
			||||||
int tcp_output(register struct tcpcb *);
 | 
					int tcp_output(register struct tcpcb *);
 | 
				
			||||||
 | 
				
			|||||||
@ -506,7 +506,7 @@ sorecvfrom(struct socket *so)
 | 
				
			|||||||
	  /* XXX Check if reply is "correct"? */
 | 
						  /* XXX Check if reply is "correct"? */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	  if(len == -1 || len == 0) {
 | 
						  if(len == -1 || len == 0) {
 | 
				
			||||||
	    u_char code=ICMP_UNREACH_PORT;
 | 
						    uint8_t code=ICMP_UNREACH_PORT;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	    if(errno == EHOSTUNREACH) code=ICMP_UNREACH_HOST;
 | 
						    if(errno == EHOSTUNREACH) code=ICMP_UNREACH_HOST;
 | 
				
			||||||
	    else if(errno == ENETUNREACH) code=ICMP_UNREACH_NET;
 | 
						    else if(errno == ENETUNREACH) code=ICMP_UNREACH_NET;
 | 
				
			||||||
@ -676,8 +676,8 @@ sosendto(struct socket *so, struct mbuf *m)
 | 
				
			|||||||
 * Listen for incoming TCP connections
 | 
					 * Listen for incoming TCP connections
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
struct socket *
 | 
					struct socket *
 | 
				
			||||||
tcp_listen(Slirp *slirp, uint32_t haddr, u_int hport, uint32_t laddr,
 | 
					tcp_listen(Slirp *slirp, uint32_t haddr, unsigned hport, uint32_t laddr,
 | 
				
			||||||
           u_int lport, int flags)
 | 
					           unsigned lport, int flags)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct sockaddr_in addr;
 | 
						struct sockaddr_in addr;
 | 
				
			||||||
	struct socket *so;
 | 
						struct socket *so;
 | 
				
			||||||
 | 
				
			|||||||
@ -61,7 +61,7 @@ struct socket {
 | 
				
			|||||||
  int32_t       so_state;       /* internal state flags SS_*, below */
 | 
					  int32_t       so_state;       /* internal state flags SS_*, below */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  struct 	tcpcb *so_tcpcb;	/* pointer to TCP protocol control block */
 | 
					  struct 	tcpcb *so_tcpcb;	/* pointer to TCP protocol control block */
 | 
				
			||||||
  u_int	so_expire;		/* When the socket will expire */
 | 
					  unsigned	so_expire;		/* When the socket will expire */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  int	so_queued;		/* Number of packets queued from this socket */
 | 
					  int	so_queued;		/* Number of packets queued from this socket */
 | 
				
			||||||
  int	so_nqueued;		/* Number of packets queued in a row
 | 
					  int	so_nqueued;		/* Number of packets queued in a row
 | 
				
			||||||
@ -144,7 +144,7 @@ int sosendoob(struct socket *);
 | 
				
			|||||||
int sowrite(struct socket *);
 | 
					int sowrite(struct socket *);
 | 
				
			||||||
void sorecvfrom(struct socket *);
 | 
					void sorecvfrom(struct socket *);
 | 
				
			||||||
int sosendto(struct socket *, struct mbuf *);
 | 
					int sosendto(struct socket *, struct mbuf *);
 | 
				
			||||||
struct socket * tcp_listen(Slirp *, uint32_t, u_int, uint32_t, u_int,
 | 
					struct socket * tcp_listen(Slirp *, uint32_t, unsigned, uint32_t, unsigned,
 | 
				
			||||||
                               int);
 | 
					                               int);
 | 
				
			||||||
void soisfconnecting(register struct socket *);
 | 
					void soisfconnecting(register struct socket *);
 | 
				
			||||||
void soisfconnected(register struct socket *);
 | 
					void soisfconnected(register struct socket *);
 | 
				
			||||||
 | 
				
			|||||||
@ -76,7 +76,7 @@
 | 
				
			|||||||
	} \
 | 
						} \
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void tcp_dooptions(struct tcpcb *tp, u_char *cp, int cnt,
 | 
					static void tcp_dooptions(struct tcpcb *tp, uint8_t *cp, int cnt,
 | 
				
			||||||
                          struct tcpiphdr *ti);
 | 
					                          struct tcpiphdr *ti);
 | 
				
			||||||
static void tcp_xmit_timer(register struct tcpcb *tp, int rtt);
 | 
					static void tcp_xmit_timer(register struct tcpcb *tp, int rtt);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -197,7 +197,7 @@ tcp_input(struct mbuf *m, int iphlen, struct socket *inso, unsigned short af)
 | 
				
			|||||||
	struct ip save_ip, *ip;
 | 
						struct ip save_ip, *ip;
 | 
				
			||||||
	struct ip6 save_ip6, *ip6;
 | 
						struct ip6 save_ip6, *ip6;
 | 
				
			||||||
	register struct tcpiphdr *ti;
 | 
						register struct tcpiphdr *ti;
 | 
				
			||||||
	caddr_t optp = NULL;
 | 
						char *optp = NULL;
 | 
				
			||||||
	int optlen = 0;
 | 
						int optlen = 0;
 | 
				
			||||||
	int len, tlen, off;
 | 
						int len, tlen, off;
 | 
				
			||||||
        register struct tcpcb *tp = NULL;
 | 
					        register struct tcpcb *tp = NULL;
 | 
				
			||||||
@ -205,7 +205,7 @@ tcp_input(struct mbuf *m, int iphlen, struct socket *inso, unsigned short af)
 | 
				
			|||||||
        struct socket *so = NULL;
 | 
					        struct socket *so = NULL;
 | 
				
			||||||
	int todrop, acked, ourfinisacked, needoutput = 0;
 | 
						int todrop, acked, ourfinisacked, needoutput = 0;
 | 
				
			||||||
	int iss = 0;
 | 
						int iss = 0;
 | 
				
			||||||
	u_long tiwin;
 | 
						uint32_t tiwin;
 | 
				
			||||||
	int ret;
 | 
						int ret;
 | 
				
			||||||
	struct sockaddr_storage lhost, fhost;
 | 
						struct sockaddr_storage lhost, fhost;
 | 
				
			||||||
	struct sockaddr_in *lhost4, *fhost4;
 | 
						struct sockaddr_in *lhost4, *fhost4;
 | 
				
			||||||
@ -327,7 +327,7 @@ tcp_input(struct mbuf *m, int iphlen, struct socket *inso, unsigned short af)
 | 
				
			|||||||
	ti->ti_len = tlen;
 | 
						ti->ti_len = tlen;
 | 
				
			||||||
	if (off > sizeof (struct tcphdr)) {
 | 
						if (off > sizeof (struct tcphdr)) {
 | 
				
			||||||
	  optlen = off - sizeof (struct tcphdr);
 | 
						  optlen = off - sizeof (struct tcphdr);
 | 
				
			||||||
	  optp = mtod(m, caddr_t) + sizeof (struct tcpiphdr);
 | 
						  optp = mtod(m, char *) + sizeof (struct tcpiphdr);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	tiflags = ti->ti_flags;
 | 
						tiflags = ti->ti_flags;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -469,7 +469,7 @@ findso:
 | 
				
			|||||||
	 * else do it below (after getting remote address).
 | 
						 * else do it below (after getting remote address).
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	if (optp && tp->t_state != TCPS_LISTEN)
 | 
						if (optp && tp->t_state != TCPS_LISTEN)
 | 
				
			||||||
		tcp_dooptions(tp, (u_char *)optp, optlen, ti);
 | 
							tcp_dooptions(tp, (uint8_t *)optp, optlen, ti);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * Header prediction: check for the two common cases
 | 
						 * Header prediction: check for the two common cases
 | 
				
			||||||
@ -724,7 +724,7 @@ findso:
 | 
				
			|||||||
	  tcp_template(tp);
 | 
						  tcp_template(tp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	  if (optp)
 | 
						  if (optp)
 | 
				
			||||||
	    tcp_dooptions(tp, (u_char *)optp, optlen, ti);
 | 
						    tcp_dooptions(tp, (uint8_t *)optp, optlen, ti);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	  if (iss)
 | 
						  if (iss)
 | 
				
			||||||
	    tp->iss = iss;
 | 
						    tp->iss = iss;
 | 
				
			||||||
@ -1039,7 +1039,7 @@ trimthenstep6:
 | 
				
			|||||||
					tp->t_dupacks = 0;
 | 
										tp->t_dupacks = 0;
 | 
				
			||||||
				else if (++tp->t_dupacks == TCPREXMTTHRESH) {
 | 
									else if (++tp->t_dupacks == TCPREXMTTHRESH) {
 | 
				
			||||||
					tcp_seq onxt = tp->snd_nxt;
 | 
										tcp_seq onxt = tp->snd_nxt;
 | 
				
			||||||
					u_int win =
 | 
										unsigned win =
 | 
				
			||||||
                                                MIN(tp->snd_wnd, tp->snd_cwnd) /
 | 
					                                                MIN(tp->snd_wnd, tp->snd_cwnd) /
 | 
				
			||||||
                                                2 / tp->t_maxseg;
 | 
					                                                2 / tp->t_maxseg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1108,8 +1108,8 @@ trimthenstep6:
 | 
				
			|||||||
		 * (maxseg^2 / cwnd per packet).
 | 
							 * (maxseg^2 / cwnd per packet).
 | 
				
			||||||
		 */
 | 
							 */
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		  register u_int cw = tp->snd_cwnd;
 | 
							  register unsigned cw = tp->snd_cwnd;
 | 
				
			||||||
		  register u_int incr = tp->t_maxseg;
 | 
							  register unsigned incr = tp->t_maxseg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		  if (cw > tp->snd_ssthresh)
 | 
							  if (cw > tp->snd_ssthresh)
 | 
				
			||||||
		    incr = incr * incr / cw;
 | 
							    incr = incr * incr / cw;
 | 
				
			||||||
@ -1381,7 +1381,7 @@ drop:
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
tcp_dooptions(struct tcpcb *tp, u_char *cp, int cnt, struct tcpiphdr *ti)
 | 
					tcp_dooptions(struct tcpcb *tp, uint8_t *cp, int cnt, struct tcpiphdr *ti)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	uint16_t mss;
 | 
						uint16_t mss;
 | 
				
			||||||
	int opt, optlen;
 | 
						int opt, optlen;
 | 
				
			||||||
@ -1511,7 +1511,7 @@ tcp_xmit_timer(register struct tcpcb *tp, int rtt)
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int
 | 
					int
 | 
				
			||||||
tcp_mss(struct tcpcb *tp, u_int offer)
 | 
					tcp_mss(struct tcpcb *tp, unsigned offer)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct socket *so = tp->t_socket;
 | 
						struct socket *so = tp->t_socket;
 | 
				
			||||||
	int mss;
 | 
						int mss;
 | 
				
			||||||
 | 
				
			|||||||
@ -40,7 +40,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "slirp.h"
 | 
					#include "slirp.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static const u_char  tcp_outflags[TCP_NSTATES] = {
 | 
					static const uint8_t  tcp_outflags[TCP_NSTATES] = {
 | 
				
			||||||
	TH_RST|TH_ACK, 0,      TH_SYN,        TH_SYN|TH_ACK,
 | 
						TH_RST|TH_ACK, 0,      TH_SYN,        TH_SYN|TH_ACK,
 | 
				
			||||||
	TH_ACK,        TH_ACK, TH_FIN|TH_ACK, TH_FIN|TH_ACK,
 | 
						TH_ACK,        TH_ACK, TH_FIN|TH_ACK, TH_FIN|TH_ACK,
 | 
				
			||||||
	TH_FIN|TH_ACK, TH_ACK, TH_ACK,
 | 
						TH_FIN|TH_ACK, TH_ACK, TH_ACK,
 | 
				
			||||||
@ -63,7 +63,7 @@ tcp_output(struct tcpcb *tp)
 | 
				
			|||||||
	register struct tcpiphdr *ti, tcpiph_save;
 | 
						register struct tcpiphdr *ti, tcpiph_save;
 | 
				
			||||||
	struct ip *ip;
 | 
						struct ip *ip;
 | 
				
			||||||
	struct ip6 *ip6;
 | 
						struct ip6 *ip6;
 | 
				
			||||||
	u_char opt[MAX_TCPOPTLEN];
 | 
						uint8_t opt[MAX_TCPOPTLEN];
 | 
				
			||||||
	unsigned optlen, hdrlen;
 | 
						unsigned optlen, hdrlen;
 | 
				
			||||||
	int idle, sendalot;
 | 
						int idle, sendalot;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -271,7 +271,7 @@ send:
 | 
				
			|||||||
			opt[0] = TCPOPT_MAXSEG;
 | 
								opt[0] = TCPOPT_MAXSEG;
 | 
				
			||||||
			opt[1] = 4;
 | 
								opt[1] = 4;
 | 
				
			||||||
			mss = htons((uint16_t) tcp_mss(tp, 0));
 | 
								mss = htons((uint16_t) tcp_mss(tp, 0));
 | 
				
			||||||
			memcpy((caddr_t)(opt + 2), (caddr_t)&mss, sizeof(mss));
 | 
								memcpy((char *)(opt + 2), (char *)&mss, sizeof(mss));
 | 
				
			||||||
			optlen = 4;
 | 
								optlen = 4;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@ -301,7 +301,7 @@ send:
 | 
				
			|||||||
		m->m_data += IF_MAXLINKHDR;
 | 
							m->m_data += IF_MAXLINKHDR;
 | 
				
			||||||
		m->m_len = hdrlen;
 | 
							m->m_len = hdrlen;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		sbcopy(&so->so_snd, off, (int) len, mtod(m, caddr_t) + hdrlen);
 | 
							sbcopy(&so->so_snd, off, (int) len, mtod(m, char *) + hdrlen);
 | 
				
			||||||
		m->m_len += len;
 | 
							m->m_len += len;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/*
 | 
							/*
 | 
				
			||||||
@ -324,7 +324,7 @@ send:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	ti = mtod(m, struct tcpiphdr *);
 | 
						ti = mtod(m, struct tcpiphdr *);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	memcpy((caddr_t)ti, &tp->t_template, sizeof (struct tcpiphdr));
 | 
						memcpy((char *)ti, &tp->t_template, sizeof (struct tcpiphdr));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * Fill in fields, remembering maximum advertised
 | 
						 * Fill in fields, remembering maximum advertised
 | 
				
			||||||
@ -353,7 +353,7 @@ send:
 | 
				
			|||||||
		ti->ti_seq = htonl(tp->snd_max);
 | 
							ti->ti_seq = htonl(tp->snd_max);
 | 
				
			||||||
	ti->ti_ack = htonl(tp->rcv_nxt);
 | 
						ti->ti_ack = htonl(tp->rcv_nxt);
 | 
				
			||||||
	if (optlen) {
 | 
						if (optlen) {
 | 
				
			||||||
		memcpy((caddr_t)(ti + 1), (caddr_t)opt, optlen);
 | 
							memcpy((char *)(ti + 1), (char *)opt, optlen);
 | 
				
			||||||
		ti->ti_off = (sizeof (struct tcphdr) + optlen) >> 2;
 | 
							ti->ti_off = (sizeof (struct tcphdr) + optlen) >> 2;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	ti->ti_flags = flags;
 | 
						ti->ti_flags = flags;
 | 
				
			||||||
 | 
				
			|||||||
@ -163,7 +163,7 @@ tcp_respond(struct tcpcb *tp, struct tcpiphdr *ti, struct mbuf *m,
 | 
				
			|||||||
		 * ti points into m so the next line is just making
 | 
							 * ti points into m so the next line is just making
 | 
				
			||||||
		 * the mbuf point to ti
 | 
							 * the mbuf point to ti
 | 
				
			||||||
		 */
 | 
							 */
 | 
				
			||||||
		m->m_data = (caddr_t)ti;
 | 
							m->m_data = (char *)ti;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		m->m_len = sizeof (struct tcpiphdr);
 | 
							m->m_len = sizeof (struct tcpiphdr);
 | 
				
			||||||
		tlen = 0;
 | 
							tlen = 0;
 | 
				
			||||||
@ -182,7 +182,7 @@ tcp_respond(struct tcpcb *tp, struct tcpiphdr *ti, struct mbuf *m,
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
#undef xchg
 | 
					#undef xchg
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	ti->ti_len = htons((u_short)(sizeof (struct tcphdr) + tlen));
 | 
						ti->ti_len = htons((uint16_t)(sizeof (struct tcphdr) + tlen));
 | 
				
			||||||
	tlen += sizeof (struct tcpiphdr);
 | 
						tlen += sizeof (struct tcpiphdr);
 | 
				
			||||||
	m->m_len = tlen;
 | 
						m->m_len = tlen;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -613,10 +613,10 @@ int
 | 
				
			|||||||
tcp_emu(struct socket *so, struct mbuf *m)
 | 
					tcp_emu(struct socket *so, struct mbuf *m)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	Slirp *slirp = so->slirp;
 | 
						Slirp *slirp = so->slirp;
 | 
				
			||||||
	u_int n1, n2, n3, n4, n5, n6;
 | 
						unsigned n1, n2, n3, n4, n5, n6;
 | 
				
			||||||
        char buff[257];
 | 
					        char buff[257];
 | 
				
			||||||
	uint32_t laddr;
 | 
						uint32_t laddr;
 | 
				
			||||||
	u_int lport;
 | 
						unsigned lport;
 | 
				
			||||||
	char *bptr;
 | 
						char *bptr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	DEBUG_CALL("tcp_emu");
 | 
						DEBUG_CALL("tcp_emu");
 | 
				
			||||||
@ -853,7 +853,7 @@ tcp_emu(struct socket *so, struct mbuf *m)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		bptr = m->m_data;
 | 
							bptr = m->m_data;
 | 
				
			||||||
		while (bptr < m->m_data + m->m_len) {
 | 
							while (bptr < m->m_data + m->m_len) {
 | 
				
			||||||
			u_short p;
 | 
								uint16_t p;
 | 
				
			||||||
			static int ra = 0;
 | 
								static int ra = 0;
 | 
				
			||||||
			char ra_tbl[4];
 | 
								char ra_tbl[4];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -909,8 +909,8 @@ tcp_emu(struct socket *so, struct mbuf *m)
 | 
				
			|||||||
				/* This is the field containing the port
 | 
									/* This is the field containing the port
 | 
				
			||||||
				 * number that RA-player is listening to.
 | 
									 * number that RA-player is listening to.
 | 
				
			||||||
				 */
 | 
									 */
 | 
				
			||||||
				lport = (((u_char*)bptr)[0] << 8)
 | 
									lport = (((uint8_t*)bptr)[0] << 8)
 | 
				
			||||||
				+ ((u_char *)bptr)[1];
 | 
									+ ((uint8_t *)bptr)[1];
 | 
				
			||||||
				if (lport < 6970)
 | 
									if (lport < 6970)
 | 
				
			||||||
				   lport += 256;   /* don't know why */
 | 
									   lport += 256;   /* don't know why */
 | 
				
			||||||
				if (lport < 6970 || lport > 7170)
 | 
									if (lport < 6970 || lport > 7170)
 | 
				
			||||||
@ -928,8 +928,8 @@ tcp_emu(struct socket *so, struct mbuf *m)
 | 
				
			|||||||
				}
 | 
									}
 | 
				
			||||||
				if (p == 7071)
 | 
									if (p == 7071)
 | 
				
			||||||
				   p = 0;
 | 
									   p = 0;
 | 
				
			||||||
				*(u_char *)bptr++ = (p >> 8) & 0xff;
 | 
									*(uint8_t *)bptr++ = (p >> 8) & 0xff;
 | 
				
			||||||
                                *(u_char *)bptr = p & 0xff;
 | 
					                                *(uint8_t *)bptr = p & 0xff;
 | 
				
			||||||
				ra = 0;
 | 
									ra = 0;
 | 
				
			||||||
				return 1;   /* port redirected, we're done */
 | 
									return 1;   /* port redirected, we're done */
 | 
				
			||||||
				break;
 | 
									break;
 | 
				
			||||||
 | 
				
			|||||||
@ -232,7 +232,7 @@ tcp_timers(register struct tcpcb *tp, int timer)
 | 
				
			|||||||
		 * to go below this.)
 | 
							 * to go below this.)
 | 
				
			||||||
		 */
 | 
							 */
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
                u_int win = MIN(tp->snd_wnd, tp->snd_cwnd) / 2 / tp->t_maxseg;
 | 
					                unsigned win = MIN(tp->snd_wnd, tp->snd_cwnd) / 2 / tp->t_maxseg;
 | 
				
			||||||
		if (win < 2)
 | 
							if (win < 2)
 | 
				
			||||||
			win = 2;
 | 
								win = 2;
 | 
				
			||||||
		tp->snd_cwnd = tp->t_maxseg;
 | 
							tp->snd_cwnd = tp->t_maxseg;
 | 
				
			||||||
 | 
				
			|||||||
@ -47,9 +47,9 @@ struct tcpcb {
 | 
				
			|||||||
	short	t_rxtshift;		/* log(2) of rexmt exp. backoff */
 | 
						short	t_rxtshift;		/* log(2) of rexmt exp. backoff */
 | 
				
			||||||
	short	t_rxtcur;		/* current retransmit value */
 | 
						short	t_rxtcur;		/* current retransmit value */
 | 
				
			||||||
	short	t_dupacks;		/* consecutive dup acks recd */
 | 
						short	t_dupacks;		/* consecutive dup acks recd */
 | 
				
			||||||
	u_short	t_maxseg;		/* maximum segment size */
 | 
						uint16_t	t_maxseg;		/* maximum segment size */
 | 
				
			||||||
	uint8_t t_force;		/* 1 if forcing out a byte */
 | 
						uint8_t t_force;		/* 1 if forcing out a byte */
 | 
				
			||||||
	u_short	t_flags;
 | 
						uint16_t	t_flags;
 | 
				
			||||||
#define	TF_ACKNOW	0x0001		/* ack peer immediately */
 | 
					#define	TF_ACKNOW	0x0001		/* ack peer immediately */
 | 
				
			||||||
#define	TF_DELACK	0x0002		/* ack, but try to delay it */
 | 
					#define	TF_DELACK	0x0002		/* ack, but try to delay it */
 | 
				
			||||||
#define	TF_NODELAY	0x0004		/* don't delay packets to coalesce */
 | 
					#define	TF_NODELAY	0x0004		/* don't delay packets to coalesce */
 | 
				
			||||||
@ -105,7 +105,7 @@ struct tcpcb {
 | 
				
			|||||||
	tcp_seq	t_rtseq;		/* sequence number being timed */
 | 
						tcp_seq	t_rtseq;		/* sequence number being timed */
 | 
				
			||||||
	short	t_srtt;			/* smoothed round-trip time */
 | 
						short	t_srtt;			/* smoothed round-trip time */
 | 
				
			||||||
	short	t_rttvar;		/* variance in round-trip time */
 | 
						short	t_rttvar;		/* variance in round-trip time */
 | 
				
			||||||
	u_short	t_rttmin;		/* minimum rtt allowed */
 | 
						uint16_t	t_rttmin;		/* minimum rtt allowed */
 | 
				
			||||||
	uint32_t max_sndwnd;		/* largest window peer has offered */
 | 
						uint32_t max_sndwnd;		/* largest window peer has offered */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* out-of-band data */
 | 
					/* out-of-band data */
 | 
				
			||||||
@ -116,10 +116,10 @@ struct tcpcb {
 | 
				
			|||||||
	short	t_softerror;		/* possible error not yet reported */
 | 
						short	t_softerror;		/* possible error not yet reported */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* RFC 1323 variables */
 | 
					/* RFC 1323 variables */
 | 
				
			||||||
	u_char	snd_scale;		/* window scaling for send window */
 | 
						uint8_t	snd_scale;		/* window scaling for send window */
 | 
				
			||||||
	u_char	rcv_scale;		/* window scaling for recv window */
 | 
						uint8_t	rcv_scale;		/* window scaling for recv window */
 | 
				
			||||||
	u_char	request_r_scale;	/* pending window scaling */
 | 
						uint8_t	request_r_scale;	/* pending window scaling */
 | 
				
			||||||
	u_char	requested_s_scale;
 | 
						uint8_t	requested_s_scale;
 | 
				
			||||||
	uint32_t	ts_recent;		/* timestamp echo data */
 | 
						uint32_t	ts_recent;		/* timestamp echo data */
 | 
				
			||||||
	uint32_t	ts_recent_age;		/* when last updated */
 | 
						uint32_t	ts_recent_age;		/* when last updated */
 | 
				
			||||||
	tcp_seq	last_ack_sent;
 | 
						tcp_seq	last_ack_sent;
 | 
				
			||||||
 | 
				
			|||||||
@ -92,7 +92,7 @@ udp_input(register struct mbuf *m, int iphlen)
 | 
				
			|||||||
	 * Get IP and UDP header together in first mbuf.
 | 
						 * Get IP and UDP header together in first mbuf.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	ip = mtod(m, struct ip *);
 | 
						ip = mtod(m, struct ip *);
 | 
				
			||||||
	uh = (struct udphdr *)((caddr_t)ip + iphlen);
 | 
						uh = (struct udphdr *)((char *)ip + iphlen);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * Make mbuf data length reflect UDP length.
 | 
						 * Make mbuf data length reflect UDP length.
 | 
				
			||||||
@ -319,8 +319,8 @@ udp_tos(struct socket *so)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct socket *
 | 
					struct socket *
 | 
				
			||||||
udp_listen(Slirp *slirp, uint32_t haddr, u_int hport, uint32_t laddr,
 | 
					udp_listen(Slirp *slirp, uint32_t haddr, unsigned hport, uint32_t laddr,
 | 
				
			||||||
           u_int lport, int flags)
 | 
					           unsigned lport, int flags)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct sockaddr_in addr;
 | 
						struct sockaddr_in addr;
 | 
				
			||||||
	struct socket *so;
 | 
						struct socket *so;
 | 
				
			||||||
 | 
				
			|||||||
@ -78,7 +78,7 @@ void udp_cleanup(Slirp *);
 | 
				
			|||||||
void udp_input(register struct mbuf *, int);
 | 
					void udp_input(register struct mbuf *, int);
 | 
				
			||||||
int udp_attach(struct socket *, unsigned short af);
 | 
					int udp_attach(struct socket *, unsigned short af);
 | 
				
			||||||
void udp_detach(struct socket *);
 | 
					void udp_detach(struct socket *);
 | 
				
			||||||
struct socket * udp_listen(Slirp *, uint32_t, u_int, uint32_t, u_int,
 | 
					struct socket * udp_listen(Slirp *, uint32_t, unsigned, uint32_t, unsigned,
 | 
				
			||||||
                           int);
 | 
					                           int);
 | 
				
			||||||
int udp_output(struct socket *so, struct mbuf *m,
 | 
					int udp_output(struct socket *so, struct mbuf *m,
 | 
				
			||||||
                struct sockaddr_in *saddr, struct sockaddr_in *daddr,
 | 
					                struct sockaddr_in *saddr, struct sockaddr_in *daddr,
 | 
				
			||||||
 | 
				
			|||||||
@ -29,7 +29,7 @@
 | 
				
			|||||||
#include <sys/statvfs.h>
 | 
					#include <sys/statvfs.h>
 | 
				
			||||||
/* See MySQL bug #7156 (http://bugs.mysql.com/bug.php?id=7156) for
 | 
					/* See MySQL bug #7156 (http://bugs.mysql.com/bug.php?id=7156) for
 | 
				
			||||||
   discussion about Solaris header problems */
 | 
					   discussion about Solaris header problems */
 | 
				
			||||||
extern int madvise(caddr_t, size_t, int);
 | 
					extern int madvise(char *, size_t, int);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "qemu-common.h"
 | 
					#include "qemu-common.h"
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user