diff options
-rw-r--r-- | src/ip_icmp.c | 3 | ||||
-rw-r--r-- | src/socket.c | 5 | ||||
-rw-r--r-- | src/socket.h | 5 | ||||
-rw-r--r-- | src/state.c | 2 | ||||
-rw-r--r-- | src/tcp_input.c | 2 | ||||
-rw-r--r-- | src/tcp_subr.c | 2 | ||||
-rw-r--r-- | src/udp.c | 4 | ||||
-rw-r--r-- | src/udp6.c | 2 |
8 files changed, 13 insertions, 12 deletions
diff --git a/src/ip_icmp.c b/src/ip_icmp.c index 4607721..4e47d51 100644 --- a/src/ip_icmp.c +++ b/src/ip_icmp.c @@ -207,7 +207,7 @@ void icmp_input(struct mbuf *m, int hlen) struct sockaddr_storage addr; int ttl; - so = socreate(slirp); + so = socreate(slirp, IPPROTO_ICMP); if (icmp_send(so, m, hlen) == 0) { /* We could send this as ICMP, good! */ return; @@ -231,7 +231,6 @@ void icmp_input(struct mbuf *m, int hlen) so->so_laddr = ip->ip_src; so->so_lport = htons(9); so->so_iptos = ip->ip_tos; - so->so_type = IPPROTO_ICMP; so->so_state = SS_ISFCONNECTED; /* Send the packet */ diff --git a/src/socket.c b/src/socket.c index 2c1b789..9e1e47e 100644 --- a/src/socket.c +++ b/src/socket.c @@ -43,11 +43,12 @@ struct socket *solookup(struct socket **last, struct socket *head, * It is the responsibility of the caller to * insque() it into the correct linked-list */ -struct socket *socreate(Slirp *slirp) +struct socket *socreate(Slirp *slirp, int type) { struct socket *so = g_new(struct socket, 1); memset(so, 0, sizeof(struct socket)); + so->so_type = type; so->so_state = SS_NOFDREF; so->s = -1; so->slirp = slirp; @@ -792,7 +793,7 @@ struct socket *tcpx_listen(Slirp *slirp, */ g_assert(!((flags & SS_HOSTFWD) && (flags & SS_FACCEPTONCE))); - so = socreate(slirp); + so = socreate(slirp, IPPROTO_TCP); /* Don't tcp_attach... we don't need so_snd nor so_rcv */ so->so_tcpcb = tcp_newtcpcb(so); diff --git a/src/socket.h b/src/socket.h index a73175d..acafff0 100644 --- a/src/socket.h +++ b/src/socket.h @@ -64,7 +64,8 @@ struct socket { uint8_t so_iptos; /* Type of service */ uint8_t so_emu; /* Is the socket emulated? */ - uint8_t so_type; /* Type of socket, UDP or TCP */ + uint8_t so_type; /* Protocol of the socket. May be 0 if loading old + * states. */ int32_t so_state; /* internal state flags SS_*, below */ struct tcpcb *so_tcpcb; /* pointer to TCP protocol control block */ @@ -157,7 +158,7 @@ static inline void sockaddr_copy(struct sockaddr *dst, socklen_t dstlen, const s struct socket *solookup(struct socket **, struct socket *, struct sockaddr_storage *, struct sockaddr_storage *); -struct socket *socreate(Slirp *); +struct socket *socreate(Slirp *, int); void sofree(struct socket *); int soread(struct socket *); int sorecvoob(struct socket *); diff --git a/src/state.c b/src/state.c index 22af77b..8708547 100644 --- a/src/state.c +++ b/src/state.c @@ -344,7 +344,7 @@ int slirp_state_load(Slirp *slirp, int version_id, SlirpReadCb read_cb, while (slirp_istream_read_u8(&f)) { int ret; - struct socket *so = socreate(slirp); + struct socket *so = socreate(slirp, -1); ret = slirp_vmstate_load_state(&f, &vmstate_slirp_socket, so, version_id); diff --git a/src/tcp_input.c b/src/tcp_input.c index 45706fe..1d72479 100644 --- a/src/tcp_input.c +++ b/src/tcp_input.c @@ -423,7 +423,7 @@ findso: if ((tiflags & (TH_SYN | TH_FIN | TH_RST | TH_URG | TH_ACK)) != TH_SYN) goto dropwithreset; - so = socreate(slirp); + so = socreate(slirp, IPPROTO_TCP); tcp_attach(so); sbreserve(&so->so_snd, TCP_SNDSPACE); diff --git a/src/tcp_subr.c b/src/tcp_subr.c index 7c63f49..636c447 100644 --- a/src/tcp_subr.c +++ b/src/tcp_subr.c @@ -521,7 +521,7 @@ void tcp_connect(struct socket *inso) /* FACCEPTONCE already have a tcpcb */ so = inso; } else { - so = socreate(slirp); + so = socreate(slirp, IPPROTO_TCP); tcp_attach(so); so->lhost = inso->lhost; so->so_ffamily = inso->so_ffamily; @@ -177,7 +177,7 @@ void udp_input(register struct mbuf *m, int iphlen) * If there's no socket for this packet, * create one */ - so = socreate(slirp); + so = socreate(slirp, IPPROTO_UDP); if (udp_attach(so, AF_INET) == -1) { DEBUG_MISC(" udp_attach errno = %d-%s", errno, strerror(errno)); sofree(so); @@ -371,7 +371,7 @@ struct socket *udpx_listen(Slirp *slirp, socklen_t addrlen; int save_errno; - so = socreate(slirp); + so = socreate(slirp, IPPROTO_UDP); so->s = slirp_socket(haddr->sa_family, SOCK_DGRAM, 0); if (so->s < 0) { save_errno = errno; @@ -95,7 +95,7 @@ void udp6_input(struct mbuf *m) if (so == NULL) { /* If there's no socket for this packet, create one. */ - so = socreate(slirp); + so = socreate(slirp, IPPROTO_UDP); if (udp_attach(so, AF_INET6) == -1) { DEBUG_MISC(" udp6_attach errno = %d-%s", errno, strerror(errno)); sofree(so); |