Skip to content

Commit

Permalink
BasiliskII/src/slirp/* copied from jvernet/macemu
Browse files Browse the repository at this point in the history
  • Loading branch information
kanjitalk755 committed Dec 6, 2017
1 parent e42b6a5 commit a944344
Show file tree
Hide file tree
Showing 40 changed files with 1,229 additions and 1,132 deletions.
1 change: 1 addition & 0 deletions BasiliskII/src/slirp/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
qemu 0.9.0 (2007/02/05)
Plus 64 Bits Patchs
Empty file modified BasiliskII/src/slirp/bootp.c
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion BasiliskII/src/slirp/bootp.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ struct bootp_t {
} PACKED__;

#ifdef PRAGMA_PACK_SUPPORTED
#pragma pack(PACK_RESET)
#pragma pack(0)
#endif

void bootp_input(struct mbuf *m);
Empty file modified BasiliskII/src/slirp/cksum.c
100644 → 100755
Empty file.
Empty file modified BasiliskII/src/slirp/ctl.h
100644 → 100755
Empty file.
15 changes: 6 additions & 9 deletions BasiliskII/src/slirp/debug.c
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ int dostats = 0;
#endif
int slirp_debug = 0;

extern char *strerror _P((int));

/* Carry over one item from main.c so that the tty's restored.
* Only done when the tty being used is /dev/tty --RedWolf */
extern struct termios slirp_tty_settings;
Expand Down Expand Up @@ -292,7 +294,6 @@ mbufstats()
void
sockstats()
{
char addr[INET_ADDRSTRLEN];
char buff[256];
int n;
struct socket *so;
Expand All @@ -310,11 +311,9 @@ sockstats()
buff[17] = 0;
lprint("%s %3d %15s %5d ",
buff, so->s,
inet_ntop(AF_INET, &so->so_laddr, addr, sizeof(addr)),
ntohs(so->so_lport));
inet_ntoa(so->so_laddr), ntohs(so->so_lport));
lprint("%15s %5d %5d %5d\r\n",
inet_ntop(AF_INET, &so->so_faddr, addr, sizeof(addr)),
ntohs(so->so_fport),
inet_ntoa(so->so_faddr), ntohs(so->so_fport),
so->so_rcv.sb_cc, so->so_snd.sb_cc);
}

Expand All @@ -326,11 +325,9 @@ sockstats()
buff[17] = 0;
lprint("%s %3d %15s %5d ",
buff, so->s,
inet_ntop(AF_INET, &so->so_laddr, addr, sizeof(addr)),
ntohs(so->so_lport));
inet_ntoa(so->so_laddr), ntohs(so->so_lport));
lprint("%15s %5d %5d %5d\r\n",
inet_ntop(AF_INET, &so->so_faddr, addr, sizeof(addr)),
ntohs(so->so_fport),
inet_ntoa(so->so_faddr), ntohs(so->so_fport),
so->so_rcv.sb_cc, so->so_snd.sb_cc);
}
}
Expand Down
22 changes: 11 additions & 11 deletions BasiliskII/src/slirp/debug.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ extern int slirp_debug;

#endif

void debug_init(char *, int);
//void ttystats(struct ttys *);
void allttystats(void);
void ipstats(void);
void vjstats(void);
void tcpstats(void);
void udpstats(void);
void icmpstats(void);
void mbufstats(void);
void sockstats(void);
void slirp_exit(int);
void debug_init _P((char *, int));
//void ttystats _P((struct ttys *));
void allttystats _P((void));
void ipstats _P((void));
void vjstats _P((void));
void tcpstats _P((void));
void udpstats _P((void));
void icmpstats _P((void));
void mbufstats _P((void));
void sockstats _P((void));
void slirp_exit _P((int));

Empty file modified BasiliskII/src/slirp/icmp_var.h
100644 → 100755
Empty file.
9 changes: 4 additions & 5 deletions BasiliskII/src/slirp/if.c
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

#include <slirp.h>

size_t if_mtu, if_mru;
int if_mtu, if_mru;
int if_comp;
int if_maxlinkhdr;
int if_queued = 0; /* Number of packets queued so far */
int if_thresh = 10; /* Number of packets queued before we start sending
int if_queued = 0; /* Number of packets queued so far */
int if_thresh = 10; /* Number of packets queued before we start sending
* (to prevent allocing too many mbufs) */

struct mbuf if_fastq; /* fast queue (for interactive data) */
Expand Down Expand Up @@ -116,8 +116,7 @@ if_input(ttyp)
DEBUG_MISC((dfd, " read %d bytes\n", if_n));

if (if_n <= 0) {
int error = WSAGetLastError();
if (if_n == 0 || (error != WSAEINTR && error != EAGAIN)) {
if (if_n == 0 || (errno != EINTR && errno != EAGAIN)) {
if (ttyp->up)
link_up--;
tty_detached(ttyp, 0);
Expand Down
4 changes: 2 additions & 2 deletions BasiliskII/src/slirp/if.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

/* Needed for FreeBSD */
#undef if_mtu
extern size_t if_mtu;
extern size_t if_mru; /* MTU and MRU */
extern int if_mtu;
extern int if_mru; /* MTU and MRU */
extern int if_comp; /* Flags for compression */
extern int if_maxlinkhdr;
extern int if_queued; /* Number of packets queued so far */
Expand Down
70 changes: 27 additions & 43 deletions BasiliskII/src/slirp/ip.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ struct ip {
} PACKED__;

#ifdef PRAGMA_PACK_SUPPORTED
#pragma pack(PACK_RESET)
#pragma pack(0)
#endif

#define IP_MAXPACKET 65535 /* maximum packet size */
Expand Down Expand Up @@ -168,7 +168,7 @@ struct ip_timestamp {
} PACKED__;

#ifdef PRAGMA_PACK_SUPPORTED
#pragma pack(PACK_RESET)
#pragma pack(0)
#endif

/* flag bits for ipt_flg */
Expand All @@ -195,23 +195,19 @@ struct ip_timestamp {

#define IP_MSS 576 /* default maximum segment size */

#ifdef HAVE_SYS_TYPES32_H /* Overcome some Solaris 2.x junk */
#include <sys/types32.h>
#else
#if SIZEOF_CHAR_P == 4
typedef caddr_t caddr32_t;
struct mbuf_ptr {
struct mbuf *mptr;
uint32_t dummy;
};
#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;
struct mbuf_ptr {
struct mbuf *mptr;
};
#endif
struct qlink {
void *next, *prev;
};

/*
* Overlay for ip header used by other protocols (tcp, udp).
Expand All @@ -221,16 +217,16 @@ typedef caddr32_t ipasfragp_32;
#endif

struct ipovly {
caddr32_t ih_next, ih_prev; /* for protocol sequence q's */
struct mbuf_ptr ih_mbuf; /* backpointer to mbuf */
u_int8_t ih_x1; /* (unused) */
u_int8_t ih_pr; /* protocol */
u_int16_t ih_len; /* protocol length */
struct in_addr ih_src; /* source internet address */
struct in_addr ih_dst; /* destination internet address */
} PACKED__;
} __attribute__((packed));

#ifdef PRAGMA_PACK_SUPPORTED
#pragma pack(PACK_RESET)
#pragma pack(0)
#endif

/*
Expand All @@ -241,12 +237,13 @@ struct ipovly {
* size 28 bytes
*/
struct ipq {
ipqp_32 next,prev; /* to other reass headers */
struct qlink frag_link; /* to ip headers of fragments */
struct qlink ip_link; /* to other reass headers */

u_int8_t ipq_ttl; /* time for reass q to live */
u_int8_t ipq_p; /* protocol of this fragment */
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;
};

Expand All @@ -256,29 +253,16 @@ struct ipq {
* Note: ipf_next must be at same offset as ipq_next above
*/
struct ipasfrag {
#ifdef WORDS_BIGENDIAN
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 */
struct qlink ipf_link;
struct ip ipf_ip;
};

#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
* and passed to ip_output when ip options are in use.
Expand Down
26 changes: 13 additions & 13 deletions BasiliskII/src/slirp/ip_icmp.c
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ icmp_input(m, hlen)

DEBUG_CALL("icmp_input");
DEBUG_ARG("m = %lx", (long )m);
DEBUG_ARG("m_len = %zu", m->m_len);
DEBUG_ARG("m_len = %d", m->m_len);

icmpstat.icps_received++;

Expand Down Expand Up @@ -201,12 +201,12 @@ icmp_input(m, hlen)

#define ICMP_MAXDATALEN (IP_MSS-28)
void
icmp_error(
struct mbuf *msrc,
u_char type,
u_char code,
int minsize,
char *message)
icmp_error(msrc, type, code, minsize, message)
struct mbuf *msrc;
u_char type;
u_char code;
int minsize;
char *message;
{
unsigned hlen, shlen, s_ip_len;
register struct ip *ip;
Expand All @@ -215,17 +215,17 @@ icmp_error(

DEBUG_CALL("icmp_error");
DEBUG_ARG("msrc = %lx", (long )msrc);
DEBUG_ARG("msrc_len = %zu", msrc->m_len);
DEBUG_ARG("msrc_len = %d", msrc->m_len);

if(type!=ICMP_UNREACH && type!=ICMP_TIMXCEED) goto end_error;

/* check msrc */
if(!msrc) goto end_error;
ip = mtod(msrc, struct ip *);
#if DEBUG
{ char bufa[INET_ADDRSTRLEN], bufb[INET_ADDRSTRLEN];
inet_ntop(AF_INET, &ip->ip_src, bufa, sizeof(bufa));
inet_ntop(AF_INET, &ip->ip_dst, bufb, sizeof(bufb));
{ char bufa[20], bufb[20];
strcpy(bufa, inet_ntoa(ip->ip_src));
strcpy(bufb, inet_ntoa(ip->ip_dst));
DEBUG_MISC((dfd, " %.16s to %.16s\n", bufa, bufb));
}
#endif
Expand All @@ -244,7 +244,7 @@ icmp_error(

/* make a copy */
if(!(m=m_get())) goto end_error; /* get mbuf */
{ u_int new_m_size;
{ int new_m_size;
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);
}
Expand Down Expand Up @@ -299,7 +299,7 @@ icmp_error(

/* fill in ip */
ip->ip_hl = hlen >> 2;
ip->ip_len = (u_int16_t)m->m_len;
ip->ip_len = m->m_len;

ip->ip_tos=((ip->ip_tos & 0x1E) | 0xC0); /* high priority for errors */

Expand Down
8 changes: 4 additions & 4 deletions BasiliskII/src/slirp/ip_icmp.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ struct icmp {
} PACKED__;

#ifdef PRAGMA_PACK_SUPPORTED
#pragma pack(PACK_RESET)
#pragma pack(0)
#endif

/*
Expand Down Expand Up @@ -161,8 +161,8 @@ struct icmp {
(type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
(type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)

void icmp_input(struct mbuf *, int);
void icmp_error(struct mbuf *, u_char, u_char, int, char *);
void icmp_reflect(struct mbuf *);
void icmp_input _P((struct mbuf *, int));
void icmp_error _P((struct mbuf *, u_char, u_char, int, char *));
void icmp_reflect _P((struct mbuf *));

#endif
Loading

0 comments on commit a944344

Please sign in to comment.