* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
struct socket *udp_last_so = &udb;
void
-udp_init()
+udp_init(void)
{
udb.so_next = udb.so_prev = &udb;
}
* ip->ip_len length data (IPDU)
*/
void
-udp_input(m, iphlen)
- register struct mbuf *m;
- int iphlen;
+udp_input(register struct mbuf *m, int iphlen)
{
register struct ip *ip;
register struct udphdr *uh;
* Checksum extended UDP header and data.
*/
if (UDPCKSUM && uh->uh_sum) {
- ((struct ipovly *)ip)->ih_next = 0;
- ((struct ipovly *)ip)->ih_prev = 0;
+ memset(&((struct ipovly *)ip)->ih_mbuf, 0, sizeof(struct mbuf_ptr));
((struct ipovly *)ip)->ih_x1 = 0;
((struct ipovly *)ip)->ih_len = uh->uh_ulen;
/* keep uh_sum for ICMP reply
goto bad;
}
+ if (slirp_restrict)
+ goto bad;
+
/*
* handle TFTP
*/
* and addresses and length put into network format.
*/
ui = mtod(m, struct udpiphdr *);
- ui->ui_next = ui->ui_prev = 0;
+ memset(&ui->ui_i.ih_mbuf, 0 , sizeof(struct mbuf_ptr));
ui->ui_x1 = 0;
ui->ui_pr = IPPROTO_UDP;
ui->ui_len = htons(m->m_len - sizeof(struct ip)); /* + sizeof (struct udphdr)); */
if ((so->so_faddr.s_addr & htonl(0x000000ff)) == htonl(0xff))
saddr.sin_addr.s_addr = alias_addr.s_addr;
else if (addr->sin_addr.s_addr == loopback_addr.s_addr ||
- ((so->so_faddr.s_addr & htonl(CTL_DNS)) == htonl(CTL_DNS)))
+ (ntohl(so->so_faddr.s_addr) & 0xff) != CTL_ALIAS)
saddr.sin_addr.s_addr = so->so_faddr.s_addr;
}
daddr.sin_addr = so->so_laddr;
}
int
-udp_attach(so)
- struct socket *so;
+udp_attach(struct socket *so)
{
struct sockaddr_in addr;
}
void
-udp_detach(so)
- struct socket *so;
+udp_detach(struct socket *so)
{
closesocket(so->s);
/* if (so->so_m) m_free(so->so_m); done by sofree */
udp_emu(struct socket *so, struct mbuf *m)
{
struct sockaddr_in addr;
- int addrlen = sizeof(addr);
+ socklen_t addrlen = sizeof(addr);
#ifdef EMULATE_TALK
CTL_MSG_OLD *omsg;
CTL_MSG *nmsg;
type = omsg->type;
OTOSIN(omsg, ctl_addr)->sin_port = addr.sin_port;
OTOSIN(omsg, ctl_addr)->sin_addr = our_addr;
- strncpy(omsg->l_name, getlogin(), NAME_SIZE_OLD);
+ pstrcpy(omsg->l_name, NAME_SIZE_OLD, getlogin());
} else { /* new talk */
omsg = (CTL_MSG_OLD *) buff;
nmsg = mtod(m, CTL_MSG *);
type = nmsg->type;
OTOSIN(nmsg, ctl_addr)->sin_port = addr.sin_port;
OTOSIN(nmsg, ctl_addr)->sin_addr = our_addr;
- strncpy(nmsg->l_name, getlogin(), NAME_SIZE_OLD);
+ pstrcpy(nmsg->l_name, NAME_SIZE_OLD, getlogin());
}
if (type == LOOK_UP)
}
struct socket *
-udp_listen(port, laddr, lport, flags)
- u_int port;
- u_int32_t laddr;
- u_int lport;
- int flags;
+udp_listen(u_int port, u_int32_t laddr, u_int lport, int flags)
{
struct sockaddr_in addr;
struct socket *so;
- int addrlen = sizeof(struct sockaddr_in), opt = 1;
+ socklen_t addrlen = sizeof(struct sockaddr_in), opt = 1;
if ((so = socreate()) == NULL) {
free(so);