mirror of
https://github.com/kanjitalk755/macemu.git
synced 2025-01-06 05:33:29 +00:00
revert BasiliskII/src/slirp/*
This commit is contained in:
parent
a944344f84
commit
aa24dbc3df
@ -1,2 +1 @@
|
|||||||
qemu 0.9.0 (2007/02/05)
|
qemu 0.9.0 (2007/02/05)
|
||||||
Plus 64 Bits Patchs
|
|
0
BasiliskII/src/slirp/bootp.c
Executable file → Normal file
0
BasiliskII/src/slirp/bootp.c
Executable file → Normal file
2
BasiliskII/src/slirp/bootp.h
Executable file → Normal file
2
BasiliskII/src/slirp/bootp.h
Executable file → Normal file
@ -115,7 +115,7 @@ struct bootp_t {
|
|||||||
} PACKED__;
|
} PACKED__;
|
||||||
|
|
||||||
#ifdef PRAGMA_PACK_SUPPORTED
|
#ifdef PRAGMA_PACK_SUPPORTED
|
||||||
#pragma pack(0)
|
#pragma pack(PACK_RESET)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void bootp_input(struct mbuf *m);
|
void bootp_input(struct mbuf *m);
|
||||||
|
0
BasiliskII/src/slirp/cksum.c
Executable file → Normal file
0
BasiliskII/src/slirp/cksum.c
Executable file → Normal file
0
BasiliskII/src/slirp/ctl.h
Executable file → Normal file
0
BasiliskII/src/slirp/ctl.h
Executable file → Normal file
15
BasiliskII/src/slirp/debug.c
Executable file → Normal file
15
BasiliskII/src/slirp/debug.c
Executable file → Normal file
@ -16,8 +16,6 @@ int dostats = 0;
|
|||||||
#endif
|
#endif
|
||||||
int slirp_debug = 0;
|
int slirp_debug = 0;
|
||||||
|
|
||||||
extern char *strerror _P((int));
|
|
||||||
|
|
||||||
/* Carry over one item from main.c so that the tty's restored.
|
/* Carry over one item from main.c so that the tty's restored.
|
||||||
* Only done when the tty being used is /dev/tty --RedWolf */
|
* Only done when the tty being used is /dev/tty --RedWolf */
|
||||||
extern struct termios slirp_tty_settings;
|
extern struct termios slirp_tty_settings;
|
||||||
@ -294,6 +292,7 @@ mbufstats()
|
|||||||
void
|
void
|
||||||
sockstats()
|
sockstats()
|
||||||
{
|
{
|
||||||
|
char addr[INET_ADDRSTRLEN];
|
||||||
char buff[256];
|
char buff[256];
|
||||||
int n;
|
int n;
|
||||||
struct socket *so;
|
struct socket *so;
|
||||||
@ -311,9 +310,11 @@ sockstats()
|
|||||||
buff[17] = 0;
|
buff[17] = 0;
|
||||||
lprint("%s %3d %15s %5d ",
|
lprint("%s %3d %15s %5d ",
|
||||||
buff, so->s,
|
buff, so->s,
|
||||||
inet_ntoa(so->so_laddr), ntohs(so->so_lport));
|
inet_ntop(AF_INET, &so->so_laddr, addr, sizeof(addr)),
|
||||||
|
ntohs(so->so_lport));
|
||||||
lprint("%15s %5d %5d %5d\r\n",
|
lprint("%15s %5d %5d %5d\r\n",
|
||||||
inet_ntoa(so->so_faddr), ntohs(so->so_fport),
|
inet_ntop(AF_INET, &so->so_faddr, addr, sizeof(addr)),
|
||||||
|
ntohs(so->so_fport),
|
||||||
so->so_rcv.sb_cc, so->so_snd.sb_cc);
|
so->so_rcv.sb_cc, so->so_snd.sb_cc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,9 +326,11 @@ sockstats()
|
|||||||
buff[17] = 0;
|
buff[17] = 0;
|
||||||
lprint("%s %3d %15s %5d ",
|
lprint("%s %3d %15s %5d ",
|
||||||
buff, so->s,
|
buff, so->s,
|
||||||
inet_ntoa(so->so_laddr), ntohs(so->so_lport));
|
inet_ntop(AF_INET, &so->so_laddr, addr, sizeof(addr)),
|
||||||
|
ntohs(so->so_lport));
|
||||||
lprint("%15s %5d %5d %5d\r\n",
|
lprint("%15s %5d %5d %5d\r\n",
|
||||||
inet_ntoa(so->so_faddr), ntohs(so->so_fport),
|
inet_ntop(AF_INET, &so->so_faddr, addr, sizeof(addr)),
|
||||||
|
ntohs(so->so_fport),
|
||||||
so->so_rcv.sb_cc, so->so_snd.sb_cc);
|
so->so_rcv.sb_cc, so->so_snd.sb_cc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
22
BasiliskII/src/slirp/debug.h
Executable file → Normal file
22
BasiliskII/src/slirp/debug.h
Executable file → Normal file
@ -36,15 +36,15 @@ extern int slirp_debug;
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void debug_init _P((char *, int));
|
void debug_init(char *, int);
|
||||||
//void ttystats _P((struct ttys *));
|
//void ttystats(struct ttys *);
|
||||||
void allttystats _P((void));
|
void allttystats(void);
|
||||||
void ipstats _P((void));
|
void ipstats(void);
|
||||||
void vjstats _P((void));
|
void vjstats(void);
|
||||||
void tcpstats _P((void));
|
void tcpstats(void);
|
||||||
void udpstats _P((void));
|
void udpstats(void);
|
||||||
void icmpstats _P((void));
|
void icmpstats(void);
|
||||||
void mbufstats _P((void));
|
void mbufstats(void);
|
||||||
void sockstats _P((void));
|
void sockstats(void);
|
||||||
void slirp_exit _P((int));
|
void slirp_exit(int);
|
||||||
|
|
||||||
|
0
BasiliskII/src/slirp/icmp_var.h
Executable file → Normal file
0
BasiliskII/src/slirp/icmp_var.h
Executable file → Normal file
9
BasiliskII/src/slirp/if.c
Executable file → Normal file
9
BasiliskII/src/slirp/if.c
Executable file → Normal file
@ -7,11 +7,11 @@
|
|||||||
|
|
||||||
#include <slirp.h>
|
#include <slirp.h>
|
||||||
|
|
||||||
int if_mtu, if_mru;
|
size_t if_mtu, if_mru;
|
||||||
int if_comp;
|
int if_comp;
|
||||||
int if_maxlinkhdr;
|
int if_maxlinkhdr;
|
||||||
int if_queued = 0; /* Number of packets queued so far */
|
int if_queued = 0; /* Number of packets queued so far */
|
||||||
int if_thresh = 10; /* Number of packets queued before we start sending
|
int if_thresh = 10; /* Number of packets queued before we start sending
|
||||||
* (to prevent allocing too many mbufs) */
|
* (to prevent allocing too many mbufs) */
|
||||||
|
|
||||||
struct mbuf if_fastq; /* fast queue (for interactive data) */
|
struct mbuf if_fastq; /* fast queue (for interactive data) */
|
||||||
@ -116,7 +116,8 @@ if_input(ttyp)
|
|||||||
DEBUG_MISC((dfd, " read %d bytes\n", if_n));
|
DEBUG_MISC((dfd, " read %d bytes\n", if_n));
|
||||||
|
|
||||||
if (if_n <= 0) {
|
if (if_n <= 0) {
|
||||||
if (if_n == 0 || (errno != EINTR && errno != EAGAIN)) {
|
int error = WSAGetLastError();
|
||||||
|
if (if_n == 0 || (error != WSAEINTR && error != EAGAIN)) {
|
||||||
if (ttyp->up)
|
if (ttyp->up)
|
||||||
link_up--;
|
link_up--;
|
||||||
tty_detached(ttyp, 0);
|
tty_detached(ttyp, 0);
|
||||||
|
4
BasiliskII/src/slirp/if.h
Executable file → Normal file
4
BasiliskII/src/slirp/if.h
Executable file → Normal file
@ -15,8 +15,8 @@
|
|||||||
|
|
||||||
/* Needed for FreeBSD */
|
/* Needed for FreeBSD */
|
||||||
#undef if_mtu
|
#undef if_mtu
|
||||||
extern int if_mtu;
|
extern size_t if_mtu;
|
||||||
extern int if_mru; /* MTU and MRU */
|
extern size_t if_mru; /* MTU and MRU */
|
||||||
extern int if_comp; /* Flags for compression */
|
extern int if_comp; /* Flags for compression */
|
||||||
extern int if_maxlinkhdr;
|
extern int if_maxlinkhdr;
|
||||||
extern int if_queued; /* Number of packets queued so far */
|
extern int if_queued; /* Number of packets queued so far */
|
||||||
|
72
BasiliskII/src/slirp/ip.h
Executable file → Normal file
72
BasiliskII/src/slirp/ip.h
Executable file → Normal file
@ -98,7 +98,7 @@ struct ip {
|
|||||||
} PACKED__;
|
} PACKED__;
|
||||||
|
|
||||||
#ifdef PRAGMA_PACK_SUPPORTED
|
#ifdef PRAGMA_PACK_SUPPORTED
|
||||||
#pragma pack(0)
|
#pragma pack(PACK_RESET)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define IP_MAXPACKET 65535 /* maximum packet size */
|
#define IP_MAXPACKET 65535 /* maximum packet size */
|
||||||
@ -168,7 +168,7 @@ struct ip_timestamp {
|
|||||||
} PACKED__;
|
} PACKED__;
|
||||||
|
|
||||||
#ifdef PRAGMA_PACK_SUPPORTED
|
#ifdef PRAGMA_PACK_SUPPORTED
|
||||||
#pragma pack(0)
|
#pragma pack(PACK_RESET)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* flag bits for ipt_flg */
|
/* flag bits for ipt_flg */
|
||||||
@ -195,19 +195,23 @@ struct ip_timestamp {
|
|||||||
|
|
||||||
#define IP_MSS 576 /* default maximum segment size */
|
#define IP_MSS 576 /* default maximum segment size */
|
||||||
|
|
||||||
#if SIZEOF_CHAR_P == 4
|
#ifdef HAVE_SYS_TYPES32_H /* Overcome some Solaris 2.x junk */
|
||||||
struct mbuf_ptr {
|
#include <sys/types32.h>
|
||||||
struct mbuf *mptr;
|
|
||||||
uint32_t dummy;
|
|
||||||
};
|
|
||||||
#else
|
#else
|
||||||
struct mbuf_ptr {
|
#if SIZEOF_CHAR_P == 4
|
||||||
struct mbuf *mptr;
|
typedef caddr_t caddr32_t;
|
||||||
};
|
#else
|
||||||
|
typedef u_int32_t caddr32_t;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if SIZEOF_CHAR_P == 4
|
||||||
|
typedef struct ipq *ipqp_32;
|
||||||
|
typedef struct ipasfrag *ipasfragp_32;
|
||||||
|
#else
|
||||||
|
typedef caddr32_t ipqp_32;
|
||||||
|
typedef caddr32_t ipasfragp_32;
|
||||||
#endif
|
#endif
|
||||||
struct qlink {
|
|
||||||
void *next, *prev;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Overlay for ip header used by other protocols (tcp, udp).
|
* Overlay for ip header used by other protocols (tcp, udp).
|
||||||
@ -217,16 +221,16 @@ struct qlink {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct ipovly {
|
struct ipovly {
|
||||||
struct mbuf_ptr ih_mbuf; /* backpointer to mbuf */
|
caddr32_t ih_next, ih_prev; /* for protocol sequence q's */
|
||||||
u_int8_t ih_x1; /* (unused) */
|
u_int8_t ih_x1; /* (unused) */
|
||||||
u_int8_t ih_pr; /* protocol */
|
u_int8_t ih_pr; /* protocol */
|
||||||
u_int16_t ih_len; /* protocol length */
|
u_int16_t ih_len; /* protocol length */
|
||||||
struct in_addr ih_src; /* source internet address */
|
struct in_addr ih_src; /* source internet address */
|
||||||
struct in_addr ih_dst; /* destination internet address */
|
struct in_addr ih_dst; /* destination internet address */
|
||||||
} __attribute__((packed));
|
} PACKED__;
|
||||||
|
|
||||||
#ifdef PRAGMA_PACK_SUPPORTED
|
#ifdef PRAGMA_PACK_SUPPORTED
|
||||||
#pragma pack(0)
|
#pragma pack(PACK_RESET)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -237,13 +241,12 @@ struct ipovly {
|
|||||||
* size 28 bytes
|
* size 28 bytes
|
||||||
*/
|
*/
|
||||||
struct ipq {
|
struct ipq {
|
||||||
struct qlink frag_link; /* to ip headers of fragments */
|
ipqp_32 next,prev; /* to other reass headers */
|
||||||
struct qlink ip_link; /* to other reass headers */
|
|
||||||
|
|
||||||
u_int8_t ipq_ttl; /* time for reass q to live */
|
u_int8_t ipq_ttl; /* time for reass q to live */
|
||||||
u_int8_t ipq_p; /* protocol of this fragment */
|
u_int8_t ipq_p; /* protocol of this fragment */
|
||||||
u_int16_t ipq_id; /* sequence id for reassembly */
|
u_int16_t ipq_id; /* sequence id for reassembly */
|
||||||
|
ipasfragp_32 ipq_next,ipq_prev;
|
||||||
|
/* to ip headers of fragments */
|
||||||
struct in_addr ipq_src,ipq_dst;
|
struct in_addr ipq_src,ipq_dst;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -253,16 +256,29 @@ struct ipq {
|
|||||||
* Note: ipf_next must be at same offset as ipq_next above
|
* Note: ipf_next must be at same offset as ipq_next above
|
||||||
*/
|
*/
|
||||||
struct ipasfrag {
|
struct ipasfrag {
|
||||||
struct qlink ipf_link;
|
#ifdef WORDS_BIGENDIAN
|
||||||
struct ip ipf_ip;
|
u_char ip_v:4,
|
||||||
|
ip_hl:4;
|
||||||
|
#else
|
||||||
|
u_char ip_hl:4,
|
||||||
|
ip_v:4;
|
||||||
|
#endif
|
||||||
|
/* BUG : u_int changed to u_int8_t.
|
||||||
|
* sizeof(u_int)==4 on linux 2.0
|
||||||
|
*/
|
||||||
|
u_int8_t ipf_mff; /* XXX overlays ip_tos: use low bit
|
||||||
|
* to avoid destroying tos (PPPDTRuu);
|
||||||
|
* copied from (ip_off&IP_MF) */
|
||||||
|
u_int16_t ip_len;
|
||||||
|
u_int16_t ip_id;
|
||||||
|
u_int16_t ip_off;
|
||||||
|
u_int8_t ip_ttl;
|
||||||
|
u_int8_t ip_p;
|
||||||
|
u_int16_t ip_sum;
|
||||||
|
ipasfragp_32 ipf_next; /* next fragment */
|
||||||
|
ipasfragp_32 ipf_prev; /* previous fragment */
|
||||||
};
|
};
|
||||||
|
|
||||||
#define ipf_off ipf_ip.ip_off
|
|
||||||
#define ipf_tos ipf_ip.ip_tos
|
|
||||||
#define ipf_len ipf_ip.ip_len
|
|
||||||
#define ipf_next ipf_link.next
|
|
||||||
#define ipf_prev ipf_link.prev
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Structure stored in mbuf in inpcb.ip_options
|
* Structure stored in mbuf in inpcb.ip_options
|
||||||
* and passed to ip_output when ip options are in use.
|
* and passed to ip_output when ip options are in use.
|
||||||
|
26
BasiliskII/src/slirp/ip_icmp.c
Executable file → Normal file
26
BasiliskII/src/slirp/ip_icmp.c
Executable file → Normal file
@ -77,7 +77,7 @@ icmp_input(m, hlen)
|
|||||||
|
|
||||||
DEBUG_CALL("icmp_input");
|
DEBUG_CALL("icmp_input");
|
||||||
DEBUG_ARG("m = %lx", (long )m);
|
DEBUG_ARG("m = %lx", (long )m);
|
||||||
DEBUG_ARG("m_len = %d", m->m_len);
|
DEBUG_ARG("m_len = %zu", m->m_len);
|
||||||
|
|
||||||
icmpstat.icps_received++;
|
icmpstat.icps_received++;
|
||||||
|
|
||||||
@ -201,12 +201,12 @@ end_error:
|
|||||||
|
|
||||||
#define ICMP_MAXDATALEN (IP_MSS-28)
|
#define ICMP_MAXDATALEN (IP_MSS-28)
|
||||||
void
|
void
|
||||||
icmp_error(msrc, type, code, minsize, message)
|
icmp_error(
|
||||||
struct mbuf *msrc;
|
struct mbuf *msrc,
|
||||||
u_char type;
|
u_char type,
|
||||||
u_char code;
|
u_char code,
|
||||||
int minsize;
|
int minsize,
|
||||||
char *message;
|
char *message)
|
||||||
{
|
{
|
||||||
unsigned hlen, shlen, s_ip_len;
|
unsigned hlen, shlen, s_ip_len;
|
||||||
register struct ip *ip;
|
register struct ip *ip;
|
||||||
@ -215,7 +215,7 @@ icmp_error(msrc, type, code, minsize, message)
|
|||||||
|
|
||||||
DEBUG_CALL("icmp_error");
|
DEBUG_CALL("icmp_error");
|
||||||
DEBUG_ARG("msrc = %lx", (long )msrc);
|
DEBUG_ARG("msrc = %lx", (long )msrc);
|
||||||
DEBUG_ARG("msrc_len = %d", msrc->m_len);
|
DEBUG_ARG("msrc_len = %zu", msrc->m_len);
|
||||||
|
|
||||||
if(type!=ICMP_UNREACH && type!=ICMP_TIMXCEED) goto end_error;
|
if(type!=ICMP_UNREACH && type!=ICMP_TIMXCEED) goto end_error;
|
||||||
|
|
||||||
@ -223,9 +223,9 @@ icmp_error(msrc, type, code, minsize, message)
|
|||||||
if(!msrc) goto end_error;
|
if(!msrc) goto end_error;
|
||||||
ip = mtod(msrc, struct ip *);
|
ip = mtod(msrc, struct ip *);
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
{ char bufa[20], bufb[20];
|
{ char bufa[INET_ADDRSTRLEN], bufb[INET_ADDRSTRLEN];
|
||||||
strcpy(bufa, inet_ntoa(ip->ip_src));
|
inet_ntop(AF_INET, &ip->ip_src, bufa, sizeof(bufa));
|
||||||
strcpy(bufb, inet_ntoa(ip->ip_dst));
|
inet_ntop(AF_INET, &ip->ip_dst, bufb, sizeof(bufb));
|
||||||
DEBUG_MISC((dfd, " %.16s to %.16s\n", bufa, bufb));
|
DEBUG_MISC((dfd, " %.16s to %.16s\n", bufa, bufb));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -244,7 +244,7 @@ icmp_error(msrc, type, code, minsize, message)
|
|||||||
|
|
||||||
/* make a copy */
|
/* make a copy */
|
||||||
if(!(m=m_get())) goto end_error; /* get mbuf */
|
if(!(m=m_get())) goto end_error; /* get mbuf */
|
||||||
{ int new_m_size;
|
{ u_int new_m_size;
|
||||||
new_m_size=sizeof(struct ip )+ICMP_MINLEN+msrc->m_len+ICMP_MAXDATALEN;
|
new_m_size=sizeof(struct ip )+ICMP_MINLEN+msrc->m_len+ICMP_MAXDATALEN;
|
||||||
if(new_m_size>m->m_size) m_inc(m, new_m_size);
|
if(new_m_size>m->m_size) m_inc(m, new_m_size);
|
||||||
}
|
}
|
||||||
@ -299,7 +299,7 @@ icmp_error(msrc, type, code, minsize, message)
|
|||||||
|
|
||||||
/* fill in ip */
|
/* fill in ip */
|
||||||
ip->ip_hl = hlen >> 2;
|
ip->ip_hl = hlen >> 2;
|
||||||
ip->ip_len = m->m_len;
|
ip->ip_len = (u_int16_t)m->m_len;
|
||||||
|
|
||||||
ip->ip_tos=((ip->ip_tos & 0x1E) | 0xC0); /* high priority for errors */
|
ip->ip_tos=((ip->ip_tos & 0x1E) | 0xC0); /* high priority for errors */
|
||||||
|
|
||||||
|
8
BasiliskII/src/slirp/ip_icmp.h
Executable file → Normal file
8
BasiliskII/src/slirp/ip_icmp.h
Executable file → Normal file
@ -95,7 +95,7 @@ struct icmp {
|
|||||||
} PACKED__;
|
} PACKED__;
|
||||||
|
|
||||||
#ifdef PRAGMA_PACK_SUPPORTED
|
#ifdef PRAGMA_PACK_SUPPORTED
|
||||||
#pragma pack(0)
|
#pragma pack(PACK_RESET)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -161,8 +161,8 @@ struct icmp {
|
|||||||
(type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
|
(type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
|
||||||
(type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
|
(type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
|
||||||
|
|
||||||
void icmp_input _P((struct mbuf *, int));
|
void icmp_input(struct mbuf *, int);
|
||||||
void icmp_error _P((struct mbuf *, u_char, u_char, int, char *));
|
void icmp_error(struct mbuf *, u_char, u_char, int, char *);
|
||||||
void icmp_reflect _P((struct mbuf *));
|
void icmp_reflect(struct mbuf *);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
154
BasiliskII/src/slirp/ip_input.c
Executable file → Normal file
154
BasiliskII/src/slirp/ip_input.c
Executable file → Normal file
@ -38,16 +38,6 @@
|
|||||||
* terms and conditions of the copyright.
|
* terms and conditions of the copyright.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#define container_of(ptr, type, member) ({ \
|
|
||||||
const typeof(((type *) 0)->member) *__mptr = (ptr); \
|
|
||||||
(type *) ((char *) __mptr - offsetof(type, member));})
|
|
||||||
|
|
||||||
|
|
||||||
#include <slirp.h>
|
#include <slirp.h>
|
||||||
#include "ip_icmp.h"
|
#include "ip_icmp.h"
|
||||||
|
|
||||||
@ -62,7 +52,7 @@ struct ipq ipq;
|
|||||||
void
|
void
|
||||||
ip_init()
|
ip_init()
|
||||||
{
|
{
|
||||||
ipq.ip_link.next = ipq.ip_link.prev = &ipq.ip_link;
|
ipq.next = ipq.prev = (ipqp_32)&ipq;
|
||||||
ip_id = tt.tv_sec & 0xffff;
|
ip_id = tt.tv_sec & 0xffff;
|
||||||
udp_init();
|
udp_init();
|
||||||
tcp_init();
|
tcp_init();
|
||||||
@ -78,11 +68,11 @@ ip_input(m)
|
|||||||
struct mbuf *m;
|
struct mbuf *m;
|
||||||
{
|
{
|
||||||
register struct ip *ip;
|
register struct ip *ip;
|
||||||
int hlen;
|
u_int hlen;
|
||||||
|
|
||||||
DEBUG_CALL("ip_input");
|
DEBUG_CALL("ip_input");
|
||||||
DEBUG_ARG("m = %lx", (long)m);
|
DEBUG_ARG("m = %lx", (long)m);
|
||||||
DEBUG_ARG("m_len = %d", m->m_len);
|
DEBUG_ARG("m_len = %zu", m->m_len);
|
||||||
|
|
||||||
ipstat.ips_total++;
|
ipstat.ips_total++;
|
||||||
|
|
||||||
@ -165,20 +155,18 @@ ip_input(m)
|
|||||||
*/
|
*/
|
||||||
if (ip->ip_off &~ IP_DF) {
|
if (ip->ip_off &~ IP_DF) {
|
||||||
register struct ipq *fp;
|
register struct ipq *fp;
|
||||||
struct qlink *l;
|
|
||||||
/*
|
/*
|
||||||
* Look for queue of fragments
|
* Look for queue of fragments
|
||||||
* of this datagram.
|
* of this datagram.
|
||||||
*/
|
*/
|
||||||
for (l = ipq.ip_link.next; l != &ipq.ip_link; l = l->next) {
|
for (fp = (struct ipq *) ipq.next; fp != &ipq;
|
||||||
fp = container_of(l, struct ipq, ip_link);
|
fp = (struct ipq *) fp->next)
|
||||||
if (ip->ip_id == fp->ipq_id &&
|
if (ip->ip_id == fp->ipq_id &&
|
||||||
ip->ip_src.s_addr == fp->ipq_src.s_addr &&
|
ip->ip_src.s_addr == fp->ipq_src.s_addr &&
|
||||||
ip->ip_dst.s_addr == fp->ipq_dst.s_addr &&
|
ip->ip_dst.s_addr == fp->ipq_dst.s_addr &&
|
||||||
ip->ip_p == fp->ipq_p)
|
ip->ip_p == fp->ipq_p)
|
||||||
goto found;
|
goto found;
|
||||||
}
|
fp = 0;
|
||||||
fp = NULL;
|
|
||||||
found:
|
found:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -188,9 +176,9 @@ ip_input(m)
|
|||||||
*/
|
*/
|
||||||
ip->ip_len -= hlen;
|
ip->ip_len -= hlen;
|
||||||
if (ip->ip_off & IP_MF)
|
if (ip->ip_off & IP_MF)
|
||||||
ip->ip_tos |= 1;
|
((struct ipasfrag *)ip)->ipf_mff |= 1;
|
||||||
else
|
else
|
||||||
ip->ip_tos &= ~1;
|
((struct ipasfrag *)ip)->ipf_mff &= ~1;
|
||||||
|
|
||||||
ip->ip_off <<= 3;
|
ip->ip_off <<= 3;
|
||||||
|
|
||||||
@ -199,9 +187,9 @@ ip_input(m)
|
|||||||
* or if this is not the first fragment,
|
* or if this is not the first fragment,
|
||||||
* attempt reassembly; if it succeeds, proceed.
|
* attempt reassembly; if it succeeds, proceed.
|
||||||
*/
|
*/
|
||||||
if (ip->ip_tos & 1 || ip->ip_off) {
|
if (((struct ipasfrag *)ip)->ipf_mff & 1 || ip->ip_off) {
|
||||||
ipstat.ips_fragments++;
|
ipstat.ips_fragments++;
|
||||||
ip = ip_reass(ip, fp);
|
ip = ip_reass((struct ipasfrag *)ip, fp);
|
||||||
if (ip == 0)
|
if (ip == 0)
|
||||||
return;
|
return;
|
||||||
ipstat.ips_reassembled++;
|
ipstat.ips_reassembled++;
|
||||||
@ -237,21 +225,21 @@ bad:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define iptofrag(P) ((struct ipasfrag *)(((char*)(P)) - sizeof(struct qlink)))
|
|
||||||
#define fragtoip(P) ((struct ip*)(((char*)(P)) + sizeof(struct qlink)))
|
|
||||||
/*
|
/*
|
||||||
* Take incoming datagram fragment and try to
|
* Take incoming datagram fragment and try to
|
||||||
* reassemble it into whole datagram. If a chain for
|
* reassemble it into whole datagram. If a chain for
|
||||||
* reassembly of this datagram already exists, then it
|
* reassembly of this datagram already exists, then it
|
||||||
* is given as fp; otherwise have to make a chain.
|
* is given as fp; otherwise have to make a chain.
|
||||||
*/
|
*/
|
||||||
static struct ip *
|
struct ip *
|
||||||
ip_reass(register struct ip *ip, register struct ipq *fp)
|
ip_reass(ip, fp)
|
||||||
|
register struct ipasfrag *ip;
|
||||||
|
register struct ipq *fp;
|
||||||
{
|
{
|
||||||
register struct mbuf *m = dtom(ip);
|
register struct mbuf *m = dtom(ip);
|
||||||
register struct ipasfrag *q;
|
register struct ipasfrag *q;
|
||||||
int hlen = ip->ip_hl << 2;
|
int hlen = ip->ip_hl << 2;
|
||||||
u_int16_t i, next;
|
int i, next;
|
||||||
|
|
||||||
DEBUG_CALL("ip_reass");
|
DEBUG_CALL("ip_reass");
|
||||||
DEBUG_ARG("ip = %lx", (long)ip);
|
DEBUG_ARG("ip = %lx", (long)ip);
|
||||||
@ -273,13 +261,13 @@ ip_reass(register struct ip *ip, register struct ipq *fp)
|
|||||||
struct mbuf *t;
|
struct mbuf *t;
|
||||||
if ((t = m_get()) == NULL) goto dropfrag;
|
if ((t = m_get()) == NULL) goto dropfrag;
|
||||||
fp = mtod(t, struct ipq *);
|
fp = mtod(t, struct ipq *);
|
||||||
insque(&fp->ip_link, &ipq.ip_link);
|
insque_32(fp, &ipq);
|
||||||
fp->ipq_ttl = IPFRAGTTL;
|
fp->ipq_ttl = IPFRAGTTL;
|
||||||
fp->ipq_p = ip->ip_p;
|
fp->ipq_p = ip->ip_p;
|
||||||
fp->ipq_id = ip->ip_id;
|
fp->ipq_id = ip->ip_id;
|
||||||
fp->frag_link.next = fp->frag_link.prev = &fp->frag_link;
|
fp->ipq_next = fp->ipq_prev = (ipasfragp_32)fp;
|
||||||
fp->ipq_src = ip->ip_src;
|
fp->ipq_src = ((struct ip *)ip)->ip_src;
|
||||||
fp->ipq_dst = ip->ip_dst;
|
fp->ipq_dst = ((struct ip *)ip)->ip_dst;
|
||||||
q = (struct ipasfrag *)fp;
|
q = (struct ipasfrag *)fp;
|
||||||
goto insert;
|
goto insert;
|
||||||
}
|
}
|
||||||
@ -287,9 +275,9 @@ ip_reass(register struct ip *ip, register struct ipq *fp)
|
|||||||
/*
|
/*
|
||||||
* Find a segment which begins after this one does.
|
* Find a segment which begins after this one does.
|
||||||
*/
|
*/
|
||||||
for (q = fp->frag_link.next; q != (struct ipasfrag *)&fp->frag_link;
|
for (q = (struct ipasfrag *)fp->ipq_next; q != (struct ipasfrag *)fp;
|
||||||
q = q->ipf_next)
|
q = (struct ipasfrag *)q->ipf_next)
|
||||||
if (q->ipf_off > ip->ip_off)
|
if (q->ip_off > ip->ip_off)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -297,9 +285,9 @@ ip_reass(register struct ip *ip, register struct ipq *fp)
|
|||||||
* our data already. If so, drop the data from the incoming
|
* our data already. If so, drop the data from the incoming
|
||||||
* segment. If it provides all of our data, drop us.
|
* segment. If it provides all of our data, drop us.
|
||||||
*/
|
*/
|
||||||
if (q->ipf_prev != &fp->frag_link) {
|
if (q->ipf_prev != (ipasfragp_32)fp) {
|
||||||
struct ipasfrag *pq = q->ipf_prev;
|
i = ((struct ipasfrag *)(q->ipf_prev))->ip_off +
|
||||||
i = pq->ipf_off + pq->ipf_len - ip->ip_off;
|
((struct ipasfrag *)(q->ipf_prev))->ip_len - ip->ip_off;
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
if (i >= ip->ip_len)
|
if (i >= ip->ip_len)
|
||||||
goto dropfrag;
|
goto dropfrag;
|
||||||
@ -313,18 +301,17 @@ ip_reass(register struct ip *ip, register struct ipq *fp)
|
|||||||
* While we overlap succeeding segments trim them or,
|
* While we overlap succeeding segments trim them or,
|
||||||
* if they are completely covered, dequeue them.
|
* if they are completely covered, dequeue them.
|
||||||
*/
|
*/
|
||||||
while (q != (struct ipasfrag*)&fp->frag_link &&
|
while (q != (struct ipasfrag *)fp && ip->ip_off + ip->ip_len > q->ip_off) {
|
||||||
ip->ip_off + ip->ip_len > q->ipf_off) {
|
i = (ip->ip_off + ip->ip_len) - q->ip_off;
|
||||||
i = (ip->ip_off + ip->ip_len) - q->ipf_off;
|
if (i < q->ip_len) {
|
||||||
if (i < q->ipf_len) {
|
q->ip_len -= i;
|
||||||
q->ipf_len -= i;
|
q->ip_off += i;
|
||||||
q->ipf_off += i;
|
|
||||||
m_adj(dtom(q), i);
|
m_adj(dtom(q), i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
q = q->ipf_next;
|
q = (struct ipasfrag *) q->ipf_next;
|
||||||
m_freem(dtom(q->ipf_prev));
|
m_freem(dtom((struct ipasfrag *) q->ipf_prev));
|
||||||
ip_deq(q->ipf_prev);
|
ip_deq((struct ipasfrag *) q->ipf_prev);
|
||||||
}
|
}
|
||||||
|
|
||||||
insert:
|
insert:
|
||||||
@ -332,26 +319,27 @@ insert:
|
|||||||
* Stick new segment in its place;
|
* Stick new segment in its place;
|
||||||
* check for complete reassembly.
|
* check for complete reassembly.
|
||||||
*/
|
*/
|
||||||
ip_enq(iptofrag(ip), q->ipf_prev);
|
ip_enq(ip, (struct ipasfrag *) q->ipf_prev);
|
||||||
next = 0;
|
next = 0;
|
||||||
for (q = fp->frag_link.next; q != (struct ipasfrag*)&fp->frag_link;
|
for (q = (struct ipasfrag *) fp->ipq_next; q != (struct ipasfrag *)fp;
|
||||||
q = q->ipf_next) {
|
q = (struct ipasfrag *) q->ipf_next) {
|
||||||
if (q->ipf_off != next)
|
if (q->ip_off != next)
|
||||||
return (0);
|
return (0);
|
||||||
next += q->ipf_len;
|
next += q->ip_len;
|
||||||
}
|
}
|
||||||
if (((struct ipasfrag *)(q->ipf_prev))->ipf_tos & 1)
|
if (((struct ipasfrag *)(q->ipf_prev))->ipf_mff & 1)
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reassembly is complete; concatenate fragments.
|
* Reassembly is complete; concatenate fragments.
|
||||||
*/
|
*/
|
||||||
q = fp->frag_link.next;
|
q = (struct ipasfrag *) fp->ipq_next;
|
||||||
m = dtom(q);
|
m = dtom(q);
|
||||||
|
|
||||||
q = (struct ipasfrag *) q->ipf_next;
|
q = (struct ipasfrag *) q->ipf_next;
|
||||||
while (q != (struct ipasfrag*)&fp->frag_link) {
|
while (q != (struct ipasfrag *)fp) {
|
||||||
struct mbuf *t = dtom(q);
|
struct mbuf *t;
|
||||||
|
t = dtom(q);
|
||||||
q = (struct ipasfrag *) q->ipf_next;
|
q = (struct ipasfrag *) q->ipf_next;
|
||||||
m_cat(m, t);
|
m_cat(m, t);
|
||||||
}
|
}
|
||||||
@ -362,7 +350,7 @@ insert:
|
|||||||
* dequeue and discard fragment reassembly header.
|
* dequeue and discard fragment reassembly header.
|
||||||
* Make header visible.
|
* Make header visible.
|
||||||
*/
|
*/
|
||||||
q = fp->frag_link.next;
|
ip = (struct ipasfrag *) fp->ipq_next;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the fragments concatenated to an mbuf that's
|
* If the fragments concatenated to an mbuf that's
|
||||||
@ -373,24 +361,24 @@ insert:
|
|||||||
*/
|
*/
|
||||||
if (m->m_flags & M_EXT) {
|
if (m->m_flags & M_EXT) {
|
||||||
int delta;
|
int delta;
|
||||||
delta = (char *)q - m->m_dat;
|
delta = (char *)ip - m->m_dat;
|
||||||
q = (struct ipasfrag *)(m->m_ext + delta);
|
ip = (struct ipasfrag *)(m->m_ext + delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* DEBUG_ARG("ip = %lx", (long)ip);
|
/* DEBUG_ARG("ip = %lx", (long)ip);
|
||||||
* ip=(struct ipasfrag *)m->m_data; */
|
* ip=(struct ipasfrag *)m->m_data; */
|
||||||
|
|
||||||
ip = fragtoip(q);
|
|
||||||
ip->ip_len = next;
|
ip->ip_len = next;
|
||||||
ip->ip_tos &= ~1;
|
ip->ipf_mff &= ~1;
|
||||||
ip->ip_src = fp->ipq_src;
|
((struct ip *)ip)->ip_src = fp->ipq_src;
|
||||||
ip->ip_dst = fp->ipq_dst;
|
((struct ip *)ip)->ip_dst = fp->ipq_dst;
|
||||||
remque(&fp->ip_link);
|
remque_32(fp);
|
||||||
(void) m_free(dtom(fp));
|
(void) m_free(dtom(fp));
|
||||||
|
m = dtom(ip);
|
||||||
m->m_len += (ip->ip_hl << 2);
|
m->m_len += (ip->ip_hl << 2);
|
||||||
m->m_data -= (ip->ip_hl << 2);
|
m->m_data -= (ip->ip_hl << 2);
|
||||||
|
|
||||||
return ip;
|
return ((struct ip *)ip);
|
||||||
|
|
||||||
dropfrag:
|
dropfrag:
|
||||||
ipstat.ips_fragdropped++;
|
ipstat.ips_fragdropped++;
|
||||||
@ -408,12 +396,13 @@ ip_freef(fp)
|
|||||||
{
|
{
|
||||||
register struct ipasfrag *q, *p;
|
register struct ipasfrag *q, *p;
|
||||||
|
|
||||||
for (q = fp->frag_link.next; q != (struct ipasfrag*)&fp->frag_link; q = p) {
|
for (q = (struct ipasfrag *) fp->ipq_next; q != (struct ipasfrag *)fp;
|
||||||
p = q->ipf_next;
|
q = p) {
|
||||||
|
p = (struct ipasfrag *) q->ipf_next;
|
||||||
ip_deq(q);
|
ip_deq(q);
|
||||||
m_freem(dtom(q));
|
m_freem(dtom(q));
|
||||||
}
|
}
|
||||||
remque(&fp->ip_link);
|
remque_32(fp);
|
||||||
(void) m_free(dtom(fp));
|
(void) m_free(dtom(fp));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -427,10 +416,10 @@ ip_enq(p, prev)
|
|||||||
{
|
{
|
||||||
DEBUG_CALL("ip_enq");
|
DEBUG_CALL("ip_enq");
|
||||||
DEBUG_ARG("prev = %lx", (long)prev);
|
DEBUG_ARG("prev = %lx", (long)prev);
|
||||||
p->ipf_prev = prev;
|
p->ipf_prev = (ipasfragp_32) prev;
|
||||||
p->ipf_next = prev->ipf_next;
|
p->ipf_next = prev->ipf_next;
|
||||||
((struct ipasfrag *)(prev->ipf_next))->ipf_prev = p;
|
((struct ipasfrag *)(prev->ipf_next))->ipf_prev = (ipasfragp_32) p;
|
||||||
prev->ipf_next = p;
|
prev->ipf_next = (ipasfragp_32) p;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -452,21 +441,20 @@ ip_deq(p)
|
|||||||
void
|
void
|
||||||
ip_slowtimo()
|
ip_slowtimo()
|
||||||
{
|
{
|
||||||
struct qlink *l;
|
register struct ipq *fp;
|
||||||
|
|
||||||
DEBUG_CALL("ip_slowtimo");
|
DEBUG_CALL("ip_slowtimo");
|
||||||
|
|
||||||
l = ipq.ip_link.next;
|
fp = (struct ipq *) ipq.next;
|
||||||
|
if (fp == 0)
|
||||||
if (l == 0)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
while (l != &ipq.ip_link) {
|
while (fp != &ipq) {
|
||||||
struct ipq *fp = container_of(l, struct ipq, ip_link);
|
--fp->ipq_ttl;
|
||||||
l = l->next;
|
fp = (struct ipq *) fp->next;
|
||||||
if (--fp->ipq_ttl == 0) {
|
if (((struct ipq *)(fp->prev))->ipq_ttl == 0) {
|
||||||
ipstat.ips_fragtimeout++;
|
ipstat.ips_fragtimeout++;
|
||||||
ip_freef(fp);
|
ip_freef((struct ipq *) fp->prev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
9
BasiliskII/src/slirp/ip_output.c
Executable file → Normal file
9
BasiliskII/src/slirp/ip_output.c
Executable file → Normal file
@ -55,8 +55,9 @@ ip_output(so, m0)
|
|||||||
{
|
{
|
||||||
register struct ip *ip;
|
register struct ip *ip;
|
||||||
register struct mbuf *m = m0;
|
register struct mbuf *m = m0;
|
||||||
register int hlen = sizeof(struct ip );
|
register u_int hlen = sizeof(struct ip);
|
||||||
int len, off, error = 0;
|
u_int len, off;
|
||||||
|
int error = 0;
|
||||||
|
|
||||||
DEBUG_CALL("ip_output");
|
DEBUG_CALL("ip_output");
|
||||||
DEBUG_ARG("so = %lx", (long)so);
|
DEBUG_ARG("so = %lx", (long)so);
|
||||||
@ -128,7 +129,7 @@ ip_output(so, m0)
|
|||||||
*/
|
*/
|
||||||
m0 = m;
|
m0 = m;
|
||||||
mhlen = sizeof (struct ip);
|
mhlen = sizeof (struct ip);
|
||||||
for (off = hlen + len; off < (u_int16_t)ip->ip_len; off += len) {
|
for (off = hlen + len; off < ip->ip_len; off += len) {
|
||||||
register struct ip *mhip;
|
register struct ip *mhip;
|
||||||
m = m_get();
|
m = m_get();
|
||||||
if (m == 0) {
|
if (m == 0) {
|
||||||
@ -173,7 +174,7 @@ ip_output(so, m0)
|
|||||||
* and updating header, then send each fragment (in order).
|
* and updating header, then send each fragment (in order).
|
||||||
*/
|
*/
|
||||||
m = m0;
|
m = m0;
|
||||||
m_adj(m, hlen + firstlen - (u_int16_t)ip->ip_len);
|
m_adj(m, hlen + firstlen - ip->ip_len);
|
||||||
ip->ip_len = htons((u_int16_t)m->m_len);
|
ip->ip_len = htons((u_int16_t)m->m_len);
|
||||||
ip->ip_off = htons((u_int16_t)(ip->ip_off | IP_MF));
|
ip->ip_off = htons((u_int16_t)(ip->ip_off | IP_MF));
|
||||||
ip->ip_sum = 0;
|
ip->ip_sum = 0;
|
||||||
|
0
BasiliskII/src/slirp/libslirp.h
Executable file → Normal file
0
BasiliskII/src/slirp/libslirp.h
Executable file → Normal file
0
BasiliskII/src/slirp/main.h
Executable file → Normal file
0
BasiliskII/src/slirp/main.h
Executable file → Normal file
37
BasiliskII/src/slirp/mbuf.c
Executable file → Normal file
37
BasiliskII/src/slirp/mbuf.c
Executable file → Normal file
@ -24,18 +24,16 @@ int mbuf_alloced = 0;
|
|||||||
struct mbuf m_freelist, m_usedlist;
|
struct mbuf m_freelist, m_usedlist;
|
||||||
int mbuf_thresh = 30;
|
int mbuf_thresh = 30;
|
||||||
int mbuf_max = 0;
|
int mbuf_max = 0;
|
||||||
int msize;
|
size_t msize;
|
||||||
|
|
||||||
void
|
void m_init()
|
||||||
m_init()
|
|
||||||
{
|
{
|
||||||
m_freelist.m_next = m_freelist.m_prev = &m_freelist;
|
m_freelist.m_next = m_freelist.m_prev = &m_freelist;
|
||||||
m_usedlist.m_next = m_usedlist.m_prev = &m_usedlist;
|
m_usedlist.m_next = m_usedlist.m_prev = &m_usedlist;
|
||||||
msize_init();
|
msize_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void msize_init()
|
||||||
msize_init()
|
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Find a nice value for msize
|
* Find a nice value for msize
|
||||||
@ -53,8 +51,7 @@ msize_init()
|
|||||||
* free old mbufs, we mark all mbufs above mbuf_thresh as M_DOFREE,
|
* free old mbufs, we mark all mbufs above mbuf_thresh as M_DOFREE,
|
||||||
* which tells m_free to actually free() it
|
* which tells m_free to actually free() it
|
||||||
*/
|
*/
|
||||||
struct mbuf *
|
struct mbuf *m_get()
|
||||||
m_get()
|
|
||||||
{
|
{
|
||||||
register struct mbuf *m;
|
register struct mbuf *m;
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
@ -89,9 +86,7 @@ end_error:
|
|||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void m_free(struct mbuf *m)
|
||||||
m_free(m)
|
|
||||||
struct mbuf *m;
|
|
||||||
{
|
{
|
||||||
|
|
||||||
DEBUG_CALL("m_free");
|
DEBUG_CALL("m_free");
|
||||||
@ -124,9 +119,7 @@ m_free(m)
|
|||||||
* the other.. if result is too big for one mbuf, malloc()
|
* the other.. if result is too big for one mbuf, malloc()
|
||||||
* an M_EXT data segment
|
* an M_EXT data segment
|
||||||
*/
|
*/
|
||||||
void
|
void m_cat(register struct mbuf *m, register struct mbuf *n)
|
||||||
m_cat(m, n)
|
|
||||||
register struct mbuf *m, *n;
|
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* If there's no room, realloc
|
* If there's no room, realloc
|
||||||
@ -142,10 +135,7 @@ m_cat(m, n)
|
|||||||
|
|
||||||
|
|
||||||
/* make m size bytes large */
|
/* make m size bytes large */
|
||||||
void
|
void m_inc(struct mbuf *m, u_int size)
|
||||||
m_inc(m, size)
|
|
||||||
struct mbuf *m;
|
|
||||||
int size;
|
|
||||||
{
|
{
|
||||||
int datasize;
|
int datasize;
|
||||||
|
|
||||||
@ -179,10 +169,7 @@ m_inc(m, size)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void m_adj(struct mbuf *m, int len)
|
||||||
m_adj(m, len)
|
|
||||||
struct mbuf *m;
|
|
||||||
int len;
|
|
||||||
{
|
{
|
||||||
if (m == NULL)
|
if (m == NULL)
|
||||||
return;
|
return;
|
||||||
@ -202,9 +189,7 @@ m_adj(m, len)
|
|||||||
* Copy len bytes from m, starting off bytes into n
|
* Copy len bytes from m, starting off bytes into n
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
m_copy(n, m, off, len)
|
m_copy(struct mbuf *n, struct mbuf *m, u_int off, u_int len)
|
||||||
struct mbuf *n, *m;
|
|
||||||
int off, len;
|
|
||||||
{
|
{
|
||||||
if (len > M_FREEROOM(n))
|
if (len > M_FREEROOM(n))
|
||||||
return -1;
|
return -1;
|
||||||
@ -220,9 +205,7 @@ m_copy(n, m, off, len)
|
|||||||
* XXX This is a kludge, I should eliminate the need for it
|
* XXX This is a kludge, I should eliminate the need for it
|
||||||
* Fortunately, it's not used often
|
* Fortunately, it's not used often
|
||||||
*/
|
*/
|
||||||
struct mbuf *
|
struct mbuf *dtom(void *dat)
|
||||||
dtom(dat)
|
|
||||||
void *dat;
|
|
||||||
{
|
{
|
||||||
struct mbuf *m;
|
struct mbuf *m;
|
||||||
|
|
||||||
|
22
BasiliskII/src/slirp/mbuf.h
Executable file → Normal file
22
BasiliskII/src/slirp/mbuf.h
Executable file → Normal file
@ -63,11 +63,11 @@ struct m_hdr {
|
|||||||
struct mbuf *mh_prevpkt; /* Flags aren't used in the output queue */
|
struct mbuf *mh_prevpkt; /* Flags aren't used in the output queue */
|
||||||
int mh_flags; /* Misc flags */
|
int mh_flags; /* Misc flags */
|
||||||
|
|
||||||
int mh_size; /* Size of data */
|
size_t mh_size; /* Size of data */
|
||||||
struct socket *mh_so;
|
struct socket *mh_so;
|
||||||
|
|
||||||
caddr_t mh_data; /* Location of data */
|
caddr_t mh_data; /* Location of data */
|
||||||
int mh_len; /* Amount of data in this mbuf */
|
size_t mh_len; /* Amount of data in this mbuf */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -130,14 +130,14 @@ extern int mbuf_alloced;
|
|||||||
extern struct mbuf m_freelist, m_usedlist;
|
extern struct mbuf m_freelist, m_usedlist;
|
||||||
extern int mbuf_max;
|
extern int mbuf_max;
|
||||||
|
|
||||||
void m_init _P((void));
|
void m_init(void);
|
||||||
void msize_init _P((void));
|
void msize_init(void);
|
||||||
struct mbuf * m_get _P((void));
|
struct mbuf * m_get(void);
|
||||||
void m_free _P((struct mbuf *));
|
void m_free(struct mbuf *);
|
||||||
void m_cat _P((register struct mbuf *, register struct mbuf *));
|
void m_cat(register struct mbuf *, register struct mbuf *);
|
||||||
void m_inc _P((struct mbuf *, int));
|
void m_inc(struct mbuf *, u_int);
|
||||||
void m_adj _P((struct mbuf *, int));
|
void m_adj(struct mbuf *, int);
|
||||||
int m_copy _P((struct mbuf *, struct mbuf *, int, int));
|
int m_copy(struct mbuf *, struct mbuf *, u_int, u_int);
|
||||||
struct mbuf * dtom _P((void *));
|
struct mbuf * dtom(void *);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
192
BasiliskII/src/slirp/misc.c
Executable file → Normal file
192
BasiliskII/src/slirp/misc.c
Executable file → Normal file
@ -17,10 +17,7 @@ int x_port = -1;
|
|||||||
int x_display = 0;
|
int x_display = 0;
|
||||||
int x_screen = 0;
|
int x_screen = 0;
|
||||||
|
|
||||||
int
|
int show_x(char *buff, struct socket *inso)
|
||||||
show_x(buff, inso)
|
|
||||||
char *buff;
|
|
||||||
struct socket *inso;
|
|
||||||
{
|
{
|
||||||
if (x_port < 0) {
|
if (x_port < 0) {
|
||||||
lprint("X Redir: X not being redirected.\r\n");
|
lprint("X Redir: X not being redirected.\r\n");
|
||||||
@ -40,12 +37,7 @@ show_x(buff, inso)
|
|||||||
/*
|
/*
|
||||||
* XXX Allow more than one X redirection?
|
* XXX Allow more than one X redirection?
|
||||||
*/
|
*/
|
||||||
void
|
void redir_x(u_int32_t inaddr, int start_port, int display, int screen)
|
||||||
redir_x(inaddr, start_port, display, screen)
|
|
||||||
u_int32_t inaddr;
|
|
||||||
int start_port;
|
|
||||||
int display;
|
|
||||||
int screen;
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -69,44 +61,69 @@ redir_x(inaddr, start_port, display, screen)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_INET_ATON
|
#ifndef HAVE_INET_ATON
|
||||||
int
|
int inet_aton(const char *cp, struct in_addr *ia)
|
||||||
inet_aton(cp, ia)
|
|
||||||
const char *cp;
|
|
||||||
struct in_addr *ia;
|
|
||||||
{
|
{
|
||||||
u_int32_t addr = inet_addr(cp);
|
return inet_pton(AF_INET, cp, &ia->s_addr);
|
||||||
if (addr == 0xffffffff)
|
|
||||||
return 0;
|
|
||||||
ia->s_addr = addr;
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get our IP address and put it in our_addr
|
* Get our IP address and put it in our_addr
|
||||||
*/
|
*/
|
||||||
void
|
void getouraddr()
|
||||||
getouraddr()
|
|
||||||
{
|
{
|
||||||
char buff[256];
|
char buff[256];
|
||||||
struct hostent *he = NULL;
|
|
||||||
|
if (gethostname(buff, sizeof(buff)) == 0)
|
||||||
if (gethostname(buff,256) == 0)
|
{
|
||||||
he = gethostbyname(buff);
|
struct addrinfo hints = { 0 };
|
||||||
if (he)
|
hints.ai_flags = AI_NUMERICHOST;
|
||||||
our_addr = *(struct in_addr *)he->h_addr;
|
hints.ai_family = AF_INET;
|
||||||
if (our_addr.s_addr == 0)
|
struct addrinfo* ai;
|
||||||
our_addr.s_addr = loopback_addr.s_addr;
|
if (getaddrinfo(buff, NULL, &hints, &ai) == 0)
|
||||||
|
{
|
||||||
|
our_addr = *(struct in_addr *)ai->ai_addr->sa_data;
|
||||||
|
freeaddrinfo(ai);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (our_addr.s_addr == 0)
|
||||||
|
our_addr.s_addr = loopback_addr.s_addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if SIZEOF_CHAR_P == 8
|
||||||
|
|
||||||
|
struct quehead_32 {
|
||||||
|
u_int32_t qh_link;
|
||||||
|
u_int32_t qh_rlink;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline void insque_32(void *a, void *b)
|
||||||
|
{
|
||||||
|
register struct quehead_32 *element = (struct quehead_32 *) a;
|
||||||
|
register struct quehead_32 *head = (struct quehead_32 *) b;
|
||||||
|
element->qh_link = head->qh_link;
|
||||||
|
head->qh_link = (u_int32_t)element;
|
||||||
|
element->qh_rlink = (u_int32_t)head;
|
||||||
|
((struct quehead_32 *)(element->qh_link))->qh_rlink
|
||||||
|
= (u_int32_t)element;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void remque_32(void *a)
|
||||||
|
{
|
||||||
|
register struct quehead_32 *element = (struct quehead_32 *) a;
|
||||||
|
((struct quehead_32 *)(element->qh_link))->qh_rlink = element->qh_rlink;
|
||||||
|
((struct quehead_32 *)(element->qh_rlink))->qh_link = element->qh_link;
|
||||||
|
element->qh_rlink = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* SIZEOF_CHAR_P == 8 */
|
||||||
|
|
||||||
struct quehead {
|
struct quehead {
|
||||||
struct quehead *qh_link;
|
struct quehead *qh_link;
|
||||||
struct quehead *qh_rlink;
|
struct quehead *qh_rlink;
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void insque(void *a, void *b)
|
||||||
insque(a, b)
|
|
||||||
void *a, *b;
|
|
||||||
{
|
{
|
||||||
register struct quehead *element = (struct quehead *) a;
|
register struct quehead *element = (struct quehead *) a;
|
||||||
register struct quehead *head = (struct quehead *) b;
|
register struct quehead *head = (struct quehead *) b;
|
||||||
@ -117,9 +134,7 @@ insque(a, b)
|
|||||||
= (struct quehead *)element;
|
= (struct quehead *)element;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void remque(void *a)
|
||||||
remque(a)
|
|
||||||
void *a;
|
|
||||||
{
|
{
|
||||||
register struct quehead *element = (struct quehead *) a;
|
register struct quehead *element = (struct quehead *) a;
|
||||||
((struct quehead *)(element->qh_link))->qh_rlink = element->qh_rlink;
|
((struct quehead *)(element->qh_link))->qh_rlink = element->qh_rlink;
|
||||||
@ -131,13 +146,7 @@ remque(a)
|
|||||||
/* #endif */
|
/* #endif */
|
||||||
|
|
||||||
|
|
||||||
int
|
int add_exec(struct ex_list **ex_ptr, int do_pty, char *exec, int addr, int port)
|
||||||
add_exec(ex_ptr, do_pty, exec, addr, port)
|
|
||||||
struct ex_list **ex_ptr;
|
|
||||||
int do_pty;
|
|
||||||
char *exec;
|
|
||||||
int addr;
|
|
||||||
int port;
|
|
||||||
{
|
{
|
||||||
struct ex_list *tmp_ptr;
|
struct ex_list *tmp_ptr;
|
||||||
|
|
||||||
@ -166,9 +175,7 @@ add_exec(ex_ptr, do_pty, exec, addr, port)
|
|||||||
extern int sys_nerr;
|
extern int sys_nerr;
|
||||||
extern char *sys_errlist[];
|
extern char *sys_errlist[];
|
||||||
|
|
||||||
char *
|
char *strerror(int error)
|
||||||
strerror(error)
|
|
||||||
int error;
|
|
||||||
{
|
{
|
||||||
if (error < sys_nerr)
|
if (error < sys_nerr)
|
||||||
return sys_errlist[error];
|
return sys_errlist[error];
|
||||||
@ -181,11 +188,7 @@ strerror(error)
|
|||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
int
|
int fork_exec(struct socket *so, char *ex, int do_pty)
|
||||||
fork_exec(so, ex, do_pty)
|
|
||||||
struct socket *so;
|
|
||||||
char *ex;
|
|
||||||
int do_pty;
|
|
||||||
{
|
{
|
||||||
/* not implemented */
|
/* not implemented */
|
||||||
return 0;
|
return 0;
|
||||||
@ -193,9 +196,7 @@ fork_exec(so, ex, do_pty)
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
int
|
int slirp_openpty(int *amaster, int *aslave)
|
||||||
slirp_openpty(amaster, aslave)
|
|
||||||
int *amaster, *aslave;
|
|
||||||
{
|
{
|
||||||
register int master, slave;
|
register int master, slave;
|
||||||
|
|
||||||
@ -269,11 +270,7 @@ slirp_openpty(amaster, aslave)
|
|||||||
* do_pty = 1 Fork/exec using slirp.telnetd
|
* do_pty = 1 Fork/exec using slirp.telnetd
|
||||||
* do_ptr = 2 Fork/exec using pty
|
* do_ptr = 2 Fork/exec using pty
|
||||||
*/
|
*/
|
||||||
int
|
int fork_exec(struct socket *so, char *ex, int do_pty)
|
||||||
fork_exec(so, ex, do_pty)
|
|
||||||
struct socket *so;
|
|
||||||
char *ex;
|
|
||||||
int do_pty;
|
|
||||||
{
|
{
|
||||||
int s;
|
int s;
|
||||||
struct sockaddr_in addr;
|
struct sockaddr_in addr;
|
||||||
@ -429,9 +426,7 @@ fork_exec(so, ex, do_pty)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_STRDUP
|
#ifndef HAVE_STRDUP
|
||||||
char *
|
char *strdup(const char *str)
|
||||||
strdup(str)
|
|
||||||
const char *str;
|
|
||||||
{
|
{
|
||||||
char *bptr;
|
char *bptr;
|
||||||
|
|
||||||
@ -443,9 +438,7 @@ strdup(str)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
void
|
void snooze_hup(int num)
|
||||||
snooze_hup(num)
|
|
||||||
int num;
|
|
||||||
{
|
{
|
||||||
int s, ret;
|
int s, ret;
|
||||||
#ifndef NO_UNIX_SOCKETS
|
#ifndef NO_UNIX_SOCKETS
|
||||||
@ -485,8 +478,7 @@ snooze_hup(num)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void snooze()
|
||||||
snooze()
|
|
||||||
{
|
{
|
||||||
sigset_t s;
|
sigset_t s;
|
||||||
int i;
|
int i;
|
||||||
@ -510,9 +502,7 @@ snooze()
|
|||||||
exit(255);
|
exit(255);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void relay(int s)
|
||||||
relay(s)
|
|
||||||
int s;
|
|
||||||
{
|
{
|
||||||
char buf[8192];
|
char buf[8192];
|
||||||
int n;
|
int n;
|
||||||
@ -572,25 +562,14 @@ relay(s)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int (*lprint_print) _P((void *, const char *, va_list));
|
int (*lprint_print)(void *, const char *, va_list);
|
||||||
char *lprint_ptr, *lprint_ptr2, **lprint_arg;
|
char *lprint_ptr, *lprint_ptr2, **lprint_arg;
|
||||||
|
|
||||||
void
|
void lprint(const char *format, ...)
|
||||||
#ifdef __STDC__
|
|
||||||
lprint(const char *format, ...)
|
|
||||||
#else
|
|
||||||
lprint(va_alist) va_dcl
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
||||||
#ifdef __STDC__
|
va_start(args, format);
|
||||||
va_start(args, format);
|
|
||||||
#else
|
|
||||||
char *format;
|
|
||||||
va_start(args);
|
|
||||||
format = va_arg(args, char *);
|
|
||||||
#endif
|
|
||||||
#if 0
|
#if 0
|
||||||
/* If we're printing to an sbuf, make sure there's enough room */
|
/* If we're printing to an sbuf, make sure there's enough room */
|
||||||
/* XXX +100? */
|
/* XXX +100? */
|
||||||
@ -639,9 +618,7 @@ lprint(va_alist) va_dcl
|
|||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void add_emu(char *buff)
|
||||||
add_emu(buff)
|
|
||||||
char *buff;
|
|
||||||
{
|
{
|
||||||
u_int lport, fport;
|
u_int lport, fport;
|
||||||
u_int8_t tos = 0, emu = 0;
|
u_int8_t tos = 0, emu = 0;
|
||||||
@ -733,42 +710,24 @@ add_emu(buff)
|
|||||||
* Some BSD-derived systems have a sprintf which returns char *
|
* Some BSD-derived systems have a sprintf which returns char *
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int
|
int vsprintf_len(char *string, const char *format, va_list args)
|
||||||
vsprintf_len(string, format, args)
|
|
||||||
char *string;
|
|
||||||
const char *format;
|
|
||||||
va_list args;
|
|
||||||
{
|
{
|
||||||
vsprintf(string, format, args);
|
vsprintf(string, format, args);
|
||||||
return strlen(string);
|
return strlen(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int sprintf_len(char *string, const char *format, ...)
|
||||||
#ifdef __STDC__
|
|
||||||
sprintf_len(char *string, const char *format, ...)
|
|
||||||
#else
|
|
||||||
sprintf_len(va_alist) va_dcl
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
#ifdef __STDC__
|
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
#else
|
|
||||||
char *string;
|
|
||||||
char *format;
|
|
||||||
va_start(args);
|
|
||||||
string = va_arg(args, char *);
|
|
||||||
format = va_arg(args, char *);
|
|
||||||
#endif
|
|
||||||
vsprintf(string, format, args);
|
vsprintf(string, format, args);
|
||||||
|
va_end(args);
|
||||||
return strlen(string);
|
return strlen(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
void u_sleep(int usec)
|
||||||
u_sleep(usec)
|
|
||||||
int usec;
|
|
||||||
{
|
{
|
||||||
struct timeval t;
|
struct timeval t;
|
||||||
fd_set fdset;
|
fd_set fdset;
|
||||||
@ -785,9 +744,7 @@ u_sleep(usec)
|
|||||||
* Set fd blocking and non-blocking
|
* Set fd blocking and non-blocking
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void fd_nonblock(int fd)
|
||||||
fd_nonblock(fd)
|
|
||||||
int fd;
|
|
||||||
{
|
{
|
||||||
#if defined USE_FIONBIO && defined FIONBIO
|
#if defined USE_FIONBIO && defined FIONBIO
|
||||||
ioctlsockopt_t opt = 1;
|
ioctlsockopt_t opt = 1;
|
||||||
@ -802,9 +759,7 @@ fd_nonblock(fd)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void fd_block(int fd)
|
||||||
fd_block(fd)
|
|
||||||
int fd;
|
|
||||||
{
|
{
|
||||||
#if defined USE_FIONBIO && defined FIONBIO
|
#if defined USE_FIONBIO && defined FIONBIO
|
||||||
ioctlsockopt_t opt = 0;
|
ioctlsockopt_t opt = 0;
|
||||||
@ -824,13 +779,8 @@ fd_block(fd)
|
|||||||
/*
|
/*
|
||||||
* invoke RSH
|
* invoke RSH
|
||||||
*/
|
*/
|
||||||
int
|
int rsh_exec(struct socket *so, struct socket *ns,
|
||||||
rsh_exec(so,ns, user, host, args)
|
char *user, char *host, char *args)
|
||||||
struct socket *so;
|
|
||||||
struct socket *ns;
|
|
||||||
char *user;
|
|
||||||
char *host;
|
|
||||||
char *args;
|
|
||||||
{
|
{
|
||||||
int fd[2];
|
int fd[2];
|
||||||
int fd0[2];
|
int fd0[2];
|
||||||
|
38
BasiliskII/src/slirp/misc.h
Executable file → Normal file
38
BasiliskII/src/slirp/misc.h
Executable file → Normal file
@ -19,15 +19,15 @@ struct ex_list {
|
|||||||
extern struct ex_list *exec_list;
|
extern struct ex_list *exec_list;
|
||||||
extern u_int curtime, time_fasttimo, last_slowtimo, detach_time, detach_wait;
|
extern u_int curtime, time_fasttimo, last_slowtimo, detach_time, detach_wait;
|
||||||
|
|
||||||
extern int (*lprint_print) _P((void *, const char *, va_list));
|
extern int (*lprint_print)(void *, const char *, va_list);
|
||||||
extern char *lprint_ptr, *lprint_ptr2, **lprint_arg;
|
extern char *lprint_ptr, *lprint_ptr2, **lprint_arg;
|
||||||
extern struct sbuf *lprint_sb;
|
extern struct sbuf *lprint_sb;
|
||||||
|
|
||||||
#ifndef HAVE_STRDUP
|
#ifndef HAVE_STRDUP
|
||||||
char *strdup _P((const char *));
|
char *strdup(const char *);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void do_wait _P((int));
|
void do_wait(int);
|
||||||
|
|
||||||
#define EMU_NONE 0x0
|
#define EMU_NONE 0x0
|
||||||
|
|
||||||
@ -67,21 +67,21 @@ extern struct emu_t *tcpemu;
|
|||||||
|
|
||||||
extern int x_port, x_server, x_display;
|
extern int x_port, x_server, x_display;
|
||||||
|
|
||||||
int show_x _P((char *, struct socket *));
|
int show_x(char *, struct socket *);
|
||||||
void redir_x _P((u_int32_t, int, int, int));
|
void redir_x(u_int32_t, int, int, int);
|
||||||
void getouraddr _P((void));
|
void getouraddr(void);
|
||||||
void slirp_insque _P((void *, void *));
|
void slirp_insque(void *, void *);
|
||||||
void slirp_remque _P((void *));
|
void slirp_remque(void *);
|
||||||
int add_exec _P((struct ex_list **, int, char *, int, int));
|
int add_exec(struct ex_list **, int, char *, int, int);
|
||||||
int slirp_openpty _P((int *, int *));
|
int slirp_openpty(int *, int *);
|
||||||
int fork_exec _P((struct socket *, char *, int));
|
int fork_exec(struct socket *, char *, int);
|
||||||
void snooze_hup _P((int));
|
void snooze_hup(int);
|
||||||
void snooze _P((void));
|
void snooze(void);
|
||||||
void relay _P((int));
|
void relay(int);
|
||||||
void add_emu _P((char *));
|
void add_emu(char *);
|
||||||
void u_sleep _P((int));
|
void u_sleep(int);
|
||||||
void fd_nonblock _P((int));
|
void fd_nonblock(int);
|
||||||
void fd_block _P((int));
|
void fd_block(int);
|
||||||
int rsh_exec _P((struct socket *, struct socket *, char *, char *, char *));
|
int rsh_exec(struct socket *, struct socket *, char *, char *, char *);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
35
BasiliskII/src/slirp/sbuf.c
Executable file → Normal file
35
BasiliskII/src/slirp/sbuf.c
Executable file → Normal file
@ -5,7 +5,7 @@
|
|||||||
* terms and conditions of the copyright.
|
* terms and conditions of the copyright.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// #include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <slirp.h>
|
#include <slirp.h>
|
||||||
|
|
||||||
/* Done as a macro in socket.h */
|
/* Done as a macro in socket.h */
|
||||||
@ -16,17 +16,12 @@
|
|||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void sbfree(struct sbuf *sb)
|
||||||
sbfree(sb)
|
|
||||||
struct sbuf *sb;
|
|
||||||
{
|
{
|
||||||
free(sb->sb_data);
|
free(sb->sb_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void sbdrop(struct sbuf *sb, u_int num)
|
||||||
sbdrop(sb, num)
|
|
||||||
struct sbuf *sb;
|
|
||||||
int num;
|
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* We can only drop how much we have
|
* We can only drop how much we have
|
||||||
@ -41,10 +36,7 @@ sbdrop(sb, num)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void sbreserve(struct sbuf *sb, size_t size)
|
||||||
sbreserve(sb, size)
|
|
||||||
struct sbuf *sb;
|
|
||||||
int size;
|
|
||||||
{
|
{
|
||||||
if (sb->sb_data) {
|
if (sb->sb_data) {
|
||||||
/* Already alloced, realloc if necessary */
|
/* Already alloced, realloc if necessary */
|
||||||
@ -72,17 +64,14 @@ sbreserve(sb, size)
|
|||||||
* this prevents an unnecessary copy of the data
|
* this prevents an unnecessary copy of the data
|
||||||
* (the socket is non-blocking, so we won't hang)
|
* (the socket is non-blocking, so we won't hang)
|
||||||
*/
|
*/
|
||||||
void
|
void sbappend(struct socket *so, struct mbuf *m)
|
||||||
sbappend(so, m)
|
|
||||||
struct socket *so;
|
|
||||||
struct mbuf *m;
|
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
DEBUG_CALL("sbappend");
|
DEBUG_CALL("sbappend");
|
||||||
DEBUG_ARG("so = %lx", (long)so);
|
DEBUG_ARG("so = %lx", (long)so);
|
||||||
DEBUG_ARG("m = %lx", (long)m);
|
DEBUG_ARG("m = %lx", (long)m);
|
||||||
DEBUG_ARG("m->m_len = %d", m->m_len);
|
DEBUG_ARG("m->m_len = %zu", m->m_len);
|
||||||
|
|
||||||
/* Shouldn't happen, but... e.g. foreign host closes connection */
|
/* Shouldn't happen, but... e.g. foreign host closes connection */
|
||||||
if (m->m_len <= 0) {
|
if (m->m_len <= 0) {
|
||||||
@ -134,10 +123,7 @@ sbappend(so, m)
|
|||||||
* Copy the data from m into sb
|
* Copy the data from m into sb
|
||||||
* The caller is responsible to make sure there's enough room
|
* The caller is responsible to make sure there's enough room
|
||||||
*/
|
*/
|
||||||
void
|
void sbappendsb(struct sbuf *sb, struct mbuf *m)
|
||||||
sbappendsb(sb, m)
|
|
||||||
struct sbuf *sb;
|
|
||||||
struct mbuf *m;
|
|
||||||
{
|
{
|
||||||
int len, n, nn;
|
int len, n, nn;
|
||||||
|
|
||||||
@ -173,12 +159,7 @@ sbappendsb(sb, m)
|
|||||||
* Don't update the sbuf rptr, this will be
|
* Don't update the sbuf rptr, this will be
|
||||||
* done in sbdrop when the data is acked
|
* done in sbdrop when the data is acked
|
||||||
*/
|
*/
|
||||||
void
|
void sbcopy(struct sbuf *sb, u_int off, u_int len, char *to)
|
||||||
sbcopy(sb, off, len, to)
|
|
||||||
struct sbuf *sb;
|
|
||||||
int off;
|
|
||||||
int len;
|
|
||||||
char *to;
|
|
||||||
{
|
{
|
||||||
char *from;
|
char *from;
|
||||||
|
|
||||||
|
14
BasiliskII/src/slirp/sbuf.h
Executable file → Normal file
14
BasiliskII/src/slirp/sbuf.h
Executable file → Normal file
@ -8,6 +8,8 @@
|
|||||||
#ifndef _SBUF_H_
|
#ifndef _SBUF_H_
|
||||||
#define _SBUF_H_
|
#define _SBUF_H_
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
#define sbflush(sb) sbdrop((sb),(sb)->sb_cc)
|
#define sbflush(sb) sbdrop((sb),(sb)->sb_cc)
|
||||||
#define sbspace(sb) ((sb)->sb_datalen - (sb)->sb_cc)
|
#define sbspace(sb) ((sb)->sb_datalen - (sb)->sb_cc)
|
||||||
|
|
||||||
@ -21,11 +23,11 @@ struct sbuf {
|
|||||||
char *sb_data; /* Actual data */
|
char *sb_data; /* Actual data */
|
||||||
};
|
};
|
||||||
|
|
||||||
void sbfree _P((struct sbuf *));
|
void sbfree(struct sbuf *);
|
||||||
void sbdrop _P((struct sbuf *, int));
|
void sbdrop(struct sbuf *, u_int);
|
||||||
void sbreserve _P((struct sbuf *, int));
|
void sbreserve(struct sbuf *, size_t);
|
||||||
void sbappend _P((struct socket *, struct mbuf *));
|
void sbappend(struct socket *, struct mbuf *);
|
||||||
void sbappendsb _P((struct sbuf *, struct mbuf *));
|
void sbappendsb(struct sbuf *, struct mbuf *);
|
||||||
void sbcopy _P((struct sbuf *, int, int, char *));
|
void sbcopy(struct sbuf *, u_int, u_int, char *);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
190
BasiliskII/src/slirp/slirp.c
Executable file → Normal file
190
BasiliskII/src/slirp/slirp.c
Executable file → Normal file
@ -84,7 +84,7 @@ static int get_dns_addr(struct in_addr *pdns_addr)
|
|||||||
static int get_dns_addr(struct in_addr *pdns_addr)
|
static int get_dns_addr(struct in_addr *pdns_addr)
|
||||||
{
|
{
|
||||||
char buff[512];
|
char buff[512];
|
||||||
char buff2[256];
|
char buff2[256+1];
|
||||||
FILE *f;
|
FILE *f;
|
||||||
int found = 0;
|
int found = 0;
|
||||||
struct in_addr tmp_addr;
|
struct in_addr tmp_addr;
|
||||||
@ -211,8 +211,8 @@ int slirp_select_fill(int *pnfds,
|
|||||||
* in the fragment queue, or there are TCP connections active
|
* in the fragment queue, or there are TCP connections active
|
||||||
*/
|
*/
|
||||||
do_slowtimo = ((tcb.so_next != &tcb) ||
|
do_slowtimo = ((tcb.so_next != &tcb) ||
|
||||||
(&ipq.ip_link != ipq.ip_link.next));
|
((struct ipasfrag *)&ipq != (struct ipasfrag *)ipq.next));
|
||||||
|
|
||||||
for (so = tcb.so_next; so != &tcb; so = so_next) {
|
for (so = tcb.so_next; so != &tcb; so = so_next) {
|
||||||
so_next = so->so_next;
|
so_next = so->so_next;
|
||||||
|
|
||||||
@ -220,14 +220,14 @@ int slirp_select_fill(int *pnfds,
|
|||||||
* See if we need a tcp_fasttimo
|
* See if we need a tcp_fasttimo
|
||||||
*/
|
*/
|
||||||
if (time_fasttimo == 0 && so->so_tcpcb->t_flags & TF_DELACK)
|
if (time_fasttimo == 0 && so->so_tcpcb->t_flags & TF_DELACK)
|
||||||
time_fasttimo = curtime; /* Flag when we want a fasttimo */
|
time_fasttimo = curtime; /* Flag when we want a fasttimo */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NOFDREF can include still connecting to local-host,
|
* NOFDREF can include still connecting to local-host,
|
||||||
* newly socreated() sockets etc. Don't want to select these.
|
* newly socreated() sockets etc. Don't want to select these.
|
||||||
*/
|
*/
|
||||||
if (so->so_state & SS_NOFDREF || so->s == -1)
|
if (so->so_state & SS_NOFDREF || so->s == -1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set for reading sockets which are accepting
|
* Set for reading sockets which are accepting
|
||||||
@ -346,18 +346,18 @@ int slirp_select_fill(int *pnfds,
|
|||||||
|
|
||||||
void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds)
|
void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds)
|
||||||
{
|
{
|
||||||
struct socket *so, *so_next;
|
struct socket *so, *so_next;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
global_readfds = readfds;
|
global_readfds = readfds;
|
||||||
global_writefds = writefds;
|
global_writefds = writefds;
|
||||||
global_xfds = xfds;
|
global_xfds = xfds;
|
||||||
|
|
||||||
/* Update time */
|
/* Update time */
|
||||||
updtime();
|
updtime();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* See if anything has timed out
|
* See if anything has timed out
|
||||||
*/
|
*/
|
||||||
if (link_up) {
|
if (link_up) {
|
||||||
if (time_fasttimo && ((curtime - time_fasttimo) >= FAST_TIMO)) {
|
if (time_fasttimo && ((curtime - time_fasttimo) >= FAST_TIMO)) {
|
||||||
@ -370,7 +370,7 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds)
|
|||||||
last_slowtimo = curtime;
|
last_slowtimo = curtime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check sockets
|
* Check sockets
|
||||||
*/
|
*/
|
||||||
@ -380,21 +380,21 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds)
|
|||||||
*/
|
*/
|
||||||
for (so = tcb.so_next; so != &tcb; so = so_next) {
|
for (so = tcb.so_next; so != &tcb; so = so_next) {
|
||||||
so_next = so->so_next;
|
so_next = so->so_next;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FD_ISSET is meaningless on these sockets
|
* FD_ISSET is meaningless on these sockets
|
||||||
* (and they can crash the program)
|
* (and they can crash the program)
|
||||||
*/
|
*/
|
||||||
if (so->so_state & SS_NOFDREF || so->s == -1)
|
if (so->so_state & SS_NOFDREF || so->s == -1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check for URG data
|
* Check for URG data
|
||||||
* This will soread as well, so no need to
|
* This will soread as well, so no need to
|
||||||
* test for readfds below if this succeeds
|
* test for readfds below if this succeeds
|
||||||
*/
|
*/
|
||||||
if (FD_ISSET(so->s, xfds))
|
if (FD_ISSET(so->s, xfds))
|
||||||
sorecvoob(so);
|
sorecvoob(so);
|
||||||
/*
|
/*
|
||||||
* Check sockets for reading
|
* Check sockets for reading
|
||||||
*/
|
*/
|
||||||
@ -407,86 +407,92 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds)
|
|||||||
continue;
|
continue;
|
||||||
} /* else */
|
} /* else */
|
||||||
ret = soread(so);
|
ret = soread(so);
|
||||||
|
|
||||||
/* Output it if we read something */
|
/* Output it if we read something */
|
||||||
if (ret > 0)
|
if (ret > 0)
|
||||||
tcp_output(sototcpcb(so));
|
tcp_output(sototcpcb(so));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check sockets for writing
|
* Check sockets for writing
|
||||||
*/
|
*/
|
||||||
if (FD_ISSET(so->s, writefds)) {
|
if (FD_ISSET(so->s, writefds)) {
|
||||||
/*
|
/*
|
||||||
* Check for non-blocking, still-connecting sockets
|
* Check for non-blocking, still-connecting sockets
|
||||||
*/
|
*/
|
||||||
if (so->so_state & SS_ISFCONNECTING) {
|
if (so->so_state & SS_ISFCONNECTING) {
|
||||||
/* Connected */
|
/* Connected */
|
||||||
so->so_state &= ~SS_ISFCONNECTING;
|
so->so_state &= ~SS_ISFCONNECTING;
|
||||||
|
|
||||||
ret = send(so->s, &ret, 0, 0);
|
ret = send(so->s, (char*)&ret, 0, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
/* XXXXX Must fix, zero bytes is a NOP */
|
/* XXXXX Must fix, zero bytes is a NOP */
|
||||||
if (errno == EAGAIN || errno == EWOULDBLOCK ||
|
int error = WSAGetLastError();
|
||||||
errno == EINPROGRESS || errno == ENOTCONN)
|
if (error == EAGAIN || error == WSAEWOULDBLOCK ||
|
||||||
continue;
|
error == WSAEINPROGRESS || error == WSAENOTCONN)
|
||||||
|
continue;
|
||||||
/* else failed */
|
|
||||||
so->so_state = SS_NOFDREF;
|
/* else failed */
|
||||||
}
|
so->so_state = SS_NOFDREF;
|
||||||
/* else so->so_state &= ~SS_ISFCONNECTING; */
|
}
|
||||||
|
/* else so->so_state &= ~SS_ISFCONNECTING; */
|
||||||
/*
|
|
||||||
* Continue tcp_input
|
/*
|
||||||
*/
|
* Continue tcp_input
|
||||||
tcp_input((struct mbuf *)NULL, sizeof(struct ip), so);
|
*/
|
||||||
/* continue; */
|
tcp_input((struct mbuf *)NULL, sizeof(struct ip), so);
|
||||||
} else
|
/* continue; */
|
||||||
ret = sowrite(so);
|
}
|
||||||
/*
|
else
|
||||||
* XXXXX If we wrote something (a lot), there
|
ret = sowrite(so);
|
||||||
* could be a need for a window update.
|
/*
|
||||||
* In the worst case, the remote will send
|
* XXXXX If we wrote something (a lot), there
|
||||||
* a window probe to get things going again
|
* could be a need for a window update.
|
||||||
*/
|
* In the worst case, the remote will send
|
||||||
|
* a window probe to get things going again
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Probe a still-connecting, non-blocking socket
|
* Probe a still-connecting, non-blocking socket
|
||||||
* to check if it's still alive
|
* to check if it's still alive
|
||||||
*/
|
*/
|
||||||
#ifdef PROBE_CONN
|
#ifdef PROBE_CONN
|
||||||
if (so->so_state & SS_ISFCONNECTING) {
|
if (so->so_state & SS_ISFCONNECTING) {
|
||||||
ret = recv(so->s, (char *)&ret, 0,0);
|
ret = recv(so->s, (char *)&ret, 0, 0);
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
/* XXX */
|
/* XXX */
|
||||||
if (errno == EAGAIN || errno == EWOULDBLOCK ||
|
int error = WSAGetLastError();
|
||||||
errno == EINPROGRESS || errno == ENOTCONN)
|
if (error == EAGAIN || error == WSAEWOULDBLOCK ||
|
||||||
continue; /* Still connecting, continue */
|
error == WSAEINPROGRESS || error == WSAENOTCONN)
|
||||||
|
continue; /* Still connecting, continue */
|
||||||
/* else failed */
|
|
||||||
so->so_state = SS_NOFDREF;
|
/* else failed */
|
||||||
|
so->so_state = SS_NOFDREF;
|
||||||
/* tcp_input will take care of it */
|
|
||||||
} else {
|
/* tcp_input will take care of it */
|
||||||
ret = send(so->s, &ret, 0,0);
|
}
|
||||||
if (ret < 0) {
|
else {
|
||||||
/* XXX */
|
ret = send(so->s, &ret, 0, 0);
|
||||||
if (errno == EAGAIN || errno == EWOULDBLOCK ||
|
if (ret < 0) {
|
||||||
errno == EINPROGRESS || errno == ENOTCONN)
|
/* XXX */
|
||||||
continue;
|
int error = WSAGetLastError();
|
||||||
/* else failed */
|
if (error == EAGAIN || error == WSAEWOULDBLOCK ||
|
||||||
so->so_state = SS_NOFDREF;
|
error == WSAEINPROGRESS || error == WSAENOTCONN)
|
||||||
} else
|
continue;
|
||||||
so->so_state &= ~SS_ISFCONNECTING;
|
/* else failed */
|
||||||
|
so->so_state = SS_NOFDREF;
|
||||||
}
|
}
|
||||||
tcp_input((struct mbuf *)NULL, sizeof(struct ip),so);
|
else
|
||||||
} /* SS_ISFCONNECTING */
|
so->so_state &= ~SS_ISFCONNECTING;
|
||||||
|
|
||||||
|
}
|
||||||
|
tcp_input((struct mbuf *)NULL, sizeof(struct ip), so);
|
||||||
|
} /* SS_ISFCONNECTING */
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now UDP sockets.
|
* Now UDP sockets.
|
||||||
* Incoming packets are sent straight away, they're not buffered.
|
* Incoming packets are sent straight away, they're not buffered.
|
||||||
@ -494,27 +500,27 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds)
|
|||||||
*/
|
*/
|
||||||
for (so = udb.so_next; so != &udb; so = so_next) {
|
for (so = udb.so_next; so != &udb; so = so_next) {
|
||||||
so_next = so->so_next;
|
so_next = so->so_next;
|
||||||
|
|
||||||
if (so->s != -1 && FD_ISSET(so->s, readfds)) {
|
if (so->s != -1 && FD_ISSET(so->s, readfds)) {
|
||||||
sorecvfrom(so);
|
sorecvfrom(so);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* See if we can start outputting
|
* See if we can start outputting
|
||||||
*/
|
*/
|
||||||
if (if_queued && link_up)
|
if (if_queued && link_up)
|
||||||
if_start();
|
if_start();
|
||||||
|
|
||||||
/* clear global file descriptor sets.
|
/* clear global file descriptor sets.
|
||||||
* these reside on the stack in vl.c
|
* these reside on the stack in vl.c
|
||||||
* so they're unusable if we're not in
|
* so they're unusable if we're not in
|
||||||
* slirp_select_fill or slirp_select_poll.
|
* slirp_select_fill or slirp_select_poll.
|
||||||
*/
|
*/
|
||||||
global_readfds = NULL;
|
global_readfds = NULL;
|
||||||
global_writefds = NULL;
|
global_writefds = NULL;
|
||||||
global_xfds = NULL;
|
global_xfds = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ETH_ALEN 6
|
#define ETH_ALEN 6
|
||||||
|
133
BasiliskII/src/slirp/slirp.h
Executable file → Normal file
133
BasiliskII/src/slirp/slirp.h
Executable file → Normal file
@ -22,18 +22,12 @@ typedef char *caddr_t;
|
|||||||
typedef int socklen_t;
|
typedef int socklen_t;
|
||||||
typedef unsigned long ioctlsockopt_t;
|
typedef unsigned long ioctlsockopt_t;
|
||||||
|
|
||||||
# include <windows.h>
|
|
||||||
# include <winsock2.h>
|
# include <winsock2.h>
|
||||||
|
# include <WS2tcpip.h>
|
||||||
# include <sys/timeb.h>
|
# include <sys/timeb.h>
|
||||||
# include <iphlpapi.h>
|
# include <iphlpapi.h>
|
||||||
|
|
||||||
# define USE_FIONBIO 1
|
# define USE_FIONBIO 1
|
||||||
# define EWOULDBLOCK WSAEWOULDBLOCK
|
|
||||||
# define EINPROGRESS WSAEINPROGRESS
|
|
||||||
# define ENOTCONN WSAENOTCONN
|
|
||||||
# define EHOSTUNREACH WSAEHOSTUNREACH
|
|
||||||
# define ENETUNREACH WSAENETUNREACH
|
|
||||||
# define ECONNREFUSED WSAECONNREFUSED
|
|
||||||
|
|
||||||
/* Basilisk II Router defines those */
|
/* Basilisk II Router defines those */
|
||||||
# define udp_read_completion slirp_udp_read_completion
|
# define udp_read_completion slirp_udp_read_completion
|
||||||
@ -139,35 +133,29 @@ typedef u_int32_t uint32;
|
|||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _P
|
|
||||||
#ifndef NO_PROTOTYPES
|
|
||||||
# define _P(x) x
|
|
||||||
#else
|
|
||||||
# define _P(x) ()
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef GETTIMEOFDAY_ONE_ARG
|
#ifdef GETTIMEOFDAY_ONE_ARG
|
||||||
#define gettimeofday(x, y) gettimeofday(x)
|
#define gettimeofday(x, y) gettimeofday(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Systems lacking strdup() definition in <string.h>. */
|
/* Systems lacking strdup() definition in <string.h>. */
|
||||||
#if defined(ultrix)
|
#if defined(ultrix)
|
||||||
char *strdup _P((const char *));
|
char *strdup(const char *);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Systems lacking malloc() definition in <stdlib.h>. */
|
/* Systems lacking malloc() definition in <stdlib.h>. */
|
||||||
#if defined(ultrix) || defined(hcx)
|
#if defined(ultrix) || defined(hcx)
|
||||||
void *malloc _P((size_t arg));
|
void *malloc(size_t arg);
|
||||||
void free _P((void *ptr));
|
void free(void *ptr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_INET_ATON
|
#ifndef HAVE_INET_ATON
|
||||||
int inet_aton _P((const char *cp, struct in_addr *ia));
|
int inet_aton(const char *cp, struct in_addr *ia);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <io.h>
|
||||||
|
#endif
|
||||||
#ifndef NO_UNIX_SOCKETS
|
#ifndef NO_UNIX_SOCKETS
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
#endif
|
#endif
|
||||||
@ -199,11 +187,7 @@ int inet_aton _P((const char *cp, struct in_addr *ia));
|
|||||||
#include <ppp/slirppp.h>
|
#include <ppp/slirppp.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __STDC__
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#else
|
|
||||||
#include <varargs.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
@ -220,8 +204,13 @@ int inet_aton _P((const char *cp, struct in_addr *ia));
|
|||||||
|
|
||||||
#if defined __GNUC__
|
#if defined __GNUC__
|
||||||
#define PACKED__ __attribute__ ((packed))
|
#define PACKED__ __attribute__ ((packed))
|
||||||
|
#elif defined _MSC_VER
|
||||||
|
#define PRAGMA_PACK_SUPPORTED 1
|
||||||
|
#define PACK_RESET
|
||||||
|
#define PACKED__
|
||||||
#elif defined __sgi
|
#elif defined __sgi
|
||||||
#define PRAGMA_PACK_SUPPORTED 1
|
#define PRAGMA_PACK_SUPPORTED 1
|
||||||
|
#define PACK_RESET 0
|
||||||
#define PACKED__
|
#define PACKED__
|
||||||
#else
|
#else
|
||||||
#error "Packed attribute or pragma shall be supported"
|
#error "Packed attribute or pragma shall be supported"
|
||||||
@ -257,41 +246,49 @@ extern struct ttys *ttys_unit[MAX_INTERFACES];
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef FULL_BOLT
|
#ifndef FULL_BOLT
|
||||||
void if_start _P((void));
|
void if_start(void);
|
||||||
#else
|
#else
|
||||||
void if_start _P((struct ttys *));
|
void if_start(struct ttys *);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef BAD_SPRINTF
|
#ifdef BAD_SPRINTF
|
||||||
# define vsprintf vsprintf_len
|
# define vsprintf vsprintf_len
|
||||||
# define sprintf sprintf_len
|
# define sprintf sprintf_len
|
||||||
extern int vsprintf_len _P((char *, const char *, va_list));
|
extern int vsprintf_len(char *, const char *, va_list);
|
||||||
extern int sprintf_len _P((char *, const char *, ...));
|
extern int sprintf_len(char *, const char *, ...);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DECLARE_SPRINTF
|
#ifdef DECLARE_SPRINTF
|
||||||
# ifndef BAD_SPRINTF
|
# ifndef BAD_SPRINTF
|
||||||
extern int vsprintf _P((char *, const char *, va_list));
|
extern int vsprintf(char *, const char *, va_list);
|
||||||
# endif
|
# endif
|
||||||
extern int vfprintf _P((FILE *, const char *, va_list));
|
extern int vfprintf(FILE *, const char *, va_list);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_STRERROR
|
#ifndef HAVE_STRERROR
|
||||||
extern char *strerror _P((int error));
|
extern char *strerror(int error);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_INDEX
|
#ifndef HAVE_INDEX
|
||||||
char *index _P((const char *, int));
|
char *index(const char *, int);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_GETHOSTID
|
#ifndef HAVE_GETHOSTID
|
||||||
long gethostid _P((void));
|
long gethostid(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void lprint _P((const char *, ...));
|
void lprint(const char *, ...);
|
||||||
|
|
||||||
extern int do_echo;
|
extern int do_echo;
|
||||||
|
|
||||||
|
#if SIZEOF_CHAR_P == 4
|
||||||
|
# define insque_32 insque
|
||||||
|
# define remque_32 remque
|
||||||
|
#else
|
||||||
|
extern inline void insque_32(void *, void *);
|
||||||
|
extern inline void remque_32(void *);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#endif
|
#endif
|
||||||
@ -302,48 +299,47 @@ extern int do_echo;
|
|||||||
int cksum(struct mbuf *m, int len);
|
int cksum(struct mbuf *m, int len);
|
||||||
|
|
||||||
/* if.c */
|
/* if.c */
|
||||||
void if_init _P((void));
|
void if_init(void);
|
||||||
void if_output _P((struct socket *, struct mbuf *));
|
void if_output(struct socket *, struct mbuf *);
|
||||||
|
|
||||||
/* ip_input.c */
|
/* ip_input.c */
|
||||||
void ip_init _P((void));
|
void ip_init(void);
|
||||||
void ip_input _P((struct mbuf *));
|
void ip_input(struct mbuf *);
|
||||||
static struct ip *
|
struct ip * ip_reass(register struct ipasfrag *, register struct ipq *);
|
||||||
ip_reass(register struct ip *ip, register struct ipq *);
|
void ip_freef(struct ipq *);
|
||||||
void ip_freef _P((struct ipq *));
|
void ip_enq(register struct ipasfrag *, register struct ipasfrag *);
|
||||||
void ip_enq _P((register struct ipasfrag *, register struct ipasfrag *));
|
void ip_deq(register struct ipasfrag *);
|
||||||
void ip_deq _P((register struct ipasfrag *));
|
void ip_slowtimo(void);
|
||||||
void ip_slowtimo _P((void));
|
void ip_stripoptions(register struct mbuf *, struct mbuf *);
|
||||||
void ip_stripoptions _P((register struct mbuf *, struct mbuf *));
|
|
||||||
|
|
||||||
/* ip_output.c */
|
/* ip_output.c */
|
||||||
int ip_output _P((struct socket *, struct mbuf *));
|
int ip_output(struct socket *, struct mbuf *);
|
||||||
|
|
||||||
/* tcp_input.c */
|
/* tcp_input.c */
|
||||||
int tcp_reass _P((register struct tcpcb *, register struct tcpiphdr *, struct mbuf *));
|
int tcp_reass(register struct tcpcb *, register struct tcpiphdr *, struct mbuf *);
|
||||||
void tcp_input _P((register struct mbuf *, int, struct socket *));
|
void tcp_input(register struct mbuf *, int, struct socket *);
|
||||||
void tcp_dooptions _P((struct tcpcb *, u_char *, int, struct tcpiphdr *));
|
void tcp_dooptions(struct tcpcb *, u_char *, int, struct tcpiphdr *);
|
||||||
void tcp_xmit_timer _P((register struct tcpcb *, int));
|
void tcp_xmit_timer(register struct tcpcb *, int);
|
||||||
int tcp_mss _P((register struct tcpcb *, u_int));
|
u_int tcp_mss(register struct tcpcb *, u_int);
|
||||||
|
|
||||||
/* tcp_output.c */
|
/* tcp_output.c */
|
||||||
int tcp_output _P((register struct tcpcb *));
|
int tcp_output(register struct tcpcb *);
|
||||||
void tcp_setpersist _P((register struct tcpcb *));
|
void tcp_setpersist(register struct tcpcb *);
|
||||||
|
|
||||||
/* tcp_subr.c */
|
/* tcp_subr.c */
|
||||||
void tcp_init _P((void));
|
void tcp_init(void);
|
||||||
void tcp_template _P((struct tcpcb *));
|
void tcp_template(struct tcpcb *);
|
||||||
void tcp_respond _P((struct tcpcb *, register struct tcpiphdr *, register struct mbuf *, tcp_seq, tcp_seq, int));
|
void tcp_respond(struct tcpcb *, register struct tcpiphdr *, register struct mbuf *, tcp_seq, tcp_seq, int);
|
||||||
struct tcpcb * tcp_newtcpcb _P((struct socket *));
|
struct tcpcb * tcp_newtcpcb(struct socket *);
|
||||||
struct tcpcb * tcp_close _P((register struct tcpcb *));
|
struct tcpcb * tcp_close(register struct tcpcb *);
|
||||||
void tcp_drain _P((void));
|
void tcp_drain(void);
|
||||||
void tcp_sockclosed _P((struct tcpcb *));
|
void tcp_sockclosed(struct tcpcb *);
|
||||||
int tcp_fconnect _P((struct socket *));
|
int tcp_fconnect(struct socket *);
|
||||||
void tcp_connect _P((struct socket *));
|
void tcp_connect(struct socket *);
|
||||||
int tcp_attach _P((struct socket *));
|
int tcp_attach(struct socket *);
|
||||||
u_int8_t tcp_tos _P((struct socket *));
|
u_int8_t tcp_tos(struct socket *);
|
||||||
int tcp_emu _P((struct socket *, struct mbuf *));
|
int tcp_emu(struct socket *, struct mbuf *);
|
||||||
int tcp_ctl _P((struct socket *));
|
int tcp_ctl(struct socket *);
|
||||||
struct tcpcb *tcp_drop(struct tcpcb *tp, int err);
|
struct tcpcb *tcp_drop(struct tcpcb *tp, int err);
|
||||||
|
|
||||||
#ifdef USE_PPP
|
#ifdef USE_PPP
|
||||||
@ -359,9 +355,4 @@ struct tcpcb *tcp_drop(struct tcpcb *tp, int err);
|
|||||||
#define max(x,y) ((x) > (y) ? (x) : (y))
|
#define max(x,y) ((x) > (y) ? (x) : (y))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#undef errno
|
|
||||||
#define errno (WSAGetLastError())
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
8
BasiliskII/src/slirp/slirp_config.h
Executable file → Normal file
8
BasiliskII/src/slirp/slirp_config.h
Executable file → Normal file
@ -40,11 +40,6 @@
|
|||||||
*/
|
*/
|
||||||
#undef USE_LOWCPU
|
#undef USE_LOWCPU
|
||||||
|
|
||||||
/* Define this if your compiler doesn't like prototypes */
|
|
||||||
#ifndef __STDC__
|
|
||||||
#define NO_PROTOTYPES
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*********************************************************/
|
/*********************************************************/
|
||||||
/*
|
/*
|
||||||
* Autoconf defined configuration options
|
* Autoconf defined configuration options
|
||||||
@ -77,9 +72,6 @@
|
|||||||
/* Define if you have sys/stropts.h */
|
/* Define if you have sys/stropts.h */
|
||||||
#undef HAVE_SYS_STROPTS_H
|
#undef HAVE_SYS_STROPTS_H
|
||||||
|
|
||||||
/* Define if your compiler doesn't like prototypes */
|
|
||||||
#undef NO_PROTOTYPES
|
|
||||||
|
|
||||||
/* Define if you don't have u_int32_t etc. typedef'd */
|
/* Define if you don't have u_int32_t etc. typedef'd */
|
||||||
#undef NEED_TYPEDEFS
|
#undef NEED_TYPEDEFS
|
||||||
#ifdef __sun__
|
#ifdef __sun__
|
||||||
|
53
BasiliskII/src/slirp/socket.c
Executable file → Normal file
53
BasiliskII/src/slirp/socket.c
Executable file → Normal file
@ -14,6 +14,12 @@
|
|||||||
#include <sys/filio.h>
|
#include <sys/filio.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#define IS_EAGAIN(e) ((e) == WSAEINTR || (e) == EAGAIN)
|
||||||
|
#else
|
||||||
|
#define IS_EAGAIN(e) ((e) == EAGAIN)
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
so_init()
|
so_init()
|
||||||
{
|
{
|
||||||
@ -97,11 +103,12 @@ int
|
|||||||
soread(so)
|
soread(so)
|
||||||
struct socket *so;
|
struct socket *so;
|
||||||
{
|
{
|
||||||
int n, nn, lss, total;
|
int n, nn;
|
||||||
|
u_int lss, total;
|
||||||
struct sbuf *sb = &so->so_snd;
|
struct sbuf *sb = &so->so_snd;
|
||||||
int len = sb->sb_datalen - sb->sb_cc;
|
u_int len = sb->sb_datalen - sb->sb_cc;
|
||||||
struct iovec iov[2];
|
struct iovec iov[2];
|
||||||
int mss = so->so_tcpcb->t_maxseg;
|
u_int mss = so->so_tcpcb->t_maxseg;
|
||||||
|
|
||||||
DEBUG_CALL("soread");
|
DEBUG_CALL("soread");
|
||||||
DEBUG_ARG("so = %lx", (long )so);
|
DEBUG_ARG("so = %lx", (long )so);
|
||||||
@ -159,7 +166,8 @@ soread(so)
|
|||||||
nn = recv(so->s, iov[0].iov_base, iov[0].iov_len,0);
|
nn = recv(so->s, iov[0].iov_base, iov[0].iov_len,0);
|
||||||
#endif
|
#endif
|
||||||
if (nn <= 0) {
|
if (nn <= 0) {
|
||||||
if (nn < 0 && (errno == EINTR || errno == EAGAIN))
|
int error = WSAGetLastError();
|
||||||
|
if (nn < 0 && IS_EAGAIN(error))
|
||||||
return 0;
|
return 0;
|
||||||
else {
|
else {
|
||||||
DEBUG_MISC((dfd, " --- soread() disconnected, nn = %d, errno = %d-%s\n", nn, errno,strerror(errno)));
|
DEBUG_MISC((dfd, " --- soread() disconnected, nn = %d, errno = %d-%s\n", nn, errno,strerror(errno)));
|
||||||
@ -297,7 +305,7 @@ sowrite(so)
|
|||||||
{
|
{
|
||||||
int n,nn;
|
int n,nn;
|
||||||
struct sbuf *sb = &so->so_rcv;
|
struct sbuf *sb = &so->so_rcv;
|
||||||
int len = sb->sb_cc;
|
u_int len = sb->sb_cc;
|
||||||
struct iovec iov[2];
|
struct iovec iov[2];
|
||||||
|
|
||||||
DEBUG_CALL("sowrite");
|
DEBUG_CALL("sowrite");
|
||||||
@ -344,9 +352,12 @@ sowrite(so)
|
|||||||
nn = send(so->s, iov[0].iov_base, iov[0].iov_len,0);
|
nn = send(so->s, iov[0].iov_base, iov[0].iov_len,0);
|
||||||
#endif
|
#endif
|
||||||
/* This should never happen, but people tell me it does *shrug* */
|
/* This should never happen, but people tell me it does *shrug* */
|
||||||
if (nn < 0 && (errno == EAGAIN || errno == EINTR))
|
if (nn < 0) {
|
||||||
return 0;
|
int error = WSAGetLastError();
|
||||||
|
if (IS_EAGAIN(error))
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (nn <= 0) {
|
if (nn <= 0) {
|
||||||
DEBUG_MISC((dfd, " --- sowrite disconnected, so->so_state = %x, errno = %d\n",
|
DEBUG_MISC((dfd, " --- sowrite disconnected, so->so_state = %x, errno = %d\n",
|
||||||
so->so_state, errno));
|
so->so_state, errno));
|
||||||
@ -405,8 +416,9 @@ sorecvfrom(so)
|
|||||||
if(len == -1 || len == 0) {
|
if(len == -1 || len == 0) {
|
||||||
u_char code=ICMP_UNREACH_PORT;
|
u_char code=ICMP_UNREACH_PORT;
|
||||||
|
|
||||||
if(errno == EHOSTUNREACH) code=ICMP_UNREACH_HOST;
|
int error = WSAGetLastError();
|
||||||
else if(errno == ENETUNREACH) code=ICMP_UNREACH_NET;
|
if(error == WSAEHOSTUNREACH) code=ICMP_UNREACH_HOST;
|
||||||
|
else if(error == WSAENETUNREACH) code=ICMP_UNREACH_NET;
|
||||||
|
|
||||||
DEBUG_MISC((dfd," udp icmp rx errno = %d-%s\n",
|
DEBUG_MISC((dfd," udp icmp rx errno = %d-%s\n",
|
||||||
errno,strerror(errno)));
|
errno,strerror(errno)));
|
||||||
@ -419,7 +431,7 @@ sorecvfrom(so)
|
|||||||
udp_detach(so);
|
udp_detach(so);
|
||||||
} else { /* A "normal" UDP packet */
|
} else { /* A "normal" UDP packet */
|
||||||
struct mbuf *m;
|
struct mbuf *m;
|
||||||
int len;
|
u_int len;
|
||||||
ioctlsockopt_t n;
|
ioctlsockopt_t n;
|
||||||
|
|
||||||
if (!(m = m_get())) return;
|
if (!(m = m_get())) return;
|
||||||
@ -442,13 +454,14 @@ sorecvfrom(so)
|
|||||||
|
|
||||||
m->m_len = recvfrom(so->s, m->m_data, len, 0,
|
m->m_len = recvfrom(so->s, m->m_data, len, 0,
|
||||||
(struct sockaddr *)&addr, &addrlen);
|
(struct sockaddr *)&addr, &addrlen);
|
||||||
DEBUG_MISC((dfd, " did recvfrom %d, errno = %d-%s\n",
|
DEBUG_MISC((dfd, " did recvfrom %zu, errno = %d-%s\n",
|
||||||
m->m_len, errno,strerror(errno)));
|
m->m_len, errno,strerror(errno)));
|
||||||
if(m->m_len<0) {
|
if(m->m_len<0) {
|
||||||
u_char code=ICMP_UNREACH_PORT;
|
u_char code=ICMP_UNREACH_PORT;
|
||||||
|
|
||||||
if(errno == EHOSTUNREACH) code=ICMP_UNREACH_HOST;
|
int error = WSAGetLastError();
|
||||||
else if(errno == ENETUNREACH) code=ICMP_UNREACH_NET;
|
if(error == WSAEHOSTUNREACH) code=ICMP_UNREACH_HOST;
|
||||||
|
else if(error == WSAENETUNREACH) code=ICMP_UNREACH_NET;
|
||||||
|
|
||||||
DEBUG_MISC((dfd," rx error, tx icmp ICMP_UNREACH:%i\n", code));
|
DEBUG_MISC((dfd," rx error, tx icmp ICMP_UNREACH:%i\n", code));
|
||||||
icmp_error(so->so_m, ICMP_UNREACH,code, 0,strerror(errno));
|
icmp_error(so->so_m, ICMP_UNREACH,code, 0,strerror(errno));
|
||||||
@ -513,7 +526,9 @@ sosendto(so, m)
|
|||||||
addr.sin_addr = so->so_faddr;
|
addr.sin_addr = so->so_faddr;
|
||||||
addr.sin_port = so->so_fport;
|
addr.sin_port = so->so_fport;
|
||||||
|
|
||||||
DEBUG_MISC((dfd, " sendto()ing, addr.sin_port=%d, addr.sin_addr.s_addr=%.16s\n", ntohs(addr.sin_port), inet_ntoa(addr.sin_addr)));
|
char addrstr[INET_ADDRSTRLEN];
|
||||||
|
DEBUG_MISC((dfd, " sendto()ing, addr.sin_port=%d, addr.sin_addr.s_addr=%.16s\n",
|
||||||
|
ntohs(addr.sin_port), inet_ntop(AF_INET, &addr.sin_addr, addrstr, sizeof(addrstr))));
|
||||||
|
|
||||||
/* Don't care what port we get */
|
/* Don't care what port we get */
|
||||||
ret = sendto(so->s, m->m_data, m->m_len, 0,
|
ret = sendto(so->s, m->m_data, m->m_len, 0,
|
||||||
@ -584,16 +599,12 @@ solisten(port, laddr, lport, flags)
|
|||||||
(setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int)) < 0) ||
|
(setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int)) < 0) ||
|
||||||
(bind(s,(struct sockaddr *)&addr, sizeof(addr)) < 0) ||
|
(bind(s,(struct sockaddr *)&addr, sizeof(addr)) < 0) ||
|
||||||
(listen(s,1) < 0)) {
|
(listen(s,1) < 0)) {
|
||||||
int tmperrno = errno; /* Don't clobber the real reason we failed */
|
int error = WSAGetLastError(); /* Don't clobber the real reason we failed */
|
||||||
|
|
||||||
close(s);
|
close(s);
|
||||||
sofree(so);
|
sofree(so);
|
||||||
/* Restore the real errno */
|
/* Restore the real errno */
|
||||||
#ifdef _WIN32
|
WSASetLastError(error);
|
||||||
WSASetLastError(tmperrno);
|
|
||||||
#else
|
|
||||||
errno = tmperrno;
|
|
||||||
#endif
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
setsockopt(s,SOL_SOCKET,SO_OOBINLINE,(char *)&opt,sizeof(int));
|
setsockopt(s,SOL_SOCKET,SO_OOBINLINE,(char *)&opt,sizeof(int));
|
||||||
|
38
BasiliskII/src/slirp/socket.h
Executable file → Normal file
38
BasiliskII/src/slirp/socket.h
Executable file → Normal file
@ -81,24 +81,24 @@ struct iovec {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void so_init _P((void));
|
void so_init(void);
|
||||||
struct socket * solookup _P((struct socket *, struct in_addr, u_int, struct in_addr, u_int));
|
struct socket * solookup(struct socket *, struct in_addr, u_int, struct in_addr, u_int);
|
||||||
struct socket * socreate _P((void));
|
struct socket * socreate(void);
|
||||||
void sofree _P((struct socket *));
|
void sofree(struct socket *);
|
||||||
int soread _P((struct socket *));
|
int soread(struct socket *);
|
||||||
void sorecvoob _P((struct socket *));
|
void sorecvoob(struct socket *);
|
||||||
int sosendoob _P((struct socket *));
|
int sosendoob(struct socket *);
|
||||||
int sowrite _P((struct socket *));
|
int sowrite(struct socket *);
|
||||||
void sorecvfrom _P((struct socket *));
|
void sorecvfrom(struct socket *);
|
||||||
int sosendto _P((struct socket *, struct mbuf *));
|
int sosendto(struct socket *, struct mbuf *);
|
||||||
struct socket * solisten _P((u_int, u_int32_t, u_int, int));
|
struct socket * solisten(u_int, u_int32_t, u_int, int);
|
||||||
void sorwakeup _P((struct socket *));
|
void sorwakeup(struct socket *);
|
||||||
void sowwakeup _P((struct socket *));
|
void sowwakeup(struct socket *);
|
||||||
void soisfconnecting _P((register struct socket *));
|
void soisfconnecting(register struct socket *);
|
||||||
void soisfconnected _P((register struct socket *));
|
void soisfconnected(register struct socket *);
|
||||||
void sofcantrcvmore _P((struct socket *));
|
void sofcantrcvmore(struct socket *);
|
||||||
void sofcantsendmore _P((struct socket *));
|
void sofcantsendmore(struct socket *);
|
||||||
void soisfdisconnected _P((struct socket *));
|
void soisfdisconnected(struct socket *);
|
||||||
void sofwdrain _P((struct socket *));
|
void sofwdrain(struct socket *);
|
||||||
|
|
||||||
#endif /* _SOCKET_H_ */
|
#endif /* _SOCKET_H_ */
|
||||||
|
6
BasiliskII/src/slirp/tcp.h
Executable file → Normal file
6
BasiliskII/src/slirp/tcp.h
Executable file → Normal file
@ -38,8 +38,8 @@ typedef u_int32_t tcp_seq;
|
|||||||
#define PR_SLOWHZ 2 /* 2 slow timeouts per second (approx) */
|
#define PR_SLOWHZ 2 /* 2 slow timeouts per second (approx) */
|
||||||
#define PR_FASTHZ 5 /* 5 fast timeouts per second (not important) */
|
#define PR_FASTHZ 5 /* 5 fast timeouts per second (not important) */
|
||||||
|
|
||||||
extern int tcp_rcvspace;
|
extern size_t tcp_rcvspace;
|
||||||
extern int tcp_sndspace;
|
extern size_t tcp_sndspace;
|
||||||
extern struct socket *tcp_last_so;
|
extern struct socket *tcp_last_so;
|
||||||
|
|
||||||
#define TCP_SNDSPACE 8192
|
#define TCP_SNDSPACE 8192
|
||||||
@ -78,7 +78,7 @@ struct tcphdr {
|
|||||||
} PACKED__;
|
} PACKED__;
|
||||||
|
|
||||||
#ifdef PRAGMA_PACK_SUPPORTED
|
#ifdef PRAGMA_PACK_SUPPORTED
|
||||||
#pragma pack(0)
|
#pragma pack(PACK_RESET)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "tcp_var.h"
|
#include "tcp_var.h"
|
||||||
|
1066
BasiliskII/src/slirp/tcp_input.c
Executable file → Normal file
1066
BasiliskII/src/slirp/tcp_input.c
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
30
BasiliskII/src/slirp/tcp_output.c
Executable file → Normal file
30
BasiliskII/src/slirp/tcp_output.c
Executable file → Normal file
@ -63,9 +63,7 @@ u_char tcp_outflags[TCP_NSTATES] = {
|
|||||||
/*
|
/*
|
||||||
* Tcp output routine: figure out what should be sent and send it.
|
* Tcp output routine: figure out what should be sent and send it.
|
||||||
*/
|
*/
|
||||||
int
|
int tcp_output(register struct tcpcb *tp)
|
||||||
tcp_output(tp)
|
|
||||||
register struct tcpcb *tp;
|
|
||||||
{
|
{
|
||||||
register struct socket *so = tp->t_socket;
|
register struct socket *so = tp->t_socket;
|
||||||
register long len, win;
|
register long len, win;
|
||||||
@ -126,7 +124,7 @@ again:
|
|||||||
* to send then the probe will be the FIN
|
* to send then the probe will be the FIN
|
||||||
* itself.
|
* itself.
|
||||||
*/
|
*/
|
||||||
if (off < so->so_snd.sb_cc)
|
if (off < (int)so->so_snd.sb_cc)
|
||||||
flags &= ~TH_FIN;
|
flags &= ~TH_FIN;
|
||||||
win = 1;
|
win = 1;
|
||||||
} else {
|
} else {
|
||||||
@ -201,12 +199,12 @@ again:
|
|||||||
* taking into account that we are limited by
|
* taking into account that we are limited by
|
||||||
* TCP_MAXWIN << tp->rcv_scale.
|
* TCP_MAXWIN << tp->rcv_scale.
|
||||||
*/
|
*/
|
||||||
long adv = min(win, (long)TCP_MAXWIN << tp->rcv_scale) -
|
long adv = min(win, TCP_MAXWIN << tp->rcv_scale) -
|
||||||
(tp->rcv_adv - tp->rcv_nxt);
|
(tp->rcv_adv - tp->rcv_nxt);
|
||||||
|
|
||||||
if (adv >= (long) (2 * tp->t_maxseg))
|
if (adv >= (long)(2 * tp->t_maxseg))
|
||||||
goto send;
|
goto send;
|
||||||
if (2 * adv >= (long) so->so_rcv.sb_datalen)
|
if (2 * adv >= (long)so->so_rcv.sb_datalen)
|
||||||
goto send;
|
goto send;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -359,7 +357,7 @@ send:
|
|||||||
*/
|
*/
|
||||||
/* if (len <= MHLEN - hdrlen - max_linkhdr) { */
|
/* if (len <= MHLEN - hdrlen - max_linkhdr) { */
|
||||||
|
|
||||||
sbcopy(&so->so_snd, off, (int) len, mtod(m, caddr_t) + hdrlen);
|
sbcopy(&so->so_snd, off, len, mtod(m, caddr_t) + hdrlen);
|
||||||
m->m_len += len;
|
m->m_len += len;
|
||||||
|
|
||||||
/* } else {
|
/* } else {
|
||||||
@ -435,12 +433,12 @@ send:
|
|||||||
* Calculate receive window. Don't shrink window,
|
* Calculate receive window. Don't shrink window,
|
||||||
* but avoid silly window syndrome.
|
* but avoid silly window syndrome.
|
||||||
*/
|
*/
|
||||||
if (win < (long)(so->so_rcv.sb_datalen / 4) && win < (long)tp->t_maxseg)
|
if (win < (so->so_rcv.sb_datalen / 4) && win < tp->t_maxseg)
|
||||||
win = 0;
|
win = 0;
|
||||||
if (win > (long)TCP_MAXWIN << tp->rcv_scale)
|
if (win > (u_long) (TCP_MAXWIN << tp->rcv_scale))
|
||||||
win = (long)TCP_MAXWIN << tp->rcv_scale;
|
win = (u_long) (TCP_MAXWIN << tp->rcv_scale);
|
||||||
if (win < (long)(tp->rcv_adv - tp->rcv_nxt))
|
if (win < (tp->rcv_adv - tp->rcv_nxt))
|
||||||
win = (long)(tp->rcv_adv - tp->rcv_nxt);
|
win = (tp->rcv_adv - tp->rcv_nxt);
|
||||||
ti->ti_win = htons((u_int16_t) (win>>tp->rcv_scale));
|
ti->ti_win = htons((u_int16_t) (win>>tp->rcv_scale));
|
||||||
|
|
||||||
if (SEQ_GT(tp->snd_up, tp->snd_una)) {
|
if (SEQ_GT(tp->snd_up, tp->snd_una)) {
|
||||||
@ -530,7 +528,7 @@ send:
|
|||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
((struct ip *)ti)->ip_len = m->m_len;
|
((struct ip *)ti)->ip_len = (u_int16_t) m->m_len;
|
||||||
|
|
||||||
((struct ip *)ti)->ip_ttl = ip_defttl;
|
((struct ip *)ti)->ip_ttl = ip_defttl;
|
||||||
((struct ip *)ti)->ip_tos = so->so_iptos;
|
((struct ip *)ti)->ip_tos = so->so_iptos;
|
||||||
@ -581,9 +579,7 @@ out:
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void tcp_setpersist(register struct tcpcb *tp)
|
||||||
tcp_setpersist(tp)
|
|
||||||
register struct tcpcb *tp;
|
|
||||||
{
|
{
|
||||||
int t = ((tp->t_srtt >> 2) + tp->t_rttvar) >> 1;
|
int t = ((tp->t_srtt >> 2) + tp->t_rttvar) >> 1;
|
||||||
|
|
||||||
|
92
BasiliskII/src/slirp/tcp_subr.c
Executable file → Normal file
92
BasiliskII/src/slirp/tcp_subr.c
Executable file → Normal file
@ -46,14 +46,13 @@
|
|||||||
int tcp_mssdflt = TCP_MSS;
|
int tcp_mssdflt = TCP_MSS;
|
||||||
int tcp_rttdflt = TCPTV_SRTTDFLT / PR_SLOWHZ;
|
int tcp_rttdflt = TCPTV_SRTTDFLT / PR_SLOWHZ;
|
||||||
int tcp_do_rfc1323 = 0; /* Don't do rfc1323 performance enhancements */
|
int tcp_do_rfc1323 = 0; /* Don't do rfc1323 performance enhancements */
|
||||||
int tcp_rcvspace; /* You may want to change this */
|
size_t tcp_rcvspace; /* You may want to change this */
|
||||||
int tcp_sndspace; /* Keep small if you have an error prone link */
|
size_t tcp_sndspace; /* Keep small if you have an error prone link */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tcp initialization
|
* Tcp initialization
|
||||||
*/
|
*/
|
||||||
void
|
void tcp_init()
|
||||||
tcp_init()
|
|
||||||
{
|
{
|
||||||
tcp_iss = 1; /* wrong */
|
tcp_iss = 1; /* wrong */
|
||||||
tcb.so_next = tcb.so_prev = &tcb;
|
tcb.so_next = tcb.so_prev = &tcb;
|
||||||
@ -74,14 +73,12 @@ tcp_init()
|
|||||||
* necessary when the connection is used.
|
* necessary when the connection is used.
|
||||||
*/
|
*/
|
||||||
/* struct tcpiphdr * */
|
/* struct tcpiphdr * */
|
||||||
void
|
void tcp_template(struct tcpcb *tp)
|
||||||
tcp_template(tp)
|
|
||||||
struct tcpcb *tp;
|
|
||||||
{
|
{
|
||||||
struct socket *so = tp->t_socket;
|
struct socket *so = tp->t_socket;
|
||||||
register struct tcpiphdr *n = &tp->t_template;
|
register struct tcpiphdr *n = &tp->t_template;
|
||||||
|
|
||||||
n->ti_mbuf = NULL;
|
n->ti_next = n->ti_prev = 0;
|
||||||
n->ti_x1 = 0;
|
n->ti_x1 = 0;
|
||||||
n->ti_pr = IPPROTO_TCP;
|
n->ti_pr = IPPROTO_TCP;
|
||||||
n->ti_len = htons(sizeof (struct tcpiphdr) - sizeof (struct ip));
|
n->ti_len = htons(sizeof (struct tcpiphdr) - sizeof (struct ip));
|
||||||
@ -113,13 +110,8 @@ tcp_template(tp)
|
|||||||
* In any case the ack and sequence number of the transmitted
|
* In any case the ack and sequence number of the transmitted
|
||||||
* segment are as specified by the parameters.
|
* segment are as specified by the parameters.
|
||||||
*/
|
*/
|
||||||
void
|
void tcp_respond(struct tcpcb *tp, register struct tcpiphdr *ti,
|
||||||
tcp_respond(tp, ti, m, ack, seq, flags)
|
register struct mbuf *m, tcp_seq ack, tcp_seq seq, int flags)
|
||||||
struct tcpcb *tp;
|
|
||||||
register struct tcpiphdr *ti;
|
|
||||||
register struct mbuf *m;
|
|
||||||
tcp_seq ack, seq;
|
|
||||||
int flags;
|
|
||||||
{
|
{
|
||||||
register int tlen;
|
register int tlen;
|
||||||
int win = 0;
|
int win = 0;
|
||||||
@ -164,7 +156,7 @@ tcp_respond(tp, ti, m, ack, seq, flags)
|
|||||||
tlen += sizeof (struct tcpiphdr);
|
tlen += sizeof (struct tcpiphdr);
|
||||||
m->m_len = tlen;
|
m->m_len = tlen;
|
||||||
|
|
||||||
ti->ti_mbuf = 0;
|
ti->ti_next = ti->ti_prev = 0;
|
||||||
ti->ti_x1 = 0;
|
ti->ti_x1 = 0;
|
||||||
ti->ti_seq = htonl(seq);
|
ti->ti_seq = htonl(seq);
|
||||||
ti->ti_ack = htonl(ack);
|
ti->ti_ack = htonl(ack);
|
||||||
@ -193,9 +185,7 @@ tcp_respond(tp, ti, m, ack, seq, flags)
|
|||||||
* empty reassembly queue and hooking it to the argument
|
* empty reassembly queue and hooking it to the argument
|
||||||
* protocol control block.
|
* protocol control block.
|
||||||
*/
|
*/
|
||||||
struct tcpcb *
|
struct tcpcb *tcp_newtcpcb(struct socket *so)
|
||||||
tcp_newtcpcb(so)
|
|
||||||
struct socket *so;
|
|
||||||
{
|
{
|
||||||
register struct tcpcb *tp;
|
register struct tcpcb *tp;
|
||||||
|
|
||||||
@ -204,7 +194,7 @@ tcp_newtcpcb(so)
|
|||||||
return ((struct tcpcb *)0);
|
return ((struct tcpcb *)0);
|
||||||
|
|
||||||
memset((char *) tp, 0, sizeof(struct tcpcb));
|
memset((char *) tp, 0, sizeof(struct tcpcb));
|
||||||
tp->seg_next = tp->seg_prev = (struct tcpiphdr*)tp;
|
tp->seg_next = tp->seg_prev = (tcpiphdrp_32)tp;
|
||||||
tp->t_maxseg = tcp_mssdflt;
|
tp->t_maxseg = tcp_mssdflt;
|
||||||
|
|
||||||
tp->t_flags = tcp_do_rfc1323 ? (TF_REQ_SCALE|TF_REQ_TSTMP) : 0;
|
tp->t_flags = tcp_do_rfc1323 ? (TF_REQ_SCALE|TF_REQ_TSTMP) : 0;
|
||||||
@ -268,9 +258,7 @@ struct tcpcb *tcp_drop(struct tcpcb *tp, int err)
|
|||||||
* discard internet protocol block
|
* discard internet protocol block
|
||||||
* wake up any sleepers
|
* wake up any sleepers
|
||||||
*/
|
*/
|
||||||
struct tcpcb *
|
struct tcpcb *tcp_close(register struct tcpcb *tp)
|
||||||
tcp_close(tp)
|
|
||||||
register struct tcpcb *tp;
|
|
||||||
{
|
{
|
||||||
register struct tcpiphdr *t;
|
register struct tcpiphdr *t;
|
||||||
struct socket *so = tp->t_socket;
|
struct socket *so = tp->t_socket;
|
||||||
@ -280,11 +268,11 @@ tcp_close(tp)
|
|||||||
DEBUG_ARG("tp = %lx", (long )tp);
|
DEBUG_ARG("tp = %lx", (long )tp);
|
||||||
|
|
||||||
/* free the reassembly queue, if any */
|
/* free the reassembly queue, if any */
|
||||||
t = tcpfrag_list_first(tp);
|
t = (struct tcpiphdr *) tp->seg_next;
|
||||||
while (!tcpfrag_list_end(t, tp)) {
|
while (t != (struct tcpiphdr *)tp) {
|
||||||
t = tcpiphdr_next(t);
|
t = (struct tcpiphdr *)t->ti_next;
|
||||||
m = tcpiphdr_prev(t)->ti_mbuf;
|
m = (struct mbuf *) REASS_MBUF((struct tcpiphdr *)t->ti_prev);
|
||||||
remque(tcpiphdr2qlink(tcpiphdr_prev(t)));
|
remque_32((struct tcpiphdr *) t->ti_prev);
|
||||||
m_freem(m);
|
m_freem(m);
|
||||||
}
|
}
|
||||||
/* It's static */
|
/* It's static */
|
||||||
@ -306,8 +294,7 @@ tcp_close(tp)
|
|||||||
return ((struct tcpcb *)0);
|
return ((struct tcpcb *)0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void tcp_drain()
|
||||||
tcp_drain()
|
|
||||||
{
|
{
|
||||||
/* XXX */
|
/* XXX */
|
||||||
}
|
}
|
||||||
@ -319,10 +306,7 @@ tcp_drain()
|
|||||||
|
|
||||||
#ifdef notdef
|
#ifdef notdef
|
||||||
|
|
||||||
void
|
void tcp_quench(int i, int errno)
|
||||||
tcp_quench(i, errno)
|
|
||||||
|
|
||||||
int errno;
|
|
||||||
{
|
{
|
||||||
struct tcpcb *tp = intotcpcb(inp);
|
struct tcpcb *tp = intotcpcb(inp);
|
||||||
|
|
||||||
@ -346,9 +330,7 @@ tcp_quench(i, errno)
|
|||||||
* for peer to send FIN or not respond to keep-alives, etc.
|
* for peer to send FIN or not respond to keep-alives, etc.
|
||||||
* We can let the user exit from the close as soon as the FIN is acked.
|
* We can let the user exit from the close as soon as the FIN is acked.
|
||||||
*/
|
*/
|
||||||
void
|
void tcp_sockclosed(struct tcpcb *tp)
|
||||||
tcp_sockclosed(tp)
|
|
||||||
struct tcpcb *tp;
|
|
||||||
{
|
{
|
||||||
|
|
||||||
DEBUG_CALL("tcp_sockclosed");
|
DEBUG_CALL("tcp_sockclosed");
|
||||||
@ -389,8 +371,7 @@ tcp_sockclosed(tp)
|
|||||||
* nonblocking. Connect returns after the SYN is sent, and does
|
* nonblocking. Connect returns after the SYN is sent, and does
|
||||||
* not wait for ACK+SYN.
|
* not wait for ACK+SYN.
|
||||||
*/
|
*/
|
||||||
int tcp_fconnect(so)
|
int tcp_fconnect(struct socket *so)
|
||||||
struct socket *so;
|
|
||||||
{
|
{
|
||||||
int ret=0;
|
int ret=0;
|
||||||
|
|
||||||
@ -423,10 +404,12 @@ int tcp_fconnect(so)
|
|||||||
} else
|
} else
|
||||||
addr.sin_addr = so->so_faddr;
|
addr.sin_addr = so->so_faddr;
|
||||||
addr.sin_port = so->so_fport;
|
addr.sin_port = so->so_fport;
|
||||||
|
|
||||||
|
char addrstr[INET_ADDRSTRLEN];
|
||||||
DEBUG_MISC((dfd, " connect()ing, addr.sin_port=%d, "
|
DEBUG_MISC((dfd, " connect()ing, addr.sin_port=%d, "
|
||||||
"addr.sin_addr.s_addr=%.16s\n",
|
"addr.sin_addr.s_addr=%.16s\n",
|
||||||
ntohs(addr.sin_port), inet_ntoa(addr.sin_addr)));
|
ntohs(addr.sin_port), inet_ntop(AF_INET, &addr.sin_addr,
|
||||||
|
addrstr, sizeof(addrstr))));
|
||||||
/* We don't care what port we get */
|
/* We don't care what port we get */
|
||||||
ret = connect(s,(struct sockaddr *)&addr,sizeof (addr));
|
ret = connect(s,(struct sockaddr *)&addr,sizeof (addr));
|
||||||
|
|
||||||
@ -452,9 +435,7 @@ int tcp_fconnect(so)
|
|||||||
* the time it gets to accept(), so... We simply accept
|
* the time it gets to accept(), so... We simply accept
|
||||||
* here and SYN the local-host.
|
* here and SYN the local-host.
|
||||||
*/
|
*/
|
||||||
void
|
void tcp_connect(struct socket *inso)
|
||||||
tcp_connect(inso)
|
|
||||||
struct socket *inso;
|
|
||||||
{
|
{
|
||||||
struct socket *so;
|
struct socket *so;
|
||||||
struct sockaddr_in addr;
|
struct sockaddr_in addr;
|
||||||
@ -486,7 +467,7 @@ tcp_connect(inso)
|
|||||||
so->so_lport = inso->so_lport;
|
so->so_lport = inso->so_lport;
|
||||||
}
|
}
|
||||||
|
|
||||||
(void) tcp_mss(sototcpcb(so), 0);
|
tcp_mss(sototcpcb(so), 0);
|
||||||
|
|
||||||
if ((s = accept(inso->s,(struct sockaddr *)&addr,&addrlen)) < 0) {
|
if ((s = accept(inso->s,(struct sockaddr *)&addr,&addrlen)) < 0) {
|
||||||
tcp_close(sototcpcb(so)); /* This will sofree() as well */
|
tcp_close(sototcpcb(so)); /* This will sofree() as well */
|
||||||
@ -539,9 +520,7 @@ tcp_connect(inso)
|
|||||||
/*
|
/*
|
||||||
* Attach a TCPCB to a socket.
|
* Attach a TCPCB to a socket.
|
||||||
*/
|
*/
|
||||||
int
|
int tcp_attach(struct socket *so)
|
||||||
tcp_attach(so)
|
|
||||||
struct socket *so;
|
|
||||||
{
|
{
|
||||||
if ((so->so_tcpcb = tcp_newtcpcb(so)) == NULL)
|
if ((so->so_tcpcb = tcp_newtcpcb(so)) == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
@ -575,9 +554,7 @@ struct emu_t *tcpemu = 0;
|
|||||||
/*
|
/*
|
||||||
* Return TOS according to the above table
|
* Return TOS according to the above table
|
||||||
*/
|
*/
|
||||||
u_int8_t
|
u_int8_t tcp_tos(struct socket *so)
|
||||||
tcp_tos(so)
|
|
||||||
struct socket *so;
|
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
struct emu_t *emup;
|
struct emu_t *emup;
|
||||||
@ -629,10 +606,7 @@ int do_echo = -1;
|
|||||||
*
|
*
|
||||||
* NOTE: if you return 0 you MUST m_free() the mbuf!
|
* NOTE: if you return 0 you MUST m_free() the mbuf!
|
||||||
*/
|
*/
|
||||||
int
|
int tcp_emu(struct socket *so, struct mbuf *m)
|
||||||
tcp_emu(so, m)
|
|
||||||
struct socket *so;
|
|
||||||
struct mbuf *m;
|
|
||||||
{
|
{
|
||||||
u_int n1, n2, n3, n4, n5, n6;
|
u_int n1, n2, n3, n4, n5, n6;
|
||||||
char buff[256];
|
char buff[256];
|
||||||
@ -833,7 +807,7 @@ tcp_emu(so, m)
|
|||||||
ns->so_laddr=so->so_laddr;
|
ns->so_laddr=so->so_laddr;
|
||||||
ns->so_lport=htons(port);
|
ns->so_lport=htons(port);
|
||||||
|
|
||||||
(void) tcp_mss(sototcpcb(ns), 0);
|
tcp_mss(sototcpcb(ns), 0);
|
||||||
|
|
||||||
ns->so_faddr=so->so_faddr;
|
ns->so_faddr=so->so_faddr;
|
||||||
ns->so_fport=htons(IPPORT_RESERVED-1); /* Use a fake port. */
|
ns->so_fport=htons(IPPORT_RESERVED-1); /* Use a fake port. */
|
||||||
@ -1060,7 +1034,7 @@ do_prompt:
|
|||||||
* of the connection as a NUL-terminated decimal ASCII string.
|
* of the connection as a NUL-terminated decimal ASCII string.
|
||||||
*/
|
*/
|
||||||
so->so_emu = 0;
|
so->so_emu = 0;
|
||||||
for (lport = 0, i = 0; i < m->m_len-1; ++i) {
|
for (lport = 0, i = 0; i < (int) (m->m_len-1); ++i) {
|
||||||
if (m->m_data[i] < '0' || m->m_data[i] > '9')
|
if (m->m_data[i] < '0' || m->m_data[i] > '9')
|
||||||
return 1; /* invalid number */
|
return 1; /* invalid number */
|
||||||
lport *= 10;
|
lport *= 10;
|
||||||
@ -1245,9 +1219,7 @@ do_prompt:
|
|||||||
* Return 0 if this connections is to be closed, 1 otherwise,
|
* Return 0 if this connections is to be closed, 1 otherwise,
|
||||||
* return 2 if this is a command-line connection
|
* return 2 if this is a command-line connection
|
||||||
*/
|
*/
|
||||||
int
|
int tcp_ctl(struct socket *so)
|
||||||
tcp_ctl(so)
|
|
||||||
struct socket *so;
|
|
||||||
{
|
{
|
||||||
struct sbuf *sb = &so->so_snd;
|
struct sbuf *sb = &so->so_snd;
|
||||||
int command;
|
int command;
|
||||||
|
0
BasiliskII/src/slirp/tcp_timer.c
Executable file → Normal file
0
BasiliskII/src/slirp/tcp_timer.c
Executable file → Normal file
8
BasiliskII/src/slirp/tcp_timer.h
Executable file → Normal file
8
BasiliskII/src/slirp/tcp_timer.h
Executable file → Normal file
@ -130,9 +130,9 @@ extern int tcp_backoff[];
|
|||||||
|
|
||||||
struct tcpcb;
|
struct tcpcb;
|
||||||
|
|
||||||
void tcp_fasttimo _P((void));
|
void tcp_fasttimo(void);
|
||||||
void tcp_slowtimo _P((void));
|
void tcp_slowtimo(void);
|
||||||
void tcp_canceltimers _P((struct tcpcb *));
|
void tcp_canceltimers(struct tcpcb *);
|
||||||
struct tcpcb * tcp_timers _P((register struct tcpcb *, int));
|
struct tcpcb * tcp_timers(register struct tcpcb *, int);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
25
BasiliskII/src/slirp/tcp_var.h
Executable file → Normal file
25
BasiliskII/src/slirp/tcp_var.h
Executable file → Normal file
@ -36,12 +36,18 @@
|
|||||||
#include "tcpip.h"
|
#include "tcpip.h"
|
||||||
#include "tcp_timer.h"
|
#include "tcp_timer.h"
|
||||||
|
|
||||||
|
#if SIZEOF_CHAR_P == 4
|
||||||
|
typedef struct tcpiphdr *tcpiphdrp_32;
|
||||||
|
#else
|
||||||
|
typedef u_int32_t tcpiphdrp_32;
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tcp control block, one per tcp; fields:
|
* Tcp control block, one per tcp; fields:
|
||||||
*/
|
*/
|
||||||
struct tcpcb {
|
struct tcpcb {
|
||||||
struct tcpiphdr *seg_next; /* sequencing queue */
|
tcpiphdrp_32 seg_next; /* sequencing queue */
|
||||||
struct tcpiphdr *seg_prev;
|
tcpiphdrp_32 seg_prev;
|
||||||
short t_state; /* state of this connection */
|
short t_state; /* state of this connection */
|
||||||
short t_timer[TCPT_NTIMERS]; /* tcp timers */
|
short t_timer[TCPT_NTIMERS]; /* tcp timers */
|
||||||
short t_rxtshift; /* log(2) of rexmt exp. backoff */
|
short t_rxtshift; /* log(2) of rexmt exp. backoff */
|
||||||
@ -160,6 +166,21 @@ struct tcpcb {
|
|||||||
#define TCP_REXMTVAL(tp) \
|
#define TCP_REXMTVAL(tp) \
|
||||||
(((tp)->t_srtt >> TCP_RTT_SHIFT) + (tp)->t_rttvar)
|
(((tp)->t_srtt >> TCP_RTT_SHIFT) + (tp)->t_rttvar)
|
||||||
|
|
||||||
|
/* XXX
|
||||||
|
* We want to avoid doing m_pullup on incoming packets but that
|
||||||
|
* means avoiding dtom on the tcp reassembly code. That in turn means
|
||||||
|
* keeping an mbuf pointer in the reassembly queue (since we might
|
||||||
|
* have a cluster). As a quick hack, the source & destination
|
||||||
|
* port numbers (which are no longer needed once we've located the
|
||||||
|
* tcpcb) are overlayed with an mbuf pointer.
|
||||||
|
*/
|
||||||
|
#if SIZEOF_CHAR_P == 4
|
||||||
|
typedef struct mbuf *mbufp_32;
|
||||||
|
#else
|
||||||
|
typedef u_int32_t mbufp_32;
|
||||||
|
#endif
|
||||||
|
#define REASS_MBUF(ti) (*(mbufp_32 *)&((ti)->ti_t))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TCP statistics.
|
* TCP statistics.
|
||||||
* Many of these should be kept per connection,
|
* Many of these should be kept per connection,
|
||||||
|
11
BasiliskII/src/slirp/tcpip.h
Executable file → Normal file
11
BasiliskII/src/slirp/tcpip.h
Executable file → Normal file
@ -40,7 +40,8 @@ struct tcpiphdr {
|
|||||||
struct ipovly ti_i; /* overlaid ip structure */
|
struct ipovly ti_i; /* overlaid ip structure */
|
||||||
struct tcphdr ti_t; /* tcp header */
|
struct tcphdr ti_t; /* tcp header */
|
||||||
};
|
};
|
||||||
#define ti_mbuf ti_i.ih_mbuf.mptr
|
#define ti_next ti_i.ih_next
|
||||||
|
#define ti_prev ti_i.ih_prev
|
||||||
#define ti_x1 ti_i.ih_x1
|
#define ti_x1 ti_i.ih_x1
|
||||||
#define ti_pr ti_i.ih_pr
|
#define ti_pr ti_i.ih_pr
|
||||||
#define ti_len ti_i.ih_len
|
#define ti_len ti_i.ih_len
|
||||||
@ -57,14 +58,6 @@ struct tcpiphdr {
|
|||||||
#define ti_sum ti_t.th_sum
|
#define ti_sum ti_t.th_sum
|
||||||
#define ti_urp ti_t.th_urp
|
#define ti_urp ti_t.th_urp
|
||||||
|
|
||||||
#define tcpiphdr2qlink(T) ((struct qlink*)(((char*)(T)) - sizeof(struct qlink)))
|
|
||||||
#define qlink2tcpiphdr(Q) ((struct tcpiphdr*)(((char*)(Q)) + sizeof(struct qlink)))
|
|
||||||
#define tcpiphdr_next(T) qlink2tcpiphdr(tcpiphdr2qlink(T)->next)
|
|
||||||
#define tcpiphdr_prev(T) qlink2tcpiphdr(tcpiphdr2qlink(T)->prev)
|
|
||||||
#define tcpfrag_list_first(T) qlink2tcpiphdr((T)->seg_next)
|
|
||||||
#define tcpfrag_list_end(F, T) (tcpiphdr2qlink(F) == (struct qlink*)(T))
|
|
||||||
#define tcpfrag_list_empty(T) ((T)->seg_next == (struct tcpiphdr*)(T))
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Just a clean way to get to the first byte
|
* Just a clean way to get to the first byte
|
||||||
* of the packet
|
* of the packet
|
||||||
|
3
BasiliskII/src/slirp/tftp.c
Executable file → Normal file
3
BasiliskII/src/slirp/tftp.c
Executable file → Normal file
@ -127,7 +127,6 @@ static int tftp_send_error(struct tftp_session *spt,
|
|||||||
struct sockaddr_in saddr, daddr;
|
struct sockaddr_in saddr, daddr;
|
||||||
struct mbuf *m;
|
struct mbuf *m;
|
||||||
struct tftp_t *tp;
|
struct tftp_t *tp;
|
||||||
int nobytes;
|
|
||||||
|
|
||||||
m = m_get();
|
m = m_get();
|
||||||
|
|
||||||
@ -152,8 +151,6 @@ static int tftp_send_error(struct tftp_session *spt,
|
|||||||
daddr.sin_addr = spt->client_ip;
|
daddr.sin_addr = spt->client_ip;
|
||||||
daddr.sin_port = spt->client_port;
|
daddr.sin_port = spt->client_port;
|
||||||
|
|
||||||
nobytes = 2;
|
|
||||||
|
|
||||||
m->m_len = sizeof(struct tftp_t) - 514 + 3 + strlen(msg) -
|
m->m_len = sizeof(struct tftp_t) - 514 + 3 + strlen(msg) -
|
||||||
sizeof(struct ip) - sizeof(struct udphdr);
|
sizeof(struct ip) - sizeof(struct udphdr);
|
||||||
|
|
||||||
|
2
BasiliskII/src/slirp/tftp.h
Executable file → Normal file
2
BasiliskII/src/slirp/tftp.h
Executable file → Normal file
@ -34,7 +34,7 @@ struct tftp_t {
|
|||||||
} PACKED__;
|
} PACKED__;
|
||||||
|
|
||||||
#ifdef PRAGMA_PACK_SUPPORTED
|
#ifdef PRAGMA_PACK_SUPPORTED
|
||||||
#pragma pack(0)
|
#pragma pack(PACK_RESET)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void tftp_input(struct mbuf *m);
|
void tftp_input(struct mbuf *m);
|
||||||
|
17
BasiliskII/src/slirp/udp.c
Executable file → Normal file
17
BasiliskII/src/slirp/udp.c
Executable file → Normal file
@ -128,7 +128,8 @@ udp_input(m, iphlen)
|
|||||||
* Checksum extended UDP header and data.
|
* Checksum extended UDP header and data.
|
||||||
*/
|
*/
|
||||||
if (udpcksum && uh->uh_sum) {
|
if (udpcksum && uh->uh_sum) {
|
||||||
memset(&((struct ipovly *)ip)->ih_mbuf, 0, sizeof(struct mbuf_ptr));
|
((struct ipovly *)ip)->ih_next = 0;
|
||||||
|
((struct ipovly *)ip)->ih_prev = 0;
|
||||||
((struct ipovly *)ip)->ih_x1 = 0;
|
((struct ipovly *)ip)->ih_x1 = 0;
|
||||||
((struct ipovly *)ip)->ih_len = uh->uh_ulen;
|
((struct ipovly *)ip)->ih_len = uh->uh_ulen;
|
||||||
/* keep uh_sum for ICMP reply
|
/* keep uh_sum for ICMP reply
|
||||||
@ -271,10 +272,10 @@ int udp_output2(struct socket *so, struct mbuf *m,
|
|||||||
* and addresses and length put into network format.
|
* and addresses and length put into network format.
|
||||||
*/
|
*/
|
||||||
ui = mtod(m, struct udpiphdr *);
|
ui = mtod(m, struct udpiphdr *);
|
||||||
memset(&ui->ui_i.ih_mbuf, 0 , sizeof(struct mbuf_ptr));
|
ui->ui_next = ui->ui_prev = 0;
|
||||||
ui->ui_x1 = 0;
|
ui->ui_x1 = 0;
|
||||||
ui->ui_pr = IPPROTO_UDP;
|
ui->ui_pr = IPPROTO_UDP;
|
||||||
ui->ui_len = htons(m->m_len - sizeof(struct ip)); /* + sizeof (struct udphdr)); */
|
ui->ui_len = htons((u_short) (m->m_len - sizeof(struct ip))); /* + sizeof (struct udphdr)); */
|
||||||
/* XXXXX Check for from-one-location sockets, or from-any-location sockets */
|
/* XXXXX Check for from-one-location sockets, or from-any-location sockets */
|
||||||
ui->ui_src = saddr->sin_addr;
|
ui->ui_src = saddr->sin_addr;
|
||||||
ui->ui_dst = daddr->sin_addr;
|
ui->ui_dst = daddr->sin_addr;
|
||||||
@ -290,7 +291,7 @@ int udp_output2(struct socket *so, struct mbuf *m,
|
|||||||
if ((ui->ui_sum = cksum(m, /* sizeof (struct udpiphdr) + */ m->m_len)) == 0)
|
if ((ui->ui_sum = cksum(m, /* sizeof (struct udpiphdr) + */ m->m_len)) == 0)
|
||||||
ui->ui_sum = 0xffff;
|
ui->ui_sum = 0xffff;
|
||||||
}
|
}
|
||||||
((struct ip *)ui)->ip_len = m->m_len;
|
((struct ip *)ui)->ip_len = (u_int16_t) m->m_len;
|
||||||
|
|
||||||
((struct ip *)ui)->ip_ttl = ip_defttl;
|
((struct ip *)ui)->ip_ttl = ip_defttl;
|
||||||
((struct ip *)ui)->ip_tos = iptos;
|
((struct ip *)ui)->ip_tos = iptos;
|
||||||
@ -337,14 +338,10 @@ udp_attach(so)
|
|||||||
addr.sin_port = 0;
|
addr.sin_port = 0;
|
||||||
addr.sin_addr.s_addr = INADDR_ANY;
|
addr.sin_addr.s_addr = INADDR_ANY;
|
||||||
if(bind(so->s, (struct sockaddr *)&addr, sizeof(addr))<0) {
|
if(bind(so->s, (struct sockaddr *)&addr, sizeof(addr))<0) {
|
||||||
int lasterrno=errno;
|
int error = WSAGetLastError();
|
||||||
closesocket(so->s);
|
closesocket(so->s);
|
||||||
so->s=-1;
|
so->s=-1;
|
||||||
#ifdef _WIN32
|
WSASetLastError(error);
|
||||||
WSASetLastError(lasterrno);
|
|
||||||
#else
|
|
||||||
errno=lasterrno;
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
/* success, insert in queue */
|
/* success, insert in queue */
|
||||||
so->so_expire = curtime + SO_EXPIRE;
|
so->so_expire = curtime + SO_EXPIRE;
|
||||||
|
21
BasiliskII/src/slirp/udp.h
Executable file → Normal file
21
BasiliskII/src/slirp/udp.h
Executable file → Normal file
@ -54,7 +54,7 @@ struct udphdr {
|
|||||||
} PACKED__;
|
} PACKED__;
|
||||||
|
|
||||||
#ifdef PRAGMA_PACK_SUPPORTED
|
#ifdef PRAGMA_PACK_SUPPORTED
|
||||||
#pragma pack(0)
|
#pragma pack(PACK_RESET)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -64,7 +64,8 @@ struct udpiphdr {
|
|||||||
struct ipovly ui_i; /* overlaid ip structure */
|
struct ipovly ui_i; /* overlaid ip structure */
|
||||||
struct udphdr ui_u; /* udp header */
|
struct udphdr ui_u; /* udp header */
|
||||||
};
|
};
|
||||||
#define ui_mbuf ui_i.ih_mbuf.mptr
|
#define ui_next ui_i.ih_next
|
||||||
|
#define ui_prev ui_i.ih_prev
|
||||||
#define ui_x1 ui_i.ih_x1
|
#define ui_x1 ui_i.ih_x1
|
||||||
#define ui_pr ui_i.ih_pr
|
#define ui_pr ui_i.ih_pr
|
||||||
#define ui_len ui_i.ih_len
|
#define ui_len ui_i.ih_len
|
||||||
@ -99,14 +100,14 @@ extern struct udpstat udpstat;
|
|||||||
extern struct socket udb;
|
extern struct socket udb;
|
||||||
struct mbuf;
|
struct mbuf;
|
||||||
|
|
||||||
void udp_init _P((void));
|
void udp_init(void);
|
||||||
void udp_input _P((register struct mbuf *, int));
|
void udp_input(register struct mbuf *, int);
|
||||||
int udp_output _P((struct socket *, struct mbuf *, struct sockaddr_in *));
|
int udp_output(struct socket *, struct mbuf *, struct sockaddr_in *);
|
||||||
int udp_attach _P((struct socket *));
|
int udp_attach(struct socket *);
|
||||||
void udp_detach _P((struct socket *));
|
void udp_detach(struct socket *);
|
||||||
u_int8_t udp_tos _P((struct socket *));
|
u_int8_t udp_tos(struct socket *);
|
||||||
void udp_emu _P((struct socket *, struct mbuf *));
|
void udp_emu(struct socket *, struct mbuf *);
|
||||||
struct socket * udp_listen _P((u_int, u_int32_t, u_int, int));
|
struct socket * udp_listen(u_int, u_int32_t, u_int, int);
|
||||||
int udp_output2(struct socket *so, struct mbuf *m,
|
int udp_output2(struct socket *so, struct mbuf *m,
|
||||||
struct sockaddr_in *saddr, struct sockaddr_in *daddr,
|
struct sockaddr_in *saddr, struct sockaddr_in *daddr,
|
||||||
int iptos);
|
int iptos);
|
||||||
|
@ -324,9 +324,13 @@ uint32 TimeToMacTime(time_t t)
|
|||||||
// This code is taken from glibc 2.2
|
// This code is taken from glibc 2.2
|
||||||
|
|
||||||
// Convert to number of seconds elapsed since 1-Jan-1904
|
// Convert to number of seconds elapsed since 1-Jan-1904
|
||||||
|
#ifdef WIN32
|
||||||
|
struct tm *local = localtime(&t);
|
||||||
|
#else
|
||||||
struct tm result;
|
struct tm result;
|
||||||
localtime_r(&t, &result);
|
localtime_r(&t, &result);
|
||||||
struct tm *local = &result;
|
struct tm *local = &result;
|
||||||
|
#endif
|
||||||
const int TM_EPOCH_YEAR = 1900;
|
const int TM_EPOCH_YEAR = 1900;
|
||||||
const int MAC_EPOCH_YEAR = 1904;
|
const int MAC_EPOCH_YEAR = 1904;
|
||||||
int a4 = ((local->tm_year + TM_EPOCH_YEAR) >> 2) - !(local->tm_year & 3);
|
int a4 = ((local->tm_year + TM_EPOCH_YEAR) >> 2) - !(local->tm_year & 3);
|
||||||
|
Loading…
Reference in New Issue
Block a user