aboutsummaryrefslogtreecommitdiff
path: root/slirp
diff options
context:
space:
mode:
authorths <ths@c046a42c-6fe2-441c-8c8c-71466251a162>2007-09-17 08:09:54 +0000
committerths <ths@c046a42c-6fe2-441c-8c8c-71466251a162>2007-09-17 08:09:54 +0000
commit3b46e6242767a2c770c0aba0a6595e9511623c92 (patch)
tree3be4de9b2efeb39df2456957babaeda70ed50012 /slirp
parentef18c8839e85341cc63467f92c35f981858a6fe5 (diff)
find -type f | xargs sed -i 's/[\t ]*$//g' # Yes, again. Note the star in the regex.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3177 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'slirp')
-rw-r--r--slirp/bootp.c16
-rw-r--r--slirp/cksum.c2
-rw-r--r--slirp/debug.c12
-rw-r--r--slirp/if.c8
-rw-r--r--slirp/ip_icmp.c18
-rw-r--r--slirp/ip_output.c6
-rw-r--r--slirp/mbuf.c4
-rw-r--r--slirp/misc.c60
-rw-r--r--slirp/sbuf.c4
-rw-r--r--slirp/slirp.c68
-rw-r--r--slirp/socket.c22
-rw-r--r--slirp/socket.h8
-rw-r--r--slirp/tcp_input.c52
-rw-r--r--slirp/tcp_output.c8
-rw-r--r--slirp/tcp_subr.c166
-rw-r--r--slirp/tcp_timer.c8
-rw-r--r--slirp/tftp.c24
-rw-r--r--slirp/udp.c56
18 files changed, 271 insertions, 271 deletions
diff --git a/slirp/bootp.c b/slirp/bootp.c
index ebefa08b4a..9f2635bf39 100644
--- a/slirp/bootp.c
+++ b/slirp/bootp.c
@@ -89,7 +89,7 @@ static void dhcp_decode(const uint8_t *buf, int size,
const uint8_t *p, *p_end;
int len, tag;
- *pmsg_type = 0;
+ *pmsg_type = 0;
p = buf;
p_end = buf + size;
@@ -137,16 +137,16 @@ static void bootp_reply(struct bootp_t *bp)
/* extract exact DHCP msg type */
dhcp_decode(bp->bp_vend, DHCP_OPT_LEN, &dhcp_msg_type);
dprintf("bootp packet op=%d msgtype=%d\n", bp->bp_op, dhcp_msg_type);
-
+
if (dhcp_msg_type == 0)
dhcp_msg_type = DHCPREQUEST; /* Force reply for old BOOTP clients */
-
+
if (dhcp_msg_type != DHCPDISCOVER &&
dhcp_msg_type != DHCPREQUEST)
return;
/* XXX: this is a hack to get the client mac address */
memcpy(client_ethaddr, bp->bp_hwaddr, 6);
-
+
if ((m = m_get()) == NULL)
return;
m->m_data += if_maxlinkhdr;
@@ -203,7 +203,7 @@ static void bootp_reply(struct bootp_t *bp)
*q++ = 1;
*q++ = DHCPACK;
}
-
+
if (dhcp_msg_type == DHCPDISCOVER ||
dhcp_msg_type == DHCPREQUEST) {
*q++ = RFC2132_SRV_ID;
@@ -217,12 +217,12 @@ static void bootp_reply(struct bootp_t *bp)
*q++ = 0xff;
*q++ = 0xff;
*q++ = 0x00;
-
+
*q++ = RFC1533_GATEWAY;
*q++ = 4;
memcpy(q, &saddr.sin_addr, 4);
q += 4;
-
+
*q++ = RFC1533_DNS;
*q++ = 4;
dns_addr.s_addr = htonl(ntohl(special_addr.s_addr) | CTL_DNS);
@@ -244,7 +244,7 @@ static void bootp_reply(struct bootp_t *bp)
}
}
*q++ = RFC1533_END;
-
+
m->m_len = sizeof(struct bootp_t) -
sizeof(struct ip) - sizeof(struct udphdr);
udp_output2(NULL, m, &saddr, &daddr, IPTOS_LOWDELAY);
diff --git a/slirp/cksum.c b/slirp/cksum.c
index ee7e8644ad..b98373b51f 100644
--- a/slirp/cksum.c
+++ b/slirp/cksum.c
@@ -117,7 +117,7 @@ int cksum(struct mbuf *m, int len)
sum += s_util.s;
mlen = 0;
} else
-
+
mlen = -1;
} else if (mlen == -1)
s_util.c[0] = *(u_int8_t *)w;
diff --git a/slirp/debug.c b/slirp/debug.c
index 607b0e76e7..e312445505 100644
--- a/slirp/debug.c
+++ b/slirp/debug.c
@@ -192,7 +192,7 @@ tcpstats()
lprint(" %6d control (SYN/FIN/RST) packets\r\n", tcpstat.tcps_sndctrl);
lprint(" %6d times tcp_output did nothing\r\n", tcpstat.tcps_didnuttin);
- lprint(" %6d packets received\r\n", tcpstat.tcps_rcvtotal);
+ lprint(" %6d packets received\r\n", tcpstat.tcps_rcvtotal);
lprint(" %6d acks (for %d bytes)\r\n",
tcpstat.tcps_rcvackpack, tcpstat.tcps_rcvackbyte);
lprint(" %6d duplicate acks\r\n", tcpstat.tcps_rcvdupack);
@@ -302,9 +302,9 @@ sockstats()
lprint(
"Proto[state] Sock Local Address, Port Remote Address, Port RecvQ SendQ\r\n");
-
+
for (so = tcb.so_next; so != &tcb; so = so->so_next) {
-
+
n = sprintf(buff, "tcp[%s]", so->so_tcpcb?tcpstates[so->so_tcpcb->t_state]:"NONE");
while (n < 17)
buff[n++] = ' ';
@@ -316,9 +316,9 @@ sockstats()
inet_ntoa(so->so_faddr), ntohs(so->so_fport),
so->so_rcv.sb_cc, so->so_snd.sb_cc);
}
-
+
for (so = udb.so_next; so != &udb; so = so->so_next) {
-
+
n = sprintf(buff, "udp[%d sec]", (so->so_expire - curtime) / 1000);
while (n < 17)
buff[n++] = ' ';
@@ -347,7 +347,7 @@ slirp_exit(exit_status)
if (!dfd)
debug_init("slirp_stats", 0xf);
lprint_arg = (char **)&dfd;
-
+
ipstats();
tcpstats();
udpstats();
diff --git a/slirp/if.c b/slirp/if.c
index 6834c33960..6d72fa72f3 100644
--- a/slirp/if.c
+++ b/slirp/if.c
@@ -179,7 +179,7 @@ if_output(so, ifm)
}
/*
- * See if there's already a batchq list for this session.
+ * See if there's already a batchq list for this session.
* This can include an interactive session, which should go on fastq,
* but gets too greedy... hence it'll be downgraded from fastq to batchq.
* We mustn't put this packet back on the fastq (or we'll send it out of order)
@@ -231,10 +231,10 @@ diddit:
*/
if (on_fastq && ((so->so_nqueued >= 6) &&
(so->so_nqueued - so->so_queued) >= 3)) {
-
+
/* Remove from current queue... */
remque(ifm->ifs_next);
-
+
/* ...And insert in the new. That'll teach ya! */
insque(ifm->ifs_next, &if_batchq);
}
@@ -290,7 +290,7 @@ if_start(void)
ifm = next_m;
else
ifm = if_batchq.ifq_next;
-
+
/* Set which packet to send on next iteration */
next_m = ifm->ifq_next;
}
diff --git a/slirp/ip_icmp.c b/slirp/ip_icmp.c
index b24eae9b7b..ae5a321185 100644
--- a/slirp/ip_icmp.c
+++ b/slirp/ip_icmp.c
@@ -105,7 +105,7 @@ icmp_input(m, hlen)
}
m->m_len += hlen;
m->m_data -= hlen;
-
+
/* icmpstat.icps_inhist[icp->icmp_type]++; */
/* code = icp->icmp_code; */
@@ -135,7 +135,7 @@ icmp_input(m, hlen)
so->so_iptos = ip->ip_tos;
so->so_type = IPPROTO_ICMP;
so->so_state = SS_ISFCONNECTED;
-
+
/* Send the packet */
addr.sin_family = AF_INET;
if ((so->so_faddr.s_addr & htonl(0xffffff00)) == special_addr.s_addr) {
@@ -173,7 +173,7 @@ icmp_input(m, hlen)
icmpstat.icps_notsupp++;
m_freem(m);
break;
-
+
default:
icmpstat.icps_badtype++;
m_freem(m);
@@ -226,7 +226,7 @@ icmp_error(msrc, type, code, minsize, message)
/* check msrc */
if(!msrc) goto end_error;
ip = mtod(msrc, struct ip *);
-#if DEBUG
+#if DEBUG
{ char bufa[20], bufb[20];
strcpy(bufa, inet_ntoa(ip->ip_src));
strcpy(bufb, inet_ntoa(ip->ip_dst));
@@ -258,9 +258,9 @@ icmp_error(msrc, type, code, minsize, message)
/* make the header of the reply packet */
ip = mtod(m, struct ip *);
hlen= sizeof(struct ip ); /* no options in reply */
-
+
/* fill in icmp */
- m->m_data += hlen;
+ m->m_data += hlen;
m->m_len -= hlen;
icp = mtod(m, struct icmp *);
@@ -269,7 +269,7 @@ icmp_error(msrc, type, code, minsize, message)
else if(s_ip_len>ICMP_MAXDATALEN) /* maximum size */
s_ip_len=ICMP_MAXDATALEN;
- m->m_len=ICMP_MINLEN+s_ip_len; /* 8 bytes ICMP header */
+ m->m_len=ICMP_MINLEN+s_ip_len; /* 8 bytes ICMP header */
/* min. size = 8+sizeof(struct ip)+8 */
@@ -304,7 +304,7 @@ icmp_error(msrc, type, code, minsize, message)
/* fill in ip */
ip->ip_hl = hlen >> 2;
ip->ip_len = m->m_len;
-
+
ip->ip_tos=((ip->ip_tos & 0x1E) | 0xC0); /* high priority for errors */
ip->ip_ttl = MAXTTL;
@@ -313,7 +313,7 @@ icmp_error(msrc, type, code, minsize, message)
ip->ip_src = alias_addr;
(void ) ip_output((struct socket *)NULL, m);
-
+
icmpstat.icps_reflect++;
end_error:
diff --git a/slirp/ip_output.c b/slirp/ip_output.c
index b80b038cd4..b1a8484026 100644
--- a/slirp/ip_output.c
+++ b/slirp/ip_output.c
@@ -143,7 +143,7 @@ ip_output(so, m0)
m->m_data += if_maxlinkhdr;
mhip = mtod(m, struct ip *);
*mhip = *ip;
-
+
/* No options */
/* if (hlen > sizeof (struct ip)) {
* mhlen = ip_optcopy(ip, mhip) + sizeof (struct ip);
@@ -159,12 +159,12 @@ ip_output(so, m0)
else
mhip->ip_off |= IP_MF;
mhip->ip_len = htons((u_int16_t)(len + mhlen));
-
+
if (m_copy(m, m0, off, len) < 0) {
error = -1;
goto sendorfree;
}
-
+
mhip->ip_off = htons((u_int16_t)mhip->ip_off);
mhip->ip_sum = 0;
mhip->ip_sum = cksum(m, mhlen);
diff --git a/slirp/mbuf.c b/slirp/mbuf.c
index bcf71bc616..392aea826b 100644
--- a/slirp/mbuf.c
+++ b/slirp/mbuf.c
@@ -156,7 +156,7 @@ m_inc(m, size)
m->m_ext = (char *)realloc(m->m_ext,size);
/* if (m->m_ext == NULL)
* return (struct mbuf *)NULL;
- */
+ */
m->m_data = m->m_ext + datasize;
} else {
char *dat;
@@ -166,7 +166,7 @@ m_inc(m, size)
* return (struct mbuf *)NULL;
*/
memcpy(dat, m->m_dat, m->m_size);
-
+
m->m_ext = dat;
m->m_data = m->m_ext + datasize;
m->m_flags |= M_EXT;
diff --git a/slirp/misc.c b/slirp/misc.c
index db4444ef3a..a41dd769b2 100644
--- a/slirp/misc.c
+++ b/slirp/misc.c
@@ -335,13 +335,13 @@ fork_exec(so, ex, do_pty)
addr.sin_family = AF_INET;
addr.sin_port = 0;
addr.sin_addr.s_addr = INADDR_ANY;
-
+
if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0 ||
bind(s, (struct sockaddr *)&addr, addrlen) < 0 ||
listen(s, 1) < 0) {
lprint("Error: inet socket: %s\n", strerror(errno));
closesocket(s);
-
+
return 0;
}
}
@@ -353,7 +353,7 @@ fork_exec(so, ex, do_pty)
if (do_pty == 2)
close(master);
return 0;
-
+
case 0:
/* Set the DISPLAY */
if (do_pty == 2) {
@@ -375,7 +375,7 @@ fork_exec(so, ex, do_pty)
ret = connect(s, (struct sockaddr *)&addr, addrlen);
} while (ret < 0 && errno == EINTR);
}
-
+
#if 0
if (x_port >= 0) {
#ifdef HAVE_SETENV
@@ -392,7 +392,7 @@ fork_exec(so, ex, do_pty)
dup2(s, 2);
for (s = 3; s <= 255; s++)
close(s);
-
+
i = 0;
bptr = strdup(ex); /* No need to free() this */
if (do_pty == 1) {
@@ -410,21 +410,21 @@ fork_exec(so, ex, do_pty)
*bptr++ = (char)0;
argv[i++] = strdup(curarg);
} while (c);
-
+
argv[i] = 0;
execvp(argv[0], argv);
-
+
/* Ooops, failed, let's tell the user why */
{
char buff[256];
-
+
sprintf(buff, "Error: execvp of %s failed: %s\n",
argv[0], strerror(errno));
write(2, buff, strlen(buff)+1);
}
close(0); close(1); close(2); /* XXX */
exit(1);
-
+
default:
if (do_pty == 2) {
close(s);
@@ -447,13 +447,13 @@ fork_exec(so, ex, do_pty)
setsockopt(so->s,SOL_SOCKET,SO_OOBINLINE,(char *)&opt,sizeof(int));
}
fd_nonblock(so->s);
-
+
/* Append the telnet options now */
if (so->so_m != 0 && do_pty == 1) {
sbappend(so, so->so_m);
so->so_m = 0;
}
-
+
return 1;
}
}
@@ -570,15 +570,15 @@ relay(s)
while (1) {
FD_ZERO(&readfds);
-
+
FD_SET(0, &readfds);
FD_SET(s, &readfds);
-
+
n = select(s+1, &readfds, (fd_set *)0, (fd_set *)0, (struct timeval *)0);
-
+
if (n <= 0)
slirp_exit(0);
-
+
if (FD_ISSET(0, &readfds)) {
n = read(0, buf, 8192);
if (n <= 0)
@@ -587,7 +587,7 @@ relay(s)
if (n <= 0)
slirp_exit(0);
}
-
+
if (FD_ISSET(s, &readfds)) {
n = read(s, buf, 8192);
if (n <= 0)
@@ -614,7 +614,7 @@ lprint(va_alist) va_dcl
#endif
{
va_list args;
-
+
#ifdef __STDC__
va_start(args, format);
#else
@@ -631,15 +631,15 @@ lprint(va_alist) va_dcl
int deltaw = lprint_sb->sb_wptr - lprint_sb->sb_data;
int deltar = lprint_sb->sb_rptr - lprint_sb->sb_data;
int deltap = lprint_ptr - lprint_sb->sb_data;
-
+
lprint_sb->sb_data = (char *)realloc(lprint_sb->sb_data,
lprint_sb->sb_datalen + TCP_SNDSPACE);
-
+
/* Adjust all values */
lprint_sb->sb_wptr = lprint_sb->sb_data + deltaw;
lprint_sb->sb_rptr = lprint_sb->sb_data + deltar;
lprint_ptr = lprint_sb->sb_data + deltap;
-
+
lprint_sb->sb_datalen += TCP_SNDSPACE;
}
}
@@ -655,9 +655,9 @@ lprint(va_alist) va_dcl
*/
int len = strlen(format);
char *bptr1, *bptr2;
-
+
bptr1 = bptr2 = strdup(format);
-
+
while (len--) {
if (*bptr1 == '\r')
memcpy(bptr1, bptr1+1, len+1);
@@ -900,11 +900,11 @@ rsh_exec(so,ns, user, host, args)
close(fd0[0]);
close(fd0[1]);
return 0;
-
+
case 0:
close(fd[0]);
close(fd0[0]);
-
+
/* Set the DISPLAY */
if (x_port >= 0) {
#ifdef HAVE_SETENV
@@ -915,29 +915,29 @@ rsh_exec(so,ns, user, host, args)
putenv(buff);
#endif
}
-
+
dup2(fd0[1], 0);
dup2(fd0[1], 1);
dup2(fd[1], 2);
for (s = 3; s <= 255; s++)
close(s);
-
+
execlp("rsh","rsh","-l", user, host, args, NULL);
-
+
/* Ooops, failed, let's tell the user why */
-
+
sprintf(buff, "Error: execlp of %s failed: %s\n",
"rsh", strerror(errno));
write(2, buff, strlen(buff)+1);
close(0); close(1); close(2); /* XXX */
exit(1);
-
+
default:
close(fd[1]);
close(fd0[1]);
ns->s=fd[0];
so->s=fd0[0];
-
+
return 1;
}
}
diff --git a/slirp/sbuf.c b/slirp/sbuf.c
index e6b5bb6707..209064b1aa 100644
--- a/slirp/sbuf.c
+++ b/slirp/sbuf.c
@@ -37,7 +37,7 @@ sbdrop(sb, num)
sb->sb_rptr += num;
if(sb->sb_rptr >= sb->sb_data + sb->sb_datalen)
sb->sb_rptr -= sb->sb_datalen;
-
+
}
void
@@ -198,4 +198,4 @@ sbcopy(sb, off, len, to)
memcpy(to+off,sb->sb_data,len);
}
}
-
+
diff --git a/slirp/slirp.c b/slirp/slirp.c
index 12093bf507..f535db12b0 100644
--- a/slirp/slirp.c
+++ b/slirp/slirp.c
@@ -38,10 +38,10 @@ static int get_dns_addr(struct in_addr *pdns_addr)
DWORD ret;
IP_ADDR_STRING *pIPAddr;
struct in_addr tmp_addr;
-
+
FixedInfo = (FIXED_INFO *)GlobalAlloc(GPTR, sizeof(FIXED_INFO));
BufLen = sizeof(FIXED_INFO);
-
+
if (ERROR_BUFFER_OVERFLOW == GetNetworkParams(FixedInfo, &BufLen)) {
if (FixedInfo) {
GlobalFree(FixedInfo);
@@ -58,14 +58,14 @@ static int get_dns_addr(struct in_addr *pdns_addr)
}
return -1;
}
-
+
pIPAddr = &(FixedInfo->DnsServerList);
inet_aton(pIPAddr->IpAddress.String, &tmp_addr);
*pdns_addr = tmp_addr;
#if 0
printf( "DNS Servers:\n" );
printf( "DNS Addr:%s\n", pIPAddr->IpAddress.String );
-
+
pIPAddr = FixedInfo -> DnsServerList.Next;
while ( pIPAddr ) {
printf( "DNS Addr:%s\n", pIPAddr ->IpAddress.String );
@@ -88,7 +88,7 @@ static int get_dns_addr(struct in_addr *pdns_addr)
FILE *f;
int found = 0;
struct in_addr tmp_addr;
-
+
f = fopen("/etc/resolv.conf", "r");
if (!f)
return -1;
@@ -130,7 +130,7 @@ void slirp_cleanup(void)
void slirp_init(void)
{
// debug_init("/tmp/slirp.log", DEBUG_DEFAULT);
-
+
#ifdef _WIN32
{
WSADATA Data;
@@ -201,7 +201,7 @@ void slirp_select_fill(int *pnfds,
global_readfds = NULL;
global_writefds = NULL;
global_xfds = NULL;
-
+
nfds = *pnfds;
/*
* First, TCP sockets
@@ -214,23 +214,23 @@ void slirp_select_fill(int *pnfds,
*/
do_slowtimo = ((tcb.so_next != &tcb) ||
((struct ipasfrag *)&ipq != (struct ipasfrag *)ipq.next));
-
+
for (so = tcb.so_next; so != &tcb; so = so_next) {
so_next = so->so_next;
-
+
/*
* See if we need a tcp_fasttimo
*/
if (time_fasttimo == 0 && so->so_tcpcb->t_flags & TF_DELACK)
time_fasttimo = curtime; /* Flag when we want a fasttimo */
-
+
/*
* NOFDREF can include still connecting to local-host,
* newly socreated() sockets etc. Don't want to select these.
*/
if (so->so_state & SS_NOFDREF || so->s == -1)
continue;
-
+
/*
* Set for reading sockets which are accepting
*/
@@ -239,7 +239,7 @@ void slirp_select_fill(int *pnfds,
UPD_NFDS(so->s);
continue;
}
-
+
/*
* Set for writing sockets which are connecting
*/
@@ -248,7 +248,7 @@ void slirp_select_fill(int *pnfds,
UPD_NFDS(so->s);
continue;
}
-
+
/*
* Set for writing if we are connected, can send more, and
* we have something to send
@@ -257,7 +257,7 @@ void slirp_select_fill(int *pnfds,
FD_SET(so->s, writefds);
UPD_NFDS(so->s);
}
-
+
/*
* Set for reading (and urgent data) if we are connected, can
* receive more, and we have room for it XXX /2 ?
@@ -268,13 +268,13 @@ void slirp_select_fill(int *pnfds,
UPD_NFDS(so->s);
}
}
-
+
/*
* UDP sockets
*/
for (so = udb.so_next; so != &udb; so = so_next) {
so_next = so->so_next;
-
+
/*
* See if it's timed out
*/
@@ -285,7 +285,7 @@ void slirp_select_fill(int *pnfds,
} else
do_slowtimo = 1; /* Let socket expire */
}
-
+
/*
* When UDP packets are received from over the
* link, they're sendto()'d straight away, so
@@ -324,13 +324,13 @@ void slirp_select_fill(int *pnfds,
timeout.tv_usec = 0;
else if (timeout.tv_usec > 510000)
timeout.tv_usec = 510000;
-
+
/* Can only fasttimo if we also slowtimo */
if (time_fasttimo) {
tmp_time = (200 - (curtime - time_fasttimo)) * 1000;
if (tmp_time < 0)
tmp_time = 0;
-
+
/* Choose the smallest of the 2 */
if (tmp_time < timeout.tv_usec)
timeout.tv_usec = (u_int)tmp_time;
@@ -375,14 +375,14 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds)
*/
for (so = tcb.so_next; so != &tcb; so = so_next) {
so_next = so->so_next;
-
+
/*
* FD_ISSET is meaningless on these sockets
* (and they can crash the program)
*/
if (so->so_state & SS_NOFDREF || so->s == -1)
continue;
-
+
/*
* Check for URG data
* This will soread as well, so no need to
@@ -402,12 +402,12 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds)
continue;
} /* else */
ret = soread(so);
-
+
/* Output it if we read something */
if (ret > 0)
tcp_output(sototcpcb(so));
}
-
+
/*
* Check sockets for writing
*/
@@ -418,19 +418,19 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds)
if (so->so_state & SS_ISFCONNECTING) {
/* Connected */
so->so_state &= ~SS_ISFCONNECTING;
-
+
ret = send(so->s, &ret, 0, 0);
if (ret < 0) {
/* XXXXX Must fix, zero bytes is a NOP */
if (errno == EAGAIN || errno == EWOULDBLOCK ||
errno == EINPROGRESS || errno == ENOTCONN)
continue;
-
+
/* else failed */
so->so_state = SS_NOFDREF;
}
/* else so->so_state &= ~SS_ISFCONNECTING; */
-
+
/*
* Continue tcp_input
*/
@@ -445,7 +445,7 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds)
* a window probe to get things going again
*/
}
-
+
/*
* Probe a still-connecting, non-blocking socket
* to check if it's still alive
@@ -453,16 +453,16 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds)
#ifdef PROBE_CONN
if (so->so_state & SS_ISFCONNECTING) {
ret = recv(so->s, (char *)&ret, 0,0);
-
+
if (ret < 0) {
/* XXX */
if (errno == EAGAIN || errno == EWOULDBLOCK ||
errno == EINPROGRESS || errno == ENOTCONN)
continue; /* Still connecting, continue */
-
+
/* else failed */
so->so_state = SS_NOFDREF;
-
+
/* tcp_input will take care of it */
} else {
ret = send(so->s, &ret, 0,0);
@@ -475,13 +475,13 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds)
so->so_state = SS_NOFDREF;
} else
so->so_state &= ~SS_ISFCONNECTING;
-
+
}
tcp_input((struct mbuf *)NULL, sizeof(struct ip),so);
} /* SS_ISFCONNECTING */
#endif
}
-
+
/*
* Now UDP sockets.
* Incoming packets are sent straight away, they're not buffered.
@@ -489,7 +489,7 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds)
*/
for (so = udb.so_next; so != &udb; so = so_next) {
so_next = so->so_next;
-
+
if (so->s != -1 && FD_ISSET(so->s, readfds)) {
sorecvfrom(so);
}
@@ -600,7 +600,7 @@ void slirp_input(const uint8_t *pkt, int pkt_len)
if (pkt_len < ETH_HLEN)
return;
-
+
proto = ntohs(*(uint16_t *)(pkt + 12));
switch(proto) {
case ETH_P_ARP:
diff --git a/slirp/socket.c b/slirp/socket.c
index 141bcb262a..7e07cf8942 100644
--- a/slirp/socket.c
+++ b/slirp/socket.c
@@ -251,7 +251,7 @@ sosendoob(so)
/* We can send it directly */
n = send(so->s, sb->sb_rptr, so->so_urgc, (MSG_OOB)); /* |MSG_DONTWAIT)); */
so->so_urgc -= n;
-
+
DEBUG_MISC((dfd, " --- sent %d bytes urgent data, %d urgent bytes left\n", n, so->so_urgc));
} else {
/*
@@ -274,7 +274,7 @@ sosendoob(so)
#ifdef DEBUG
if (n != len)
DEBUG_ERROR((dfd, "Didn't send all data urgently XXXXX\n"));
-#endif
+#endif
DEBUG_MISC((dfd, " ---2 sent %d bytes urgent data, %d urgent bytes left\n", n, so->so_urgc));
}
@@ -396,17 +396,17 @@ sorecvfrom(so)
if (so->so_type == IPPROTO_ICMP) { /* This is a "ping" reply */
char buff[256];
int len;
-
+
len = recvfrom(so->s, buff, 256, 0,
(struct sockaddr *)&addr, &addrlen);
/* XXX Check if reply is "correct"? */
-
+
if(len == -1 || len == 0) {
u_char code=ICMP_UNREACH_PORT;
if(errno == EHOSTUNREACH) code=ICMP_UNREACH_HOST;
else if(errno == ENETUNREACH) code=ICMP_UNREACH_NET;
-
+
DEBUG_MISC((dfd," udp icmp rx errno = %d-%s\n",
errno,strerror(errno)));
icmp_error(so->so_m, ICMP_UNREACH,code, 0,strerror(errno));
@@ -422,7 +422,7 @@ sorecvfrom(so)
if (!(m = m_get())) return;
m->m_data += if_maxlinkhdr;
-
+
/*
* XXX Shouldn't FIONREAD packets destined for port 53,
* but I don't know the max packet size for DNS lookups
@@ -430,14 +430,14 @@ sorecvfrom(so)
len = M_FREEROOM(m);
/* if (so->so_fport != htons(53)) { */
ioctlsocket(so->s, FIONREAD, &n);
-
+
if (n > len) {
n = (m->m_data - m->m_dat) + m->m_len + n + 1;
m_inc(m, n);
len = M_FREEROOM(m);
}
/* } */
-
+
m->m_len = recvfrom(so->s, m->m_data, len, 0,
(struct sockaddr *)&addr, &addrlen);
DEBUG_MISC((dfd, " did recvfrom %d, errno = %d-%s\n",
@@ -447,7 +447,7 @@ sorecvfrom(so)
if(errno == EHOSTUNREACH) code=ICMP_UNREACH_HOST;
else if(errno == ENETUNREACH) code=ICMP_UNREACH_NET;
-
+
DEBUG_MISC((dfd," rx error, tx icmp ICMP_UNREACH:%i\n", code));
icmp_error(so->so_m, ICMP_UNREACH,code, 0,strerror(errno));
m_free(m);
@@ -470,7 +470,7 @@ sorecvfrom(so)
* m->m_len = 0;
* }
*/
-
+
/*
* If this packet was destined for CTL_ADDR,
* make it look like that's where it came from, done by udp_output
@@ -580,7 +580,7 @@ solisten(port, laddr, lport, flags)
(bind(s,(struct sockaddr *)&addr, sizeof(addr)) < 0) ||
(listen(s,1) < 0)) {
int tmperrno = errno; /* Don't clobber the real reason we failed */
-
+
close(s);
sofree(so);
/* Restore the real errno */
diff --git a/slirp/socket.h b/slirp/socket.h
index 901e8423e3..99cc17f32b 100644
--- a/slirp/socket.h
+++ b/slirp/socket.h
@@ -33,16 +33,16 @@ struct socket {
struct in_addr so_laddr; /* local host table entry */
u_int16_t so_fport; /* foreign port */
u_int16_t so_lport; /* local port */
-
+
u_int8_t so_iptos; /* Type of service */
u_int8_t so_emu; /* Is the socket emulated? */
-
+
u_char so_type; /* Type of socket, UDP or TCP */
int so_state; /* internal state flags SS_*, below */
-
+
struct tcpcb *so_tcpcb; /* pointer to TCP protocol control block */
u_int so_expire; /* When the socket will expire */
-
+
int so_queued; /* Number of packets queued from this socket */
int so_nqueued; /* Number of packets queued in a row
* Used to determine when to "downgrade" a session
diff --git a/slirp/tcp_input.c b/slirp/tcp_input.c
index da35c4398b..04f6553127 100644
--- a/slirp/tcp_input.c
+++ b/slirp/tcp_input.c
@@ -262,7 +262,7 @@ tcp_input(m, iphlen, inso)
*/
if (m == NULL) {
so = inso;
-
+
/* Re-set a few variables */
tp = sototcpcb(so);
m = so->so_m;
@@ -270,7 +270,7 @@ tcp_input(m, iphlen, inso)
ti = so->so_ti;
tiwin = ti->ti_win;
tiflags = ti->ti_flags;
-
+
goto cont_conn;
}
@@ -394,32 +394,32 @@ findso:
if (so == 0) {
if ((tiflags & (TH_SYN|TH_FIN|TH_RST|TH_URG|TH_ACK)) != TH_SYN)
goto dropwithreset;
-
+
if ((so = socreate()) == NULL)
goto dropwithreset;
if (tcp_attach(so) < 0) {
free(so); /* Not sofree (if it failed, it's not insqued) */
goto dropwithreset;
}
-
+
sbreserve(&so->so_snd, tcp_sndspace);
sbreserve(&so->so_rcv, tcp_rcvspace);
-
+
/* tcp_last_so = so; */ /* XXX ? */
/* tp = sototcpcb(so); */
-
+
so->so_laddr = ti->ti_src;
so->so_lport = ti->ti_sport;
so->so_faddr = ti->ti_dst;
so->so_fport = ti->ti_dport;
-
+
if ((so->so_iptos = tcp_tos(so)) == 0)
so->so_iptos = ((struct ip *)ti)->ip_tos;
-
+
tp = sototcpcb(so);
tp->t_state = TCPS_LISTEN;
}
-
+
/*
* If this is a still-connecting socket, this probably
* a retransmit of the SYN. Whether it's a retransmit SYN
@@ -567,14 +567,14 @@ findso:
if (tcp_emu(so,m)) sbappend(so, m);
} else
sbappend(so, m);
-
+
/*
* XXX This is called when data arrives. Later, check
* if we can actually write() to the socket
* XXX Need to check? It's be NON_BLOCKING
*/
/* sorwakeup(so); */
-
+
/*
* If this is a short packet, then ACK now - with Nagel
* congestion avoidance sender won't send more until
@@ -624,12 +624,12 @@ findso:
goto dropwithreset;
if ((tiflags & TH_SYN) == 0)
goto drop;
-
+
/*
* This has way too many gotos...
* But a bit of spaghetti code never hurt anybody :)
*/
-
+
/*
* If this is destined for the control address, then flag to
* tcp_ctl once connected, otherwise connect
@@ -658,12 +658,12 @@ findso:
}
/* CTL_ALIAS: Do nothing, tcp_fconnect will be called on it */
}
-
+
if (so->so_emu & EMU_NOCONNECT) {
so->so_emu &= ~EMU_NOCONNECT;
goto cont_input;
}
-
+
if((tcp_fconnect(so) == -1) && (errno != EINPROGRESS) && (errno != EWOULDBLOCK)) {
u_char code=ICMP_UNREACH_NET;
DEBUG_MISC((dfd," tcp fconnect errno = %d-%s\n",
@@ -699,7 +699,7 @@ findso:
}
return;
- cont_conn:
+ cont_conn:
/* m==NULL
* Check if the connect succeeded
*/
@@ -707,14 +707,14 @@ findso:
tp = tcp_close(tp);
goto dropwithreset;
}
- cont_input:
+ cont_input:
tcp_template(tp);
-
+
if (optp)
tcp_dooptions(tp, (u_char *)optp, optlen, ti);
/* , */
/* &ts_present, &ts_val, &ts_ecr); */
-
+
if (iss)
tp->iss = iss;
else
@@ -770,7 +770,7 @@ findso:
tcpstat.tcps_connects++;
soisfconnected(so);
tp->t_state = TCPS_ESTABLISHED;
-
+
/* Do window scaling on this connection? */
/* if ((tp->t_flags & (TF_RCVD_SCALE|TF_REQ_SCALE)) ==
* (TF_RCVD_SCALE|TF_REQ_SCALE)) {
@@ -866,7 +866,7 @@ trimthenstep6:
* of sequence; drop it.
*/
tiflags &= ~TH_FIN;
-
+
/*
* Send an ACK to resynchronize and drop any data.
* But keep on processing for RST or ACK.
@@ -1022,7 +1022,7 @@ trimthenstep6:
* The first data byte already in the buffer will get
* lost if no correction is made. This is only needed for
* SS_CTL since the buffer is empty otherwise.
- * tp->snd_una++; or:
+ * tp->snd_una++; or:
*/
tp->snd_una=ti->ti_ack;
if (so->so_state & SS_CTL) {
@@ -1040,7 +1040,7 @@ trimthenstep6:
} else {
soisfconnected(so);
}
-
+
/* Do window scaling? */
/* if ((tp->t_flags & (TF_RCVD_SCALE|TF_REQ_SCALE)) ==
* (TF_RCVD_SCALE|TF_REQ_SCALE)) {
@@ -1159,7 +1159,7 @@ trimthenstep6:
/* if (ts_present)
* tcp_xmit_timer(tp, tcp_now-ts_ecr+1);
* else
- */
+ */
if (tp->t_rtt && SEQ_GT(ti->ti_ack, tp->t_rtseq))
tcp_xmit_timer(tp,tp->t_rtt);
@@ -1328,7 +1328,7 @@ step6:
so->so_urgc = so->so_rcv.sb_cc +
(tp->rcv_up - tp->rcv_nxt); /* -1; */
tp->rcv_up = ti->ti_seq + ti->ti_urp;
-
+
}
} else
/*
@@ -1379,7 +1379,7 @@ dodata:
*/
/* sofcantrcvmore(so); */
sofwdrain(so);
-
+
tp->t_flags |= TF_ACKNOW;
tp->rcv_nxt++;
}
diff --git a/slirp/tcp_output.c b/slirp/tcp_output.c
index b4be123dc6..3eddfd38e2 100644
--- a/slirp/tcp_output.c
+++ b/slirp/tcp_output.c
@@ -356,7 +356,7 @@ send:
}
m->m_data += if_maxlinkhdr;
m->m_len = hdrlen;
-
+
/*
* This will always succeed, since we make sure our mbufs
* are big enough to hold one MSS packet + header + ... etc.
@@ -449,7 +449,7 @@ send:
if (SEQ_GT(tp->snd_up, tp->snd_una)) {
ti->ti_urp = htons((u_int16_t)(tp->snd_up - ntohl(ti->ti_seq)));
-#ifdef notdef
+#ifdef notdef
if (SEQ_GT(tp->snd_up, tp->snd_nxt)) {
ti->ti_urp = htons((u_int16_t)(tp->snd_up - tp->snd_nxt));
#endif
@@ -533,12 +533,12 @@ send:
m->m_len = hdrlen + len; /* XXX Needed? m_len should be correct */
{
-
+
((struct ip *)ti)->ip_len = m->m_len;
((struct ip *)ti)->ip_ttl = ip_defttl;
((struct ip *)ti)->ip_tos = so->so_iptos;
-
+
/* #if BSD >= 43 */
/* Don't do IP options... */
/* error = ip_output(m, tp->t_inpcb->inp_options, &tp->t_inpcb->inp_route,
diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c
index 547a7f6793..3814ec19b2 100644
--- a/slirp/tcp_subr.c
+++ b/slirp/tcp_subr.c
@@ -155,7 +155,7 @@ tcp_respond(tp, ti, m, ack, seq, flags)
* the mbuf point to ti
*/
m->m_data = (caddr_t)ti;
-
+
m->m_len = sizeof (struct tcpiphdr);
tlen = 0;
#define xchg(a,b,type) { type t; t=a; a=b; b=t; }
@@ -396,7 +396,7 @@ int tcp_fconnect(so)
struct socket *so;
{
int ret=0;
-
+
DEBUG_CALL("tcp_fconnect");
DEBUG_ARG("so = %lx", (long )so);
@@ -409,7 +409,7 @@ int tcp_fconnect(so)
setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(opt ));
opt = 1;
setsockopt(s,SOL_SOCKET,SO_OOBINLINE,(char *)&opt,sizeof(opt ));
-
+
addr.sin_family = AF_INET;
if ((so->so_faddr.s_addr & htonl(0xffffff00)) == special_addr.s_addr) {
/* It's an alias */
@@ -425,13 +425,13 @@ int tcp_fconnect(so)
} else
addr.sin_addr = so->so_faddr;
addr.sin_port = so->so_fport;
-
+
DEBUG_MISC((dfd, " connect()ing, addr.sin_port=%d, "
"addr.sin_addr.s_addr=%.16s\n",
ntohs(addr.sin_port), inet_ntoa(addr.sin_addr)));
/* We don't care what port we get */
ret = connect(s,(struct sockaddr *)&addr,sizeof (addr));
-
+
/*
* If it's not in progress, it failed, so we just return 0,
* without clearing SS_NOFDREF
@@ -573,7 +573,7 @@ struct tos_t tcptos[] = {
};
struct emu_t *tcpemu = 0;
-
+
/*
* Return TOS according to the above table
*/
@@ -618,7 +618,7 @@ int do_echo = -1;
* more checks are needed here
*
* XXX Assumes the whole command came in one packet
- *
+ *
* XXX Some ftp clients will have their TOS set to
* LOWDELAY and so Nagel will kick in. Because of this,
* we'll get the first letter, followed by the rest, so
@@ -648,18 +648,18 @@ tcp_emu(so, m)
switch(so->so_emu) {
int x, i;
-
+
case EMU_IDENT:
/*
* Identification protocol as per rfc-1413
*/
-
+
{
struct socket *tmpso;
struct sockaddr_in addr;
int addrlen = sizeof(struct sockaddr_in);
struct sbuf *so_rcv = &so->so_rcv;
-
+
memcpy(so_rcv->sb_wptr, m->m_data, m->m_len);
so_rcv->sb_wptr += m->m_len;
so_rcv->sb_rptr += m->m_len;
@@ -688,7 +688,7 @@ tcp_emu(so, m)
m_free(m);
return 0;
}
-
+
#if 0
case EMU_RLOGIN:
/*
@@ -703,7 +703,7 @@ tcp_emu(so, m)
char term[100];
struct sbuf *so_snd = &so->so_snd;
struct sbuf *so_rcv = &so->so_rcv;
-
+
/* First check if they have a priveladged port, or too much data has arrived */
if (ntohs(so->so_lport) > 1023 || ntohs(so->so_lport) < 512 ||
(m->m_len + so_rcv->sb_wptr) > (so_rcv->sb_data + so_rcv->sb_datalen)) {
@@ -714,13 +714,13 @@ tcp_emu(so, m)
m_free(m);
return 0;
}
-
+
/* Append the current data */
memcpy(so_rcv->sb_wptr, m->m_data, m->m_len);
so_rcv->sb_wptr += m->m_len;
so_rcv->sb_rptr += m->m_len;
m_free(m);
-
+
/*
* Check if we have all the initial options,
* and build argument list to rlogin while we're here
@@ -752,10 +752,10 @@ tcp_emu(so, m)
}
}
}
-
+
if (n != 4)
return 0;
-
+
/* We have it, set our term variable and fork_exec() */
#ifdef HAVE_SETENV
setenv("TERM", term, 1);
@@ -765,15 +765,15 @@ tcp_emu(so, m)
fork_exec(so, args, 2);
term[0] = 0;
so->so_emu = 0;
-
+
/* And finally, send the client a 0 character */
so_snd->sb_wptr[0] = 0;
so_snd->sb_wptr++;
so_snd->sb_cc++;
-
+
return 0;
}
-
+
case EMU_RSH:
/*
* rsh emulation
@@ -787,7 +787,7 @@ tcp_emu(so, m)
char *args;
struct sbuf *so_snd = &so->so_snd;
struct sbuf *so_rcv = &so->so_rcv;
-
+
/* First check if they have a priveladged port, or too much data has arrived */
if (ntohs(so->so_lport) > 1023 || ntohs(so->so_lport) < 512 ||
(m->m_len + so_rcv->sb_wptr) > (so_rcv->sb_data + so_rcv->sb_datalen)) {
@@ -798,13 +798,13 @@ tcp_emu(so, m)
m_free(m);
return 0;
}
-
+
/* Append the current data */
memcpy(so_rcv->sb_wptr, m->m_data, m->m_len);
so_rcv->sb_wptr += m->m_len;
so_rcv->sb_rptr += m->m_len;
m_free(m);
-
+
/*
* Check if we have all the initial options,
* and build argument list to rlogin while we're here
@@ -846,9 +846,9 @@ tcp_emu(so, m)
ns->so_iptos = tcp_tos(ns);
tp = sototcpcb(ns);
-
+
tcp_template(tp);
-
+
/* Compute window scaling to request. */
/* while (tp->request_r_scale < TCP_MAX_WINSHIFT &&
* (TCP_MAXWIN << tp->request_r_scale) < so->so_rcv.sb_hiwat)
@@ -858,7 +858,7 @@ tcp_emu(so, m)
/*soisfconnecting(ns);*/
tcpstat.tcps_connattempt++;
-
+
tp->t_state = TCPS_SYN_SENT;
tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT;
tp->iss = tcp_iss;
@@ -877,19 +877,19 @@ tcp_emu(so, m)
}
}
}
-
+
if (n != 4)
return 0;
-
+
rsh_exec(so,so->extra, user, inet_ntoa(so->so_faddr), args);
so->so_emu = 0;
so->extra=NULL;
-
+
/* And finally, send the client a 0 character */
so_snd->sb_wptr[0] = 0;
so_snd->sb_wptr++;
so_snd->sb_cc++;
-
+
return 0;
}
@@ -898,7 +898,7 @@ tcp_emu(so, m)
int num;
struct sbuf *so_snd = &so->so_snd;
struct sbuf *so_rcv = &so->so_rcv;
-
+
/*
* If there is binary data here, we save it in so->so_m
*/
@@ -913,16 +913,16 @@ tcp_emu(so, m)
}
}
} /* if(so->so_m==NULL) */
-
+
/*
* Append the line
*/
sbappendsb(so_rcv, m);
-
+
/* To avoid going over the edge of the buffer, we reset it */
if (so_snd->sb_cc == 0)
so_snd->sb_wptr = so_snd->sb_rptr = so_snd->sb_data;
-
+
/*
* A bit of a hack:
* If the first packet we get here is 1 byte long, then it
@@ -941,13 +941,13 @@ tcp_emu(so, m)
tcp_output(sototcpcb(so)); /* XXX */
} else
m_free(m);
-
+
num = 0;
while (num < so->so_rcv.sb_cc) {
if (*(so->so_rcv.sb_rptr + num) == '\n' ||
*(so->so_rcv.sb_rptr + num) == '\r') {
int n;
-
+
*(so_rcv->sb_rptr + num) = 0;
if (ctl_password && !ctl_password_ok) {
/* Need a password */
@@ -984,36 +984,36 @@ do_prompt:
}
return 0;
}
-#endif
+#endif
case EMU_FTP: /* ftp */
*(m->m_data+m->m_len) = 0; /* NULL terminate for strstr */
if ((bptr = (char *)strstr(m->m_data, "ORT")) != NULL) {
/*
* Need to emulate the PORT command
- */
+ */
x = sscanf(bptr, "ORT %d,%d,%d,%d,%d,%d\r\n%256[^\177]",
&n1, &n2, &n3, &n4, &n5, &n6, buff);
if (x < 6)
return 1;
-
+
laddr = htonl((n1 << 24) | (n2 << 16) | (n3 << 8) | (n4));
lport = htons((n5 << 8) | (n6));
-
+
if ((so = solisten(0, laddr, lport, SS_FACCEPTONCE)) == NULL)
return 1;
-
+
n6 = ntohs(so->so_fport);
-
+
n5 = (n6 >> 8) & 0xff;
n6 &= 0xff;
-
+
laddr = ntohl(so->so_faddr.s_addr);
-
+
n1 = ((laddr >> 24) & 0xff);
n2 = ((laddr >> 16) & 0xff);
n3 = ((laddr >> 8) & 0xff);
n4 = (laddr & 0xff);
-
+
m->m_len = bptr - m->m_data; /* Adjust length */
m->m_len += sprintf(bptr,"ORT %d,%d,%d,%d,%d,%d\r\n%s",
n1, n2, n3, n4, n5, n6, x==7?buff:"");
@@ -1026,34 +1026,34 @@ do_prompt:
&n1, &n2, &n3, &n4, &n5, &n6, buff);
if (x < 6)
return 1;
-
+
laddr = htonl((n1 << 24) | (n2 << 16) | (n3 << 8) | (n4));
lport = htons((n5 << 8) | (n6));
-
+
if ((so = solisten(0, laddr, lport, SS_FACCEPTONCE)) == NULL)
return 1;
-
+
n6 = ntohs(so->so_fport);
-
+
n5 = (n6 >> 8) & 0xff;
n6 &= 0xff;
-
+
laddr = ntohl(so->so_faddr.s_addr);
-
+
n1 = ((laddr >> 24) & 0xff);
n2 = ((laddr >> 16) & 0xff);
n3 = ((laddr >> 8) & 0xff);
n4 = (laddr & 0xff);
-
+
m->m_len = bptr - m->m_data; /* Adjust length */
m->m_len += sprintf(bptr,"27 Entering Passive Mode (%d,%d,%d,%d,%d,%d)\r\n%s",
n1, n2, n3, n4, n5, n6, x==7?buff:"");
-
+
return 1;
}
-
+
return 1;
-
+
case EMU_KSH:
/*
* The kshell (Kerberos rsh) and shell services both pass
@@ -1072,7 +1072,7 @@ do_prompt:
(so = solisten(0, so->so_laddr.s_addr, htons(lport), SS_FACCEPTONCE)) != NULL)
m->m_len = sprintf(m->m_data, "%d", ntohs(so->so_fport))+1;
return 1;
-
+
case EMU_IRC:
/*
* Need to emulate DCC CHAT, DCC SEND and DCC MOVE
@@ -1080,12 +1080,12 @@ do_prompt:
*(m->m_data+m->m_len) = 0; /* NULL terminate the string for strstr */
if ((bptr = (char *)strstr(m->m_data, "DCC")) == NULL)
return 1;
-
+
/* The %256s is for the broken mIRC */
if (sscanf(bptr, "DCC CHAT %256s %u %u", buff, &laddr, &lport) == 3) {
if ((so = solisten(0, htonl(laddr), htons(lport), SS_FACCEPTONCE)) == NULL)
return 1;
-
+
m->m_len = bptr - m->m_data; /* Adjust length */
m->m_len += sprintf(bptr, "DCC CHAT chat %lu %u%c\n",
(unsigned long)ntohl(so->so_faddr.s_addr),
@@ -1093,7 +1093,7 @@ do_prompt:
} else if (sscanf(bptr, "DCC SEND %256s %u %u %u", buff, &laddr, &lport, &n1) == 4) {
if ((so = solisten(0, htonl(laddr), htons(lport), SS_FACCEPTONCE)) == NULL)
return 1;
-
+
m->m_len = bptr - m->m_data; /* Adjust length */
m->m_len += sprintf(bptr, "DCC SEND %s %lu %u %u%c\n",
buff, (unsigned long)ntohl(so->so_faddr.s_addr),
@@ -1101,7 +1101,7 @@ do_prompt:
} else if (sscanf(bptr, "DCC MOVE %256s %u %u %u", buff, &laddr, &lport, &n1) == 4) {
if ((so = solisten(0, htonl(laddr), htons(lport), SS_FACCEPTONCE)) == NULL)
return 1;
-
+
m->m_len = bptr - m->m_data; /* Adjust length */
m->m_len += sprintf(bptr, "DCC MOVE %s %lu %u %u%c\n",
buff, (unsigned long)ntohl(so->so_faddr.s_addr),
@@ -1120,43 +1120,43 @@ do_prompt:
* any more.
*
* A typical packet for player version 1.0 (release version):
- *
+ *
* 0000:50 4E 41 00 05
* 0000:00 01 00 02 1B D7 00 00 67 E6 6C DC 63 00 12 50 .....×..gælÜc..P
* 0010:4E 43 4C 49 45 4E 54 20 31 30 31 20 41 4C 50 48 NCLIENT 101 ALPH
* 0020:41 6C 00 00 52 00 17 72 61 66 69 6C 65 73 2F 76 Al..R..rafiles/v
* 0030:6F 61 2F 65 6E 67 6C 69 73 68 5F 2E 72 61 79 42 oa/english_.rayB
- *
+ *
* Now the port number 0x1BD7 is found at offset 0x04 of the
* Now the port number 0x1BD7 is found at offset 0x04 of the
* second packet. This time we received five bytes first and
* then the rest. You never know how many bytes you get.
*
* A typical packet for player version 2.0 (beta):
- *
+ *
* 0000:50 4E 41 00 06 00 02 00 00 00 01 00 02 1B C1 00 PNA...........Á.
* 0010:00 67 75 78 F5 63 00 0A 57 69 6E 32 2E 30 2E 30 .guxõc..Win2.0.0
* 0020:2E 35 6C 00 00 52 00 1C 72 61 66 69 6C 65 73 2F .5l..R..rafiles/
* 0030:77 65 62 73 69 74 65 2F 32 30 72 65 6C 65 61 73 website/20releas
* 0040:65 2E 72 61 79 53 00 00 06 36 42 e.rayS...6B
- *
+ *
* Port number 0x1BC1 is found at offset 0x0d.
- *
+ *
* This is just a horrible switch statement. Variable ra tells
* us where we're going.
*/
-
+
bptr = m->m_data;
while (bptr < m->m_data + m->m_len) {
u_short p;
static int ra = 0;
char ra_tbl[4];
-
+
ra_tbl[0] = 0x50;
ra_tbl[1] = 0x4e;
ra_tbl[2] = 0x41;
ra_tbl[3] = 0;
-
+
switch (ra) {
case 0:
case 2:
@@ -1166,7 +1166,7 @@ do_prompt:
continue;
}
break;
-
+
case 1:
/*
* We may get 0x50 several times, ignore them
@@ -1180,14 +1180,14 @@ do_prompt:
continue;
}
break;
-
+
case 4:
/*
* skip version number
*/
bptr++;
break;
-
+
case 5:
/*
* The difference between versions 1.0 and
@@ -1198,19 +1198,19 @@ do_prompt:
bptr += 8;
else
bptr += 4;
- break;
-
+ break;
+
case 6:
/* This is the field containing the port
* number that RA-player is listening to.
*/
lport = (((u_char*)bptr)[0] << 8)
+ ((u_char *)bptr)[1];
- if (lport < 6970)
+ if (lport < 6970)
lport += 256; /* don't know why */
if (lport < 6970 || lport > 7170)
return 1; /* failed */
-
+
/* try to get udp port between 6970 - 7170 */
for (p = 6970; p < 7071; p++) {
if (udp_listen( htons(p),
@@ -1226,15 +1226,15 @@ do_prompt:
*(u_char *)bptr++ = p & 0xff;
ra = 0;
return 1; /* port redirected, we're done */
- break;
-
+ break;
+
default:
- ra = 0;
+ ra = 0;
}
ra++;
}
- return 1;
-
+ return 1;
+
default:
/* Ooops, not emulated, won't call tcp_emu again */
so->so_emu = 0;
@@ -1274,7 +1274,7 @@ tcp_ctl(so)
switch(command) {
default: /* Check for exec's */
-
+
/*
* Check if it's pty_exec
*/
@@ -1285,12 +1285,12 @@ tcp_ctl(so)
goto do_exec;
}
}
-
+
/*
* Nothing bound..
*/
/* tcp_fconnect(so); */
-
+
/* FALLTHROUGH */
case CTL_ALIAS:
sb->sb_cc = sprintf(sb->sb_wptr,
@@ -1301,7 +1301,7 @@ tcp_ctl(so)
do_exec:
DEBUG_MISC((dfd, " executing %s \n",ex_ptr->ex_exec));
return(fork_exec(so, ex_ptr->ex_exec, do_pty));
-
+
#if 0
case CTL_CMD:
for (tmpso = tcb.so_next; tmpso != &tcb; tmpso = tmpso->so_next) {
diff --git a/slirp/tcp_timer.c b/slirp/tcp_timer.c
index 044c2b8f7d..cc1bd50c07 100644
--- a/slirp/tcp_timer.c
+++ b/slirp/tcp_timer.c
@@ -164,12 +164,12 @@ tcp_timers(tp, timer)
* to a longer retransmit interval and retransmit one segment.
*/
case TCPT_REXMT:
-
+
/*
* XXXXX If a packet has timed out, then remove all the queued
* packets for that session.
*/
-
+
if (++tp->t_rxtshift > TCP_MAXRXTSHIFT) {
/*
* This is a hack to suit our terminal server here at the uni of canberra
@@ -185,7 +185,7 @@ tcp_timers(tp, timer)
*
* *sigh*
*/
-
+
tp->t_maxseg >>= 1;
if (tp->t_maxseg < 32) {
/*
@@ -197,7 +197,7 @@ tcp_timers(tp, timer)
/* tp->t_softerror : ETIMEDOUT); */ /* XXX */
return (tp); /* XXX */
}
-
+
/*
* Set rxtshift to 6, which is still at the maximum
* backoff time
diff --git a/slirp/tftp.c b/slirp/tftp.c
index f16530db6a..2b2bf2c5a2 100644
--- a/slirp/tftp.c
+++ b/slirp/tftp.c
@@ -27,10 +27,10 @@
struct tftp_session {
int in_use;
unsigned char filename[TFTP_FILENAME_MAX];
-
+
struct in_addr client_ip;
u_int16_t client_port;
-
+
int timestamp;
};
@@ -146,14 +146,14 @@ static int tftp_send_oack(struct tftp_session *spt,
m->m_data += if_maxlinkhdr;
tp = (void *)m->m_data;
m->m_data += sizeof(struct udpiphdr);
-
+
tp->tp_op = htons(TFTP_OACK);
n += sprintf(tp->x.tp_buf + n, "%s", key) + 1;
n += sprintf(tp->x.tp_buf + n, "%u", value) + 1;
saddr.sin_addr = recv_tp->ip.ip_dst;
saddr.sin_port = recv_tp->udp.uh_dport;
-
+
daddr.sin_addr = spt->client_ip;
daddr.sin_port = spt->client_port;
@@ -186,7 +186,7 @@ static int tftp_send_error(struct tftp_session *spt,
m->m_data += if_maxlinkhdr;
tp = (void *)m->m_data;
m->m_data += sizeof(struct udpiphdr);
-
+
tp->tp_op = htons(TFTP_ERROR);
tp->x.tp_error.tp_error_code = htons(errorcode);
strcpy(tp->x.tp_error.tp_msg, msg);
@@ -233,7 +233,7 @@ static int tftp_send_data(struct tftp_session *spt,
m->m_data += if_maxlinkhdr;
tp = (void *)m->m_data;
m->m_data += sizeof(struct udpiphdr);
-
+
tp->tp_op = htons(TFTP_DATA);
tp->x.tp_data.tp_block_nr = htons(block_nr);
@@ -297,23 +297,23 @@ static void tftp_handle_rrq(struct tftp_t *tp, int pktlen)
else {
return;
}
-
+
if (src[k] == '\0') {
break;
}
}
-
+
if (k >= n) {
return;
}
-
+
k++;
-
+
/* check mode */
if ((n - k) < 6) {
return;
}
-
+
if (memcmp(&src[k], "octet\0", 6) != 0) {
tftp_send_error(spt, 4, "Unsupported transfer mode", tp);
return;
@@ -338,7 +338,7 @@ static void tftp_handle_rrq(struct tftp_t *tp, int pktlen)
}
/* check if the file exists */
-
+
if (tftp_read_data(spt, 0, spt->filename, 0) < 0) {
tftp_send_error(spt, 1, "File not found", tp);
return;
diff --git a/slirp/udp.c b/slirp/udp.c
index 2504d119a4..44900ff144 100644
--- a/slirp/udp.c
+++ b/slirp/udp.c
@@ -168,7 +168,7 @@ udp_input(m, iphlen)
if (so->so_lport != uh->uh_sport ||
so->so_laddr.s_addr != ip->ip_src.s_addr) {
struct socket *tmp;
-
+
for (tmp = udb.so_next; tmp != &udb; tmp = tmp->so_next) {
if (tmp->so_lport == uh->uh_sport &&
tmp->so_laddr.s_addr == ip->ip_src.s_addr) {
@@ -198,17 +198,17 @@ udp_input(m, iphlen)
sofree(so);
goto bad;
}
-
+
/*
* Setup fields
*/
/* udp_last_so = so; */
so->so_laddr = ip->ip_src;
so->so_lport = uh->uh_sport;
-
+
if ((so->so_iptos = udp_tos(so)) == 0)
so->so_iptos = ip->ip_tos;
-
+
/*
* XXXXX Here, check if it's in udpexec_list,
* and if it is, do the fork_exec() etc.
@@ -233,7 +233,7 @@ udp_input(m, iphlen)
m->m_data -= iphlen;
*ip=save_ip;
DEBUG_MISC((dfd,"udp tx errno = %d-%s\n",errno,strerror(errno)));
- icmp_error(m, ICMP_UNREACH,ICMP_UNREACH_NET, 0,strerror(errno));
+ icmp_error(m, ICMP_UNREACH,ICMP_UNREACH_NET, 0,strerror(errno));
}
m_free(so->so_m); /* used for ICMP if error on sorecvfrom */
@@ -320,7 +320,7 @@ int udp_output(struct socket *so, struct mbuf *m,
}
daddr.sin_addr = so->so_laddr;
daddr.sin_port = so->so_lport;
-
+
return udp_output2(so, m, &saddr, &daddr, so->so_iptos);
}
@@ -449,7 +449,7 @@ struct cu_header {
*/
if (getsockname(so->s, (struct sockaddr *)&addr, &addrlen) < 0)
return;
-
+
#define IS_OLD (so->so_emu == EMU_TALK)
#define COPY_MSG(dest, src) { dest->type = src->type; \
@@ -480,10 +480,10 @@ struct cu_header {
OTOSIN(nmsg, ctl_addr)->sin_addr = our_addr;
strncpy(nmsg->l_name, getlogin(), NAME_SIZE_OLD);
}
-
+
if (type == LOOK_UP)
return; /* for LOOK_UP this is enough */
-
+
if (IS_OLD) { /* make a copy of the message */
COPY_MSG(nmsg, omsg);
nmsg->vers = 1;
@@ -507,39 +507,39 @@ struct cu_header {
if (type == ANNOUNCE) {
int s;
u_short temp_port;
-
+
for(req = req_tbl; req; req = req->next)
if (so == req->udp_so)
break; /* found it */
-
+
if (!req) { /* no entry for so, create new */
req = (struct talk_request *)
malloc(sizeof(struct talk_request));
req->udp_so = so;
- req->tcp_so = solisten(0,
+ req->tcp_so = solisten(0,
OTOSIN(omsg, addr)->sin_addr.s_addr,
OTOSIN(omsg, addr)->sin_port,
SS_FACCEPTONCE);
req->next = req_tbl;
req_tbl = req;
- }
-
+ }
+
/* replace port number in addr field */
addrlen = sizeof(addr);
getsockname(req->tcp_so->s,
(struct sockaddr *) &addr,
- &addrlen);
+ &addrlen);
OTOSIN(omsg, addr)->sin_port = addr.sin_port;
OTOSIN(omsg, addr)->sin_addr = our_addr;
OTOSIN(nmsg, addr)->sin_port = addr.sin_port;
- OTOSIN(nmsg, addr)->sin_addr = our_addr;
-
+ OTOSIN(nmsg, addr)->sin_addr = our_addr;
+
/* send LEAVE_INVITEs */
temp_port = OTOSIN(omsg, ctl_addr)->sin_port;
OTOSIN(omsg, ctl_addr)->sin_port = 0;
OTOSIN(nmsg, ctl_addr)->sin_port = 0;
- omsg->type = nmsg->type = LEAVE_INVITE;
-
+ omsg->type = nmsg->type = LEAVE_INVITE;
+
s = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
addr.sin_addr = our_addr;
addr.sin_family = AF_INET;
@@ -555,22 +555,22 @@ struct cu_header {
OTOSIN(omsg, ctl_addr)->sin_port = temp_port;
OTOSIN(nmsg, ctl_addr)->sin_port = temp_port;
}
-
+
/*
* If it is a DELETE message, we send a copy to the
* local daemons. Then we delete the entry corresponding
* to our socket from the request table.
*/
-
+
if (type == DELETE) {
struct talk_request *temp_req, *req_next;
int s;
u_short temp_port;
-
+
temp_port = OTOSIN(omsg, ctl_addr)->sin_port;
OTOSIN(omsg, ctl_addr)->sin_port = 0;
OTOSIN(nmsg, ctl_addr)->sin_port = 0;
-
+
s = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
addr.sin_addr = our_addr;
addr.sin_family = AF_INET;
@@ -581,7 +581,7 @@ struct cu_header {
sendto(s, (char *)nmsg, sizeof(*nmsg), 0,
(struct sockaddr *)&addr, sizeof(addr));
closesocket(s);
-
+
OTOSIN(omsg, ctl_addr)->sin_port = temp_port;
OTOSIN(nmsg, ctl_addr)->sin_port = temp_port;
@@ -604,10 +604,10 @@ struct cu_header {
}
}
}
-
- return;
+
+ return;
#endif
-
+
case EMU_CUSEEME:
/*
@@ -623,7 +623,7 @@ struct cu_header {
cu_head->s_port = addr.sin_port;
cu_head->so_addr = our_addr.s_addr;
}
-
+
return;
}
}