Revision b6dce92e
b/slirp/cksum.c | ||
---|---|---|
47 | 47 |
|
48 | 48 |
int cksum(struct mbuf *m, int len) |
49 | 49 |
{ |
50 |
register u_int16_t *w;
|
|
50 |
register uint16_t *w; |
|
51 | 51 |
register int sum = 0; |
52 | 52 |
register int mlen = 0; |
53 | 53 |
int byte_swapped = 0; |
54 | 54 |
|
55 | 55 |
union { |
56 |
u_int8_t c[2];
|
|
57 |
u_int16_t s;
|
|
56 |
uint8_t c[2];
|
|
57 |
uint16_t s;
|
|
58 | 58 |
} s_util; |
59 | 59 |
union { |
60 |
u_int16_t s[2];
|
|
61 |
u_int32_t l;
|
|
60 |
uint16_t s[2]; |
|
61 |
uint32_t l; |
|
62 | 62 |
} l_util; |
63 | 63 |
|
64 | 64 |
if (m->m_len == 0) |
65 | 65 |
goto cont; |
66 |
w = mtod(m, u_int16_t *);
|
|
66 |
w = mtod(m, uint16_t *); |
|
67 | 67 |
|
68 | 68 |
mlen = m->m_len; |
69 | 69 |
|
... | ... | |
78 | 78 |
if ((1 & (long) w) && (mlen > 0)) { |
79 | 79 |
REDUCE; |
80 | 80 |
sum <<= 8; |
81 |
s_util.c[0] = *(u_int8_t *)w;
|
|
82 |
w = (u_int16_t *)((int8_t *)w + 1);
|
|
81 |
s_util.c[0] = *(uint8_t *)w; |
|
82 |
w = (uint16_t *)((int8_t *)w + 1); |
|
83 | 83 |
mlen--; |
84 | 84 |
byte_swapped = 1; |
85 | 85 |
} |
... | ... | |
111 | 111 |
REDUCE; |
112 | 112 |
sum <<= 8; |
113 | 113 |
if (mlen == -1) { |
114 |
s_util.c[1] = *(u_int8_t *)w;
|
|
114 |
s_util.c[1] = *(uint8_t *)w; |
|
115 | 115 |
sum += s_util.s; |
116 | 116 |
mlen = 0; |
117 | 117 |
} else |
118 | 118 |
|
119 | 119 |
mlen = -1; |
120 | 120 |
} else if (mlen == -1) |
121 |
s_util.c[0] = *(u_int8_t *)w;
|
|
121 |
s_util.c[0] = *(uint8_t *)w; |
|
122 | 122 |
|
123 | 123 |
cont: |
124 | 124 |
#ifdef DEBUG |
b/slirp/ip.h | ||
---|---|---|
51 | 51 |
# define NTOHL(d) ((d) = ntohl((d))) |
52 | 52 |
# endif |
53 | 53 |
# ifndef NTOHS |
54 |
# define NTOHS(d) ((d) = ntohs((u_int16_t)(d)))
|
|
54 |
# define NTOHS(d) ((d) = ntohs((uint16_t)(d))) |
|
55 | 55 |
# endif |
56 | 56 |
# ifndef HTONL |
57 | 57 |
# define HTONL(d) ((d) = htonl((d))) |
58 | 58 |
# endif |
59 | 59 |
# ifndef HTONS |
60 |
# define HTONS(d) ((d) = htons((u_int16_t)(d)))
|
|
60 |
# define HTONS(d) ((d) = htons((uint16_t)(d))) |
|
61 | 61 |
# endif |
62 | 62 |
#endif |
63 | 63 |
|
64 |
typedef u_int32_t n_long; /* long as received from the net */
|
|
64 |
typedef uint32_t n_long; /* long as received from the net */ |
|
65 | 65 |
|
66 | 66 |
/* |
67 | 67 |
* Definitions for internet protocol version 4. |
... | ... | |
80 | 80 |
u_int ip_hl:4, /* header length */ |
81 | 81 |
ip_v:4; /* version */ |
82 | 82 |
#endif |
83 |
u_int8_t ip_tos; /* type of service */
|
|
84 |
u_int16_t ip_len; /* total length */
|
|
85 |
u_int16_t ip_id; /* identification */
|
|
86 |
u_int16_t ip_off; /* fragment offset field */
|
|
83 |
uint8_t ip_tos; /* type of service */
|
|
84 |
uint16_t ip_len; /* total length */ |
|
85 |
uint16_t ip_id; /* identification */ |
|
86 |
uint16_t ip_off; /* fragment offset field */ |
|
87 | 87 |
#define IP_DF 0x4000 /* don't fragment flag */ |
88 | 88 |
#define IP_MF 0x2000 /* more fragments flag */ |
89 | 89 |
#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */ |
90 |
u_int8_t ip_ttl; /* time to live */
|
|
91 |
u_int8_t ip_p; /* protocol */
|
|
92 |
u_int16_t ip_sum; /* checksum */
|
|
90 |
uint8_t ip_ttl; /* time to live */ |
|
91 |
uint8_t ip_p; /* protocol */ |
|
92 |
uint16_t ip_sum; /* checksum */ |
|
93 | 93 |
struct in_addr ip_src,ip_dst; /* source and dest address */ |
94 | 94 |
} __attribute__((packed)); |
95 | 95 |
|
... | ... | |
136 | 136 |
* Time stamp option structure. |
137 | 137 |
*/ |
138 | 138 |
struct ip_timestamp { |
139 |
u_int8_t ipt_code; /* IPOPT_TS */
|
|
140 |
u_int8_t ipt_len; /* size of structure (variable) */
|
|
141 |
u_int8_t ipt_ptr; /* index of current entry */
|
|
139 |
uint8_t ipt_code; /* IPOPT_TS */ |
|
140 |
uint8_t ipt_len; /* size of structure (variable) */ |
|
141 |
uint8_t ipt_ptr; /* index of current entry */ |
|
142 | 142 |
#ifdef HOST_WORDS_BIGENDIAN |
143 | 143 |
u_int ipt_oflw:4, /* overflow counter */ |
144 | 144 |
ipt_flg:4; /* flags, see below */ |
... | ... | |
198 | 198 |
*/ |
199 | 199 |
struct ipovly { |
200 | 200 |
struct mbuf_ptr ih_mbuf; /* backpointer to mbuf */ |
201 |
u_int8_t ih_x1; /* (unused) */
|
|
202 |
u_int8_t ih_pr; /* protocol */
|
|
203 |
u_int16_t ih_len; /* protocol length */
|
|
201 |
uint8_t ih_x1; /* (unused) */ |
|
202 |
uint8_t ih_pr; /* protocol */ |
|
203 |
uint16_t ih_len; /* protocol length */ |
|
204 | 204 |
struct in_addr ih_src; /* source internet address */ |
205 | 205 |
struct in_addr ih_dst; /* destination internet address */ |
206 | 206 |
} __attribute__((packed)); |
... | ... | |
215 | 215 |
struct ipq { |
216 | 216 |
struct qlink frag_link; /* to ip headers of fragments */ |
217 | 217 |
struct qlink ip_link; /* to other reass headers */ |
218 |
u_int8_t ipq_ttl; /* time for reass q to live */
|
|
219 |
u_int8_t ipq_p; /* protocol of this fragment */
|
|
220 |
u_int16_t ipq_id; /* sequence id for reassembly */
|
|
218 |
uint8_t ipq_ttl; /* time for reass q to live */ |
|
219 |
uint8_t ipq_p; /* protocol of this fragment */ |
|
220 |
uint16_t ipq_id; /* sequence id for reassembly */ |
|
221 | 221 |
struct in_addr ipq_src,ipq_dst; |
222 | 222 |
} __attribute__((packed)); |
223 | 223 |
|
... | ... | |
235 | 235 |
#define ipf_tos ipf_ip.ip_tos |
236 | 236 |
#define ipf_len ipf_ip.ip_len |
237 | 237 |
#define ipf_next ipf_link.next |
238 |
#define ipf_prev ipf_link.prev
|
|
238 |
#define ipf_prev ipf_link.prev |
|
239 | 239 |
|
240 | 240 |
/* |
241 | 241 |
* Structure stored in mbuf in inpcb.ip_options |
b/slirp/ip_icmp.h | ||
---|---|---|
38 | 38 |
* Per RFC 792, September 1981. |
39 | 39 |
*/ |
40 | 40 |
|
41 |
typedef u_int32_t n_time;
|
|
41 |
typedef uint32_t n_time; |
|
42 | 42 |
|
43 | 43 |
/* |
44 | 44 |
* Structure of an icmp header. |
b/slirp/ip_input.c | ||
---|---|---|
477 | 477 |
register struct in_ifaddr *ia; |
478 | 478 |
int opt, optlen, cnt, off, code, type, forward = 0; |
479 | 479 |
struct in_addr *sin, dst; |
480 |
typedef u_int32_t n_time;
|
|
480 |
typedef uint32_t n_time; |
|
481 | 481 |
n_time ntime; |
482 | 482 |
|
483 | 483 |
dst = ip->ip_dst; |
b/slirp/ip_output.c | ||
---|---|---|
75 | 75 |
/* |
76 | 76 |
* If small enough for interface, can just send directly. |
77 | 77 |
*/ |
78 |
if ((u_int16_t)ip->ip_len <= IF_MTU) {
|
|
79 |
ip->ip_len = htons((u_int16_t)ip->ip_len);
|
|
80 |
ip->ip_off = htons((u_int16_t)ip->ip_off);
|
|
78 |
if ((uint16_t)ip->ip_len <= IF_MTU) { |
|
79 |
ip->ip_len = htons((uint16_t)ip->ip_len); |
|
80 |
ip->ip_off = htons((uint16_t)ip->ip_off); |
|
81 | 81 |
ip->ip_sum = 0; |
82 | 82 |
ip->ip_sum = cksum(m, hlen); |
83 | 83 |
|
... | ... | |
110 | 110 |
*/ |
111 | 111 |
m0 = m; |
112 | 112 |
mhlen = sizeof (struct ip); |
113 |
for (off = hlen + len; off < (u_int16_t)ip->ip_len; off += len) {
|
|
113 |
for (off = hlen + len; off < (uint16_t)ip->ip_len; off += len) { |
|
114 | 114 |
register struct ip *mhip; |
115 | 115 |
m = m_get(slirp); |
116 | 116 |
if (m == NULL) { |
... | ... | |
125 | 125 |
mhip->ip_off = ((off - hlen) >> 3) + (ip->ip_off & ~IP_MF); |
126 | 126 |
if (ip->ip_off & IP_MF) |
127 | 127 |
mhip->ip_off |= IP_MF; |
128 |
if (off + len >= (u_int16_t)ip->ip_len)
|
|
129 |
len = (u_int16_t)ip->ip_len - off;
|
|
128 |
if (off + len >= (uint16_t)ip->ip_len) |
|
129 |
len = (uint16_t)ip->ip_len - off; |
|
130 | 130 |
else |
131 | 131 |
mhip->ip_off |= IP_MF; |
132 |
mhip->ip_len = htons((u_int16_t)(len + mhlen));
|
|
132 |
mhip->ip_len = htons((uint16_t)(len + mhlen)); |
|
133 | 133 |
|
134 | 134 |
if (m_copy(m, m0, off, len) < 0) { |
135 | 135 |
error = -1; |
136 | 136 |
goto sendorfree; |
137 | 137 |
} |
138 | 138 |
|
139 |
mhip->ip_off = htons((u_int16_t)mhip->ip_off);
|
|
139 |
mhip->ip_off = htons((uint16_t)mhip->ip_off); |
|
140 | 140 |
mhip->ip_sum = 0; |
141 | 141 |
mhip->ip_sum = cksum(m, mhlen); |
142 | 142 |
*mnext = m; |
... | ... | |
147 | 147 |
* and updating header, then send each fragment (in order). |
148 | 148 |
*/ |
149 | 149 |
m = m0; |
150 |
m_adj(m, hlen + firstlen - (u_int16_t)ip->ip_len);
|
|
151 |
ip->ip_len = htons((u_int16_t)m->m_len);
|
|
152 |
ip->ip_off = htons((u_int16_t)(ip->ip_off | IP_MF));
|
|
150 |
m_adj(m, hlen + firstlen - (uint16_t)ip->ip_len); |
|
151 |
ip->ip_len = htons((uint16_t)m->m_len); |
|
152 |
ip->ip_off = htons((uint16_t)(ip->ip_off | IP_MF)); |
|
153 | 153 |
ip->ip_sum = 0; |
154 | 154 |
ip->ip_sum = cksum(m, hlen); |
155 | 155 |
sendorfree: |
b/slirp/main.h | ||
---|---|---|
14 | 14 |
extern int slirp_socket; |
15 | 15 |
extern int slirp_socket_unit; |
16 | 16 |
extern int slirp_socket_port; |
17 |
extern u_int32_t slirp_socket_addr;
|
|
17 |
extern uint32_t slirp_socket_addr; |
|
18 | 18 |
extern char *slirp_socket_passwd; |
19 | 19 |
extern int ctty_closed; |
20 | 20 |
|
b/slirp/misc.h | ||
---|---|---|
37 | 37 |
#define EMU_NOCONNECT 0x10 /* Don't connect */ |
38 | 38 |
|
39 | 39 |
struct tos_t { |
40 |
u_int16_t lport;
|
|
41 |
u_int16_t fport;
|
|
42 |
u_int8_t tos;
|
|
43 |
u_int8_t emu;
|
|
40 |
uint16_t lport;
|
|
41 |
uint16_t fport;
|
|
42 |
uint8_t tos;
|
|
43 |
uint8_t emu;
|
|
44 | 44 |
}; |
45 | 45 |
|
46 | 46 |
struct emu_t { |
47 |
u_int16_t lport;
|
|
48 |
u_int16_t fport;
|
|
49 |
u_int8_t tos;
|
|
50 |
u_int8_t emu;
|
|
51 |
struct emu_t *next;
|
|
47 |
uint16_t lport;
|
|
48 |
uint16_t fport;
|
|
49 |
uint8_t tos;
|
|
50 |
uint8_t emu;
|
|
51 |
struct emu_t *next;
|
|
52 | 52 |
}; |
53 | 53 |
|
54 | 54 |
extern int x_port, x_server, x_display; |
55 | 55 |
|
56 | 56 |
int show_x(char *, struct socket *); |
57 |
void redir_x(u_int32_t, int, int, int);
|
|
57 |
void redir_x(uint32_t, int, int, int); |
|
58 | 58 |
void slirp_insque(void *, void *); |
59 | 59 |
void slirp_remque(void *); |
60 | 60 |
int add_exec(struct ex_list **, int, char *, struct in_addr, int); |
b/slirp/slirp.h | ||
---|---|---|
233 | 233 |
|
234 | 234 |
/* ip states */ |
235 | 235 |
struct ipq ipq; /* ip reass. queue */ |
236 |
u_int16_t ip_id; /* ip packet ctr, for ids */
|
|
236 |
uint16_t ip_id; /* ip packet ctr, for ids */
|
|
237 | 237 |
|
238 | 238 |
/* bootp/dhcp states */ |
239 | 239 |
BOOTPClient bootp_clients[NB_BOOTP_CLIENTS]; |
... | ... | |
243 | 243 |
struct socket tcb; |
244 | 244 |
struct socket *tcp_last_so; |
245 | 245 |
tcp_seq tcp_iss; /* tcp initial send seq # */ |
246 |
u_int32_t tcp_now; /* for RFC 1323 timestamps */
|
|
246 |
uint32_t tcp_now; /* for RFC 1323 timestamps */
|
|
247 | 247 |
|
248 | 248 |
/* udp states */ |
249 | 249 |
struct socket udb; |
... | ... | |
339 | 339 |
int tcp_fconnect(struct socket *); |
340 | 340 |
void tcp_connect(struct socket *); |
341 | 341 |
int tcp_attach(struct socket *); |
342 |
u_int8_t tcp_tos(struct socket *);
|
|
342 |
uint8_t tcp_tos(struct socket *); |
|
343 | 343 |
int tcp_emu(struct socket *, struct mbuf *); |
344 | 344 |
int tcp_ctl(struct socket *); |
345 | 345 |
struct tcpcb *tcp_drop(struct tcpcb *tp, int err); |
b/slirp/slirp_config.h | ||
---|---|---|
133 | 133 |
/* Define if your compiler doesn't like prototypes */ |
134 | 134 |
#undef NO_PROTOTYPES |
135 | 135 |
|
136 |
/* Define if you don't have u_int32_t etc. typedef'd */ |
|
137 |
#undef NEED_TYPEDEFS |
|
138 |
#ifdef __sun__ |
|
139 |
#define NEED_TYPEDEFS |
|
140 |
#endif |
|
141 |
|
|
142 | 136 |
/* Define to sizeof(char) */ |
143 | 137 |
#define SIZEOF_CHAR 1 |
144 | 138 |
|
b/slirp/socket.c | ||
---|---|---|
580 | 580 |
* Listen for incoming TCP connections |
581 | 581 |
*/ |
582 | 582 |
struct socket * |
583 |
tcp_listen(Slirp *slirp, u_int32_t haddr, u_int hport, u_int32_t laddr,
|
|
583 |
tcp_listen(Slirp *slirp, uint32_t haddr, u_int hport, uint32_t laddr,
|
|
584 | 584 |
u_int lport, int flags) |
585 | 585 |
{ |
586 | 586 |
struct sockaddr_in addr; |
b/slirp/socket.h | ||
---|---|---|
31 | 31 |
int so_urgc; |
32 | 32 |
struct in_addr so_faddr; /* foreign host table entry */ |
33 | 33 |
struct in_addr so_laddr; /* local host table entry */ |
34 |
u_int16_t so_fport; /* foreign port */
|
|
35 |
u_int16_t so_lport; /* local port */
|
|
34 |
uint16_t so_fport; /* foreign port */ |
|
35 |
uint16_t so_lport; /* local port */ |
|
36 | 36 |
|
37 |
u_int8_t so_iptos; /* Type of service */
|
|
38 |
u_int8_t so_emu; /* Is the socket emulated? */
|
|
37 |
uint8_t so_iptos; /* Type of service */ |
|
38 |
uint8_t so_emu; /* Is the socket emulated? */ |
|
39 | 39 |
|
40 | 40 |
u_char so_type; /* Type of socket, UDP or TCP */ |
41 | 41 |
int so_state; /* internal state flags SS_*, below */ |
... | ... | |
83 | 83 |
int sowrite(struct socket *); |
84 | 84 |
void sorecvfrom(struct socket *); |
85 | 85 |
int sosendto(struct socket *, struct mbuf *); |
86 |
struct socket * tcp_listen(Slirp *, u_int32_t, u_int, u_int32_t, u_int,
|
|
86 |
struct socket * tcp_listen(Slirp *, uint32_t, u_int, uint32_t, u_int,
|
|
87 | 87 |
int); |
88 | 88 |
void soisfconnecting(register struct socket *); |
89 | 89 |
void soisfconnected(register struct socket *); |
b/slirp/tcp.h | ||
---|---|---|
33 | 33 |
#ifndef _TCP_H_ |
34 | 34 |
#define _TCP_H_ |
35 | 35 |
|
36 |
typedef u_int32_t tcp_seq;
|
|
36 |
typedef uint32_t tcp_seq;
|
|
37 | 37 |
|
38 | 38 |
#define PR_SLOWHZ 2 /* 2 slow timeouts per second (approx) */ |
39 | 39 |
#define PR_FASTHZ 5 /* 5 fast timeouts per second (not important) */ |
... | ... | |
46 | 46 |
* Per RFC 793, September, 1981. |
47 | 47 |
*/ |
48 | 48 |
struct tcphdr { |
49 |
u_int16_t th_sport; /* source port */
|
|
50 |
u_int16_t th_dport; /* destination port */
|
|
49 |
uint16_t th_sport; /* source port */
|
|
50 |
uint16_t th_dport; /* destination port */
|
|
51 | 51 |
tcp_seq th_seq; /* sequence number */ |
52 | 52 |
tcp_seq th_ack; /* acknowledgement number */ |
53 | 53 |
#ifdef HOST_WORDS_BIGENDIAN |
... | ... | |
57 | 57 |
u_int th_x2:4, /* (unused) */ |
58 | 58 |
th_off:4; /* data offset */ |
59 | 59 |
#endif |
60 |
u_int8_t th_flags;
|
|
60 |
uint8_t th_flags;
|
|
61 | 61 |
#define TH_FIN 0x01 |
62 | 62 |
#define TH_SYN 0x02 |
63 | 63 |
#define TH_RST 0x04 |
64 | 64 |
#define TH_PUSH 0x08 |
65 | 65 |
#define TH_ACK 0x10 |
66 | 66 |
#define TH_URG 0x20 |
67 |
u_int16_t th_win; /* window */
|
|
68 |
u_int16_t th_sum; /* checksum */
|
|
69 |
u_int16_t th_urp; /* urgent pointer */
|
|
67 |
uint16_t th_win; /* window */
|
|
68 |
uint16_t th_sum; /* checksum */
|
|
69 |
uint16_t th_urp; /* urgent pointer */
|
|
70 | 70 |
}; |
71 | 71 |
|
72 | 72 |
#include "tcp_var.h" |
b/slirp/tcp_input.c | ||
---|---|---|
280 | 280 |
tcpiphdr2qlink(ti)->next = tcpiphdr2qlink(ti)->prev = NULL; |
281 | 281 |
memset(&ti->ti_i.ih_mbuf, 0 , sizeof(struct mbuf_ptr)); |
282 | 282 |
ti->ti_x1 = 0; |
283 |
ti->ti_len = htons((u_int16_t)tlen);
|
|
283 |
ti->ti_len = htons((uint16_t)tlen); |
|
284 | 284 |
len = sizeof(struct ip ) + tlen; |
285 | 285 |
if(cksum(m, len)) { |
286 | 286 |
goto drop; |
... | ... | |
1289 | 1289 |
static void |
1290 | 1290 |
tcp_dooptions(struct tcpcb *tp, u_char *cp, int cnt, struct tcpiphdr *ti) |
1291 | 1291 |
{ |
1292 |
u_int16_t mss;
|
|
1292 |
uint16_t mss; |
|
1293 | 1293 |
int opt, optlen; |
1294 | 1294 |
|
1295 | 1295 |
DEBUG_CALL("tcp_dooptions"); |
b/slirp/tcp_output.c | ||
---|---|---|
263 | 263 |
if (flags & TH_SYN) { |
264 | 264 |
tp->snd_nxt = tp->iss; |
265 | 265 |
if ((tp->t_flags & TF_NOOPT) == 0) { |
266 |
u_int16_t mss;
|
|
266 |
uint16_t mss; |
|
267 | 267 |
|
268 | 268 |
opt[0] = TCPOPT_MAXSEG; |
269 | 269 |
opt[1] = 4; |
270 |
mss = htons((u_int16_t) tcp_mss(tp, 0));
|
|
270 |
mss = htons((uint16_t) tcp_mss(tp, 0)); |
|
271 | 271 |
memcpy((caddr_t)(opt + 2), (caddr_t)&mss, sizeof(mss)); |
272 | 272 |
optlen = 4; |
273 | 273 |
} |
... | ... | |
364 | 364 |
win = (long)TCP_MAXWIN << tp->rcv_scale; |
365 | 365 |
if (win < (long)(tp->rcv_adv - tp->rcv_nxt)) |
366 | 366 |
win = (long)(tp->rcv_adv - tp->rcv_nxt); |
367 |
ti->ti_win = htons((u_int16_t) (win>>tp->rcv_scale));
|
|
367 |
ti->ti_win = htons((uint16_t) (win>>tp->rcv_scale)); |
|
368 | 368 |
|
369 | 369 |
if (SEQ_GT(tp->snd_up, tp->snd_una)) { |
370 |
ti->ti_urp = htons((u_int16_t)(tp->snd_up - ntohl(ti->ti_seq)));
|
|
370 |
ti->ti_urp = htons((uint16_t)(tp->snd_up - ntohl(ti->ti_seq))); |
|
371 | 371 |
ti->ti_flags |= TH_URG; |
372 | 372 |
} else |
373 | 373 |
/* |
... | ... | |
383 | 383 |
* checksum extended header and data. |
384 | 384 |
*/ |
385 | 385 |
if (len + optlen) |
386 |
ti->ti_len = htons((u_int16_t)(sizeof (struct tcphdr) +
|
|
386 |
ti->ti_len = htons((uint16_t)(sizeof (struct tcphdr) + |
|
387 | 387 |
optlen + len)); |
388 | 388 |
ti->ti_sum = cksum(m, (int)(hdrlen + len)); |
389 | 389 |
|
b/slirp/tcp_subr.c | ||
---|---|---|
134 | 134 |
m->m_len = sizeof (struct tcpiphdr); |
135 | 135 |
tlen = 0; |
136 | 136 |
#define xchg(a,b,type) { type t; t=a; a=b; b=t; } |
137 |
xchg(ti->ti_dst.s_addr, ti->ti_src.s_addr, u_int32_t);
|
|
138 |
xchg(ti->ti_dport, ti->ti_sport, u_int16_t);
|
|
137 |
xchg(ti->ti_dst.s_addr, ti->ti_src.s_addr, uint32_t); |
|
138 |
xchg(ti->ti_dport, ti->ti_sport, uint16_t); |
|
139 | 139 |
#undef xchg |
140 | 140 |
} |
141 | 141 |
ti->ti_len = htons((u_short)(sizeof (struct tcphdr) + tlen)); |
... | ... | |
150 | 150 |
ti->ti_off = sizeof (struct tcphdr) >> 2; |
151 | 151 |
ti->ti_flags = flags; |
152 | 152 |
if (tp) |
153 |
ti->ti_win = htons((u_int16_t) (win >> tp->rcv_scale));
|
|
153 |
ti->ti_win = htons((uint16_t) (win >> tp->rcv_scale)); |
|
154 | 154 |
else |
155 |
ti->ti_win = htons((u_int16_t)win);
|
|
155 |
ti->ti_win = htons((uint16_t)win); |
|
156 | 156 |
ti->ti_urp = 0; |
157 | 157 |
ti->ti_sum = 0; |
158 | 158 |
ti->ti_sum = cksum(m, tlen); |
... | ... | |
491 | 491 |
/* |
492 | 492 |
* Return TOS according to the above table |
493 | 493 |
*/ |
494 |
u_int8_t
|
|
494 |
uint8_t |
|
495 | 495 |
tcp_tos(struct socket *so) |
496 | 496 |
{ |
497 | 497 |
int i = 0; |
... | ... | |
548 | 548 |
Slirp *slirp = so->slirp; |
549 | 549 |
u_int n1, n2, n3, n4, n5, n6; |
550 | 550 |
char buff[257]; |
551 |
u_int32_t laddr;
|
|
551 |
uint32_t laddr; |
|
552 | 552 |
u_int lport; |
553 | 553 |
char *bptr; |
554 | 554 |
|
b/slirp/tcp_var.h | ||
---|---|---|
75 | 75 |
tcp_seq snd_wl1; /* window update seg seq number */ |
76 | 76 |
tcp_seq snd_wl2; /* window update seg ack number */ |
77 | 77 |
tcp_seq iss; /* initial send sequence number */ |
78 |
u_int32_t snd_wnd; /* send window */
|
|
78 |
uint32_t snd_wnd; /* send window */ |
|
79 | 79 |
/* receive sequence variables */ |
80 |
u_int32_t rcv_wnd; /* receive window */
|
|
80 |
uint32_t rcv_wnd; /* receive window */ |
|
81 | 81 |
tcp_seq rcv_nxt; /* receive next */ |
82 | 82 |
tcp_seq rcv_up; /* receive urgent pointer */ |
83 | 83 |
tcp_seq irs; /* initial receive sequence number */ |
... | ... | |
91 | 91 |
* used to recognize retransmits |
92 | 92 |
*/ |
93 | 93 |
/* congestion control (for slow start, source quench, retransmit after loss) */ |
94 |
u_int32_t snd_cwnd; /* congestion-controlled window */
|
|
95 |
u_int32_t snd_ssthresh; /* snd_cwnd size threshold for
|
|
94 |
uint32_t snd_cwnd; /* congestion-controlled window */ |
|
95 |
uint32_t snd_ssthresh; /* snd_cwnd size threshold for |
|
96 | 96 |
* for slow start exponential to |
97 | 97 |
* linear switch |
98 | 98 |
*/ |
... | ... | |
106 | 106 |
short t_srtt; /* smoothed round-trip time */ |
107 | 107 |
short t_rttvar; /* variance in round-trip time */ |
108 | 108 |
u_short t_rttmin; /* minimum rtt allowed */ |
109 |
u_int32_t max_sndwnd; /* largest window peer has offered */
|
|
109 |
uint32_t max_sndwnd; /* largest window peer has offered */ |
|
110 | 110 |
|
111 | 111 |
/* out-of-band data */ |
112 | 112 |
char t_oobflags; /* have some */ |
... | ... | |
120 | 120 |
u_char rcv_scale; /* window scaling for recv window */ |
121 | 121 |
u_char request_r_scale; /* pending window scaling */ |
122 | 122 |
u_char requested_s_scale; |
123 |
u_int32_t ts_recent; /* timestamp echo data */
|
|
124 |
u_int32_t ts_recent_age; /* when last updated */
|
|
123 |
uint32_t ts_recent; /* timestamp echo data */ |
|
124 |
uint32_t ts_recent_age; /* when last updated */ |
|
125 | 125 |
tcp_seq last_ack_sent; |
126 | 126 |
|
127 | 127 |
}; |
b/slirp/tftp.c | ||
---|---|---|
92 | 92 |
return -1; |
93 | 93 |
} |
94 | 94 |
|
95 |
static int tftp_read_data(struct tftp_session *spt, u_int16_t block_nr,
|
|
96 |
u_int8_t *buf, int len)
|
|
95 |
static int tftp_read_data(struct tftp_session *spt, uint16_t block_nr, |
|
96 |
uint8_t *buf, int len)
|
|
97 | 97 |
{ |
98 | 98 |
int fd; |
99 | 99 |
int bytes_read = 0; |
... | ... | |
155 | 155 |
} |
156 | 156 |
|
157 | 157 |
static void tftp_send_error(struct tftp_session *spt, |
158 |
u_int16_t errorcode, const char *msg,
|
|
158 |
uint16_t errorcode, const char *msg, |
|
159 | 159 |
struct tftp_t *recv_tp) |
160 | 160 |
{ |
161 | 161 |
struct sockaddr_in saddr, daddr; |
... | ... | |
194 | 194 |
} |
195 | 195 |
|
196 | 196 |
static int tftp_send_data(struct tftp_session *spt, |
197 |
u_int16_t block_nr,
|
|
197 |
uint16_t block_nr,
|
|
198 | 198 |
struct tftp_t *recv_tp) |
199 | 199 |
{ |
200 | 200 |
struct sockaddr_in saddr, daddr; |
b/slirp/tftp.h | ||
---|---|---|
16 | 16 |
struct tftp_t { |
17 | 17 |
struct ip ip; |
18 | 18 |
struct udphdr udp; |
19 |
u_int16_t tp_op;
|
|
19 |
uint16_t tp_op; |
|
20 | 20 |
union { |
21 | 21 |
struct { |
22 |
u_int16_t tp_block_nr;
|
|
23 |
u_int8_t tp_buf[512];
|
|
22 |
uint16_t tp_block_nr; |
|
23 |
uint8_t tp_buf[512]; |
|
24 | 24 |
} tp_data; |
25 | 25 |
struct { |
26 |
u_int16_t tp_error_code;
|
|
27 |
u_int8_t tp_msg[512];
|
|
26 |
uint16_t tp_error_code; |
|
27 |
uint8_t tp_msg[512]; |
|
28 | 28 |
} tp_error; |
29 |
u_int8_t tp_buf[512 + 2];
|
|
29 |
uint8_t tp_buf[512 + 2]; |
|
30 | 30 |
} x; |
31 | 31 |
}; |
32 | 32 |
|
... | ... | |
35 | 35 |
char *filename; |
36 | 36 |
|
37 | 37 |
struct in_addr client_ip; |
38 |
u_int16_t client_port;
|
|
38 |
uint16_t client_port; |
|
39 | 39 |
|
40 | 40 |
int timestamp; |
41 | 41 |
}; |
b/slirp/udp.c | ||
---|---|---|
41 | 41 |
#include <slirp.h> |
42 | 42 |
#include "ip_icmp.h" |
43 | 43 |
|
44 |
static u_int8_t udp_tos(struct socket *so);
|
|
44 |
static uint8_t udp_tos(struct socket *so); |
|
45 | 45 |
|
46 | 46 |
void |
47 | 47 |
udp_init(Slirp *slirp) |
... | ... | |
88 | 88 |
* Make mbuf data length reflect UDP length. |
89 | 89 |
* If not enough data to reflect UDP length, drop. |
90 | 90 |
*/ |
91 |
len = ntohs((u_int16_t)uh->uh_ulen);
|
|
91 |
len = ntohs((uint16_t)uh->uh_ulen); |
|
92 | 92 |
|
93 | 93 |
if (ip->ip_len != len) { |
94 | 94 |
if (len > ip->ip_len) { |
... | ... | |
321 | 321 |
{0, 0, 0, 0} |
322 | 322 |
}; |
323 | 323 |
|
324 |
static u_int8_t
|
|
324 |
static uint8_t |
|
325 | 325 |
udp_tos(struct socket *so) |
326 | 326 |
{ |
327 | 327 |
int i = 0; |
... | ... | |
339 | 339 |
} |
340 | 340 |
|
341 | 341 |
struct socket * |
342 |
udp_listen(Slirp *slirp, u_int32_t haddr, u_int hport, u_int32_t laddr,
|
|
342 |
udp_listen(Slirp *slirp, uint32_t haddr, u_int hport, uint32_t laddr,
|
|
343 | 343 |
u_int lport, int flags) |
344 | 344 |
{ |
345 | 345 |
struct sockaddr_in addr; |
b/slirp/udp.h | ||
---|---|---|
41 | 41 |
* Per RFC 768, September, 1981. |
42 | 42 |
*/ |
43 | 43 |
struct udphdr { |
44 |
u_int16_t uh_sport; /* source port */
|
|
45 |
u_int16_t uh_dport; /* destination port */
|
|
46 |
int16_t uh_ulen; /* udp length */
|
|
47 |
u_int16_t uh_sum; /* udp checksum */
|
|
44 |
uint16_t uh_sport; /* source port */
|
|
45 |
uint16_t uh_dport; /* destination port */
|
|
46 |
int16_t uh_ulen; /* udp length */
|
|
47 |
uint16_t uh_sum; /* udp checksum */
|
|
48 | 48 |
}; |
49 | 49 |
|
50 | 50 |
/* |
... | ... | |
78 | 78 |
int udp_output(struct socket *, struct mbuf *, struct sockaddr_in *); |
79 | 79 |
int udp_attach(struct socket *); |
80 | 80 |
void udp_detach(struct socket *); |
81 |
struct socket * udp_listen(Slirp *, u_int32_t, u_int, u_int32_t, u_int,
|
|
81 |
struct socket * udp_listen(Slirp *, uint32_t, u_int, uint32_t, u_int,
|
|
82 | 82 |
int); |
83 | 83 |
int udp_output2(struct socket *so, struct mbuf *m, |
84 | 84 |
struct sockaddr_in *saddr, struct sockaddr_in *daddr, |
Also available in: Unified diff