Added support for controlling modules.
Fixed warnings. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5026 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
f5ef266db8
commit
eb5d50b665
@ -40,7 +40,6 @@
|
||||
/* Defines we need */
|
||||
#define NETWORK_INTERFACES "network/interfaces"
|
||||
#define NETWORK_PROTOCOLS "network/protocols"
|
||||
#define PPP_DEVICES "ppp/devices"
|
||||
|
||||
/* Variables used in other core modules */
|
||||
int ndevs = 0;
|
||||
@ -61,6 +60,10 @@ status_t std_ops(int32 op, ...);
|
||||
static int start_stack(void);
|
||||
static int stop_stack(void);
|
||||
|
||||
static int32 count_net_modules(void);
|
||||
static const char *get_net_module_name(int32 index);
|
||||
static status_t control_net_module(int32 index, uint32 op, void *data, size_t length);
|
||||
|
||||
static void add_protosw(struct protosw *[], int layer);
|
||||
static struct net_module *module_list = NULL;
|
||||
|
||||
@ -70,6 +73,10 @@ static int get_max_linkhdr(void);
|
||||
static void set_max_protohdr(int maxProtoHdr);
|
||||
static int get_max_protohdr(void);
|
||||
|
||||
#ifdef SHOW_DEBUG
|
||||
void walk_protocols(void);
|
||||
#endif
|
||||
|
||||
/* Wider scoped prototypes */
|
||||
int net_sysctl(int *name, uint namelen, void *oldp, size_t *oldlenp,
|
||||
void *newp, size_t newlen);
|
||||
@ -86,6 +93,11 @@ struct core_module_info core_info = {
|
||||
|
||||
start_stack,
|
||||
stop_stack,
|
||||
|
||||
count_net_modules,
|
||||
get_net_module_name,
|
||||
control_net_module,
|
||||
|
||||
add_domain,
|
||||
remove_domain,
|
||||
add_protocol,
|
||||
@ -204,6 +216,63 @@ struct core_module_info core_info = {
|
||||
socket_shutdown
|
||||
};
|
||||
|
||||
|
||||
static
|
||||
struct net_module*
|
||||
net_module_at(int32 index)
|
||||
{
|
||||
int32 currentIndex;
|
||||
struct net_module *current = module_list;
|
||||
|
||||
currentIndex = 0;
|
||||
for(; current && currentIndex != index; current = current->next)
|
||||
++currentIndex;
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
int32
|
||||
count_net_modules(void)
|
||||
{
|
||||
int32 count;
|
||||
struct net_module *current = module_list;
|
||||
|
||||
count = 0;
|
||||
for(; current; current = current->next)
|
||||
++count;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
const char*
|
||||
get_net_module_name(int32 index)
|
||||
{
|
||||
struct net_module *module = net_module_at(index);
|
||||
|
||||
if(!module)
|
||||
return NULL;
|
||||
|
||||
return module->name;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
status_t
|
||||
control_net_module(int32 index, uint32 op, void *data, size_t length)
|
||||
{
|
||||
struct net_module *module = net_module_at(index);
|
||||
|
||||
if(!module || !module->ptr->control)
|
||||
return B_ERROR;
|
||||
|
||||
return module->ptr->control(op, data, length);
|
||||
}
|
||||
|
||||
|
||||
static int32 if_thread(void *data)
|
||||
{
|
||||
struct ifnet *i = (struct ifnet *)data;
|
||||
@ -634,8 +703,8 @@ static void walk_domains(void)
|
||||
|
||||
void remove_domain(int fam)
|
||||
{
|
||||
struct domain *dmp = domains, *opr;
|
||||
|
||||
struct domain *dmp = domains, *opr = NULL;
|
||||
|
||||
for (; dmp; dmp = dmp->dom_next) {
|
||||
if (dmp->dom_family == fam)
|
||||
break;
|
||||
@ -643,7 +712,7 @@ void remove_domain(int fam)
|
||||
}
|
||||
if (!dmp || dmp->dom_protosw != NULL)
|
||||
return;
|
||||
|
||||
|
||||
acquire_sem_etc(dom_lock, 1, B_CAN_INTERRUPT, 0);
|
||||
/* we're ok to remove it! */
|
||||
if (opr)
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <kernel/OS.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef _KERNEL_MODE
|
||||
#include <KernelExport.h>
|
||||
@ -28,6 +29,9 @@ struct ifaddr **ifnet_addrs;
|
||||
static int if_index;
|
||||
static int if_indexlim;
|
||||
|
||||
void dump_sockaddr(void *ptr);
|
||||
void *protocol_address(struct ifnet *ifa, int family);
|
||||
|
||||
|
||||
static inline bool
|
||||
equal(struct sockaddr *addr1, struct sockaddr *addr2)
|
||||
@ -412,7 +416,7 @@ int ifconf(int cmd, caddr_t data)
|
||||
ifrp = ifc->ifc_req;
|
||||
ep = ifr.ifr_name + sizeof(ifr.ifr_name) - 2;
|
||||
|
||||
for (; space > sizeof(ifr) && ifp; ifp = ifp->if_next) {
|
||||
for (; space > (int) sizeof(ifr) && ifp; ifp = ifp->if_next) {
|
||||
strncpy(ifr.ifr_name, ifp->if_name, sizeof(ifr.ifr_name) - 2);
|
||||
for (cp = ifr.ifr_name;cp < ep && *cp; cp++)
|
||||
continue;
|
||||
@ -424,7 +428,7 @@ int ifconf(int cmd, caddr_t data)
|
||||
break;
|
||||
space -= sizeof(ifr), ifrp++;
|
||||
} else {
|
||||
for (; space > sizeof(ifr) && ifa; ifa = ifa->ifa_next) {
|
||||
for (; space > (int) sizeof(ifr) && ifa; ifa = ifa->ifa_next) {
|
||||
struct sockaddr *sa = ifa->ifa_addr;
|
||||
if (sa->sa_len <= sizeof(*sa)) {
|
||||
printf("sa->sa_len = %d compared to %ld, sa->sa_family = %d\n",
|
||||
@ -435,7 +439,7 @@ int ifconf(int cmd, caddr_t data)
|
||||
ifrp++;
|
||||
} else {
|
||||
space -= sa->sa_len - sizeof(*sa);
|
||||
if (space < sizeof(ifr))
|
||||
if (space < (int) sizeof(ifr))
|
||||
break;
|
||||
copyptr = memcpy((caddr_t)ifrp, (caddr_t)&ifr, sizeof(ifr.ifr_name));
|
||||
if (copyptr != NULL)
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <strings.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef _KERNEL_MODE
|
||||
#include <KernelExport.h>
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* in.c */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_var.h>
|
||||
#include <sys/socketvar.h>
|
||||
@ -211,7 +212,7 @@ int in_control(struct socket *so, int cmd, caddr_t data, struct ifnet *ifp)
|
||||
ia->ia_addr.sin_addr.s_addr == ifra->ifra_addr.sin_addr.s_addr)
|
||||
break;
|
||||
}
|
||||
if (cmd == SIOCDIFADDR && ia == NULL)
|
||||
if (cmd == (int) SIOCDIFADDR && ia == NULL)
|
||||
return EADDRNOTAVAIL;
|
||||
case SIOCSIFADDR:
|
||||
printf("SIOCSIFADDR\n");
|
||||
|
@ -106,7 +106,7 @@ struct mbuf *m_prepend(struct mbuf *m, int len)
|
||||
M_MOVE_PKTHDR(mnew, m);
|
||||
mnew->m_next = m;
|
||||
m = mnew;
|
||||
if (len < MHLEN)
|
||||
if (len < (int) MHLEN)
|
||||
MH_ALIGN(m, len);
|
||||
m->m_len = len;
|
||||
}
|
||||
@ -154,7 +154,7 @@ struct mbuf *m_devget(char *buf, int totlen, int off0,
|
||||
m->m_len = MLEN;
|
||||
}
|
||||
len = min(totlen, epkt - cp);
|
||||
if (len >= MINCLSIZE) {
|
||||
if (len >= (int) MINCLSIZE) {
|
||||
MCLGET(m);
|
||||
if (m->m_flags & M_EXT)
|
||||
m->m_len = len = min(len, MCLBYTES);
|
||||
@ -164,9 +164,9 @@ struct mbuf *m_devget(char *buf, int totlen, int off0,
|
||||
/*
|
||||
* Place initial small packet/header at end of mbuf.
|
||||
*/
|
||||
if (len < m->m_len) {
|
||||
if (len < (int) m->m_len) {
|
||||
if (top == NULL &&
|
||||
len + max_linkhdr <= m->m_len)
|
||||
len + max_linkhdr <= (int) m->m_len)
|
||||
m->m_data += max_linkhdr;
|
||||
m->m_len = len;
|
||||
} else
|
||||
@ -191,7 +191,7 @@ void m_reserve(struct mbuf *mp, int len)
|
||||
if (mp->m_len == 0) {
|
||||
/* empty buffer! */
|
||||
if (mp->m_flags & M_PKTHDR) {
|
||||
if (len < MHLEN) {
|
||||
if (len < (int) MHLEN) {
|
||||
mp->m_data += len;
|
||||
mp->m_len -= len;
|
||||
mp->m_pkthdr.len -= len;
|
||||
@ -199,7 +199,7 @@ void m_reserve(struct mbuf *mp, int len)
|
||||
}
|
||||
/* ?? */
|
||||
} else {
|
||||
if (len <= MLEN) {
|
||||
if (len <= (int) MLEN) {
|
||||
mp->m_data += len;
|
||||
mp->m_len -= len;
|
||||
return;
|
||||
@ -208,7 +208,7 @@ void m_reserve(struct mbuf *mp, int len)
|
||||
}
|
||||
|
||||
if (len > 0) {
|
||||
if (len <= mp->m_len) {
|
||||
if (len <= (int) mp->m_len) {
|
||||
mp->m_data += len;
|
||||
mp->m_len -= len;
|
||||
}
|
||||
@ -246,7 +246,7 @@ void m_adj(struct mbuf *mp, int req_len)
|
||||
if (len >= 0) {
|
||||
/* trim from the head */
|
||||
while (m!= NULL && len > 0) {
|
||||
if (m->m_len <= len) {
|
||||
if ((int) m->m_len <= len) {
|
||||
/* this whole mbuf isn't enough... */
|
||||
len -= m->m_len;
|
||||
m->m_len = 0;
|
||||
@ -271,7 +271,7 @@ void m_adj(struct mbuf *mp, int req_len)
|
||||
break;
|
||||
m = m->m_next;
|
||||
}
|
||||
if (m->m_len >= len) {
|
||||
if ((int) m->m_len >= len) {
|
||||
m->m_len -= len;
|
||||
if (mp->m_flags & M_PKTHDR)
|
||||
mp->m_pkthdr.len -= len;
|
||||
@ -288,7 +288,7 @@ void m_adj(struct mbuf *mp, int req_len)
|
||||
if (m->m_flags & M_PKTHDR)
|
||||
m->m_pkthdr.len = count;
|
||||
for (; m; m= m->m_next) {
|
||||
if (m->m_len >= count) {
|
||||
if ((int) m->m_len >= count) {
|
||||
m->m_len = count;
|
||||
break;
|
||||
}
|
||||
@ -316,7 +316,7 @@ void m_copydata(struct mbuf *m, int off, int len, caddr_t cp)
|
||||
printf("m_copydata: null mbuf in skip");
|
||||
return;
|
||||
}
|
||||
if (off < m->m_len)
|
||||
if (off < (int) m->m_len)
|
||||
break;
|
||||
off -= m->m_len;
|
||||
m = m->m_next;
|
||||
@ -326,7 +326,7 @@ void m_copydata(struct mbuf *m, int off, int len, caddr_t cp)
|
||||
printf("m_copydata: null mbuf");
|
||||
return;
|
||||
}
|
||||
count = min(m->m_len - off, len);
|
||||
count = min((int) m->m_len - off, len);
|
||||
memcpy(cp, (void*)(mtod(m, char *) + off), count);
|
||||
len -= count;
|
||||
cp += count;
|
||||
@ -353,7 +353,7 @@ struct mbuf *m_copym(struct mbuf *m, int off0, int len)
|
||||
printf("PANIC: m_copym: null mbuf\n");
|
||||
return NULL;
|
||||
}
|
||||
if (off < m->m_len)
|
||||
if (off < (int) m->m_len)
|
||||
break;
|
||||
off -= m->m_len;
|
||||
m = m->m_next;
|
||||
@ -380,7 +380,7 @@ struct mbuf *m_copym(struct mbuf *m, int off0, int len)
|
||||
n->m_pkthdr.len = len;
|
||||
copyhdr = 0;
|
||||
}
|
||||
n->m_len = min(len, m->m_len - off);
|
||||
n->m_len = min(len, (int) m->m_len - off);
|
||||
if (m->m_flags & M_EXT) {
|
||||
/*
|
||||
* we are unsure about the way m was allocated.
|
||||
@ -389,7 +389,7 @@ struct mbuf *m_copym(struct mbuf *m, int off0, int len)
|
||||
MCLGET(n);
|
||||
n->m_len = 0;
|
||||
n->m_len = M_TRAILINGSPACE(n);
|
||||
n->m_len = min(n->m_len, len);
|
||||
n->m_len = min((int) n->m_len, len);
|
||||
n->m_len = min(n->m_len, m->m_len - off);
|
||||
memcpy(mtod(n, caddr_t), (void *)(mtod(m, char *) + off),
|
||||
(unsigned)n->m_len);
|
||||
@ -399,7 +399,7 @@ struct mbuf *m_copym(struct mbuf *m, int off0, int len)
|
||||
if (len != M_COPYALL)
|
||||
len -= n->m_len;
|
||||
off += n->m_len;
|
||||
if (off == m->m_len) {
|
||||
if (off == (int) m->m_len) {
|
||||
m = m->m_next;
|
||||
off = 0;
|
||||
}
|
||||
@ -425,7 +425,7 @@ struct mbuf *m_pullup(struct mbuf *n, int len)
|
||||
int count;
|
||||
int space;
|
||||
|
||||
if (n->m_len <= len)
|
||||
if ((int) n->m_len <= len)
|
||||
return n;
|
||||
|
||||
/*
|
||||
@ -435,13 +435,13 @@ struct mbuf *m_pullup(struct mbuf *n, int len)
|
||||
*/
|
||||
if ((n->m_flags & M_EXT) == 0 &&
|
||||
n->m_data + len < &n->m_dat[MLEN] && n->m_next) {
|
||||
if (n->m_len >= len)
|
||||
if ((int) n->m_len >= len)
|
||||
return (n);
|
||||
m = n;
|
||||
n = n->m_next;
|
||||
len -= m->m_len;
|
||||
} else {
|
||||
if (len > MHLEN)
|
||||
if (len > (int) MHLEN)
|
||||
goto bad;
|
||||
MGET(m, n->m_type);
|
||||
if (m == NULL)
|
||||
@ -453,7 +453,7 @@ struct mbuf *m_pullup(struct mbuf *n, int len)
|
||||
}
|
||||
space = &m->m_dat[MLEN] - (m->m_data + m->m_len);
|
||||
do {
|
||||
count = min(min(max(len, max_protohdr), space), n->m_len);
|
||||
count = min(min(max(len, max_protohdr), space), (int) n->m_len);
|
||||
memcpy((void *)(mtod(m, caddr_t) + m->m_len), mtod(n, void *), (uint)count);
|
||||
len -= count;
|
||||
m->m_len += count;
|
||||
@ -499,13 +499,13 @@ void m_copyback(struct mbuf *m0, int off, int len, caddr_t cp)
|
||||
n = m_getclr(m->m_type);
|
||||
if (n == 0)
|
||||
goto out;
|
||||
n->m_len = min(MLEN, len + off);
|
||||
n->m_len = min((int) MLEN, len + off);
|
||||
m->m_next = n;
|
||||
}
|
||||
m = m->m_next;
|
||||
}
|
||||
while (len > 0) {
|
||||
mlen = min (m->m_len - off, len);
|
||||
mlen = min ((int) m->m_len - off, len);
|
||||
memcpy(off + mtod(m, caddr_t), cp, (unsigned)mlen);
|
||||
cp += mlen;
|
||||
len -= mlen;
|
||||
@ -518,7 +518,7 @@ void m_copyback(struct mbuf *m0, int off, int len, caddr_t cp)
|
||||
n = m_get(m->m_type);
|
||||
if (n == 0)
|
||||
break;
|
||||
n->m_len = min(MLEN, len);
|
||||
n->m_len = min((int) MLEN, len);
|
||||
m->m_next = n;
|
||||
}
|
||||
m = m->m_next;
|
||||
|
@ -58,9 +58,3 @@ void dump_buffer(char *buffer, int len)
|
||||
}
|
||||
printf("\n\n");
|
||||
}
|
||||
|
||||
int compare_sockaddr(struct sockaddr *a, struct sockaddr *b) // XXX this function is not used at all
|
||||
{
|
||||
return memcmp(a->sa_data, b->sa_data, a->sa_len);
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,13 @@
|
||||
|
||||
#define MAX_INITIAL 15;
|
||||
|
||||
|
||||
net_hash_index *nhash_next(net_hash_index *hi);
|
||||
net_hash_index *nhash_first(net_hash *nh);
|
||||
void nhash_this(net_hash_index *hi, const void **key, ssize_t *klen,
|
||||
void **val);
|
||||
|
||||
|
||||
net_hash *nhash_make(void)
|
||||
{
|
||||
net_hash *nn;
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include <kernel/OS.h>
|
||||
#include <strings.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "net_malloc.h"
|
||||
|
||||
@ -409,7 +410,7 @@ on1:
|
||||
x = x->rn_right;
|
||||
else
|
||||
x = x->rn_left;
|
||||
} while (b > (unsigned) x->rn_bit);
|
||||
} while (b > abs(x->rn_bit));
|
||||
/* x->rn_bit < b && x->rn_bit >= 0 */
|
||||
#ifdef RN_DEBUG
|
||||
if (rn_debug)
|
||||
|
@ -273,7 +273,7 @@ int rt_setgate(struct rtentry *rt0,
|
||||
struct rtentry *rt = rt0;
|
||||
|
||||
|
||||
if (rt->rt_gateway == NULL || glen > ROUNDUP(rt->rt_gateway->sa_len)) {
|
||||
if (rt->rt_gateway == NULL || glen > (int) ROUNDUP(rt->rt_gateway->sa_len)) {
|
||||
old = (caddr_t)rt_key(rt);
|
||||
R_Malloc(new, caddr_t, dlen + glen);
|
||||
if (new == NULL)
|
||||
@ -413,7 +413,7 @@ int rtinit(struct ifaddr *ifa, int cmd, int flags)
|
||||
return (error);
|
||||
}
|
||||
|
||||
void rtable_init(void **table)
|
||||
static void rtable_init(void **table)
|
||||
{
|
||||
struct domain *dom;
|
||||
|
||||
|
@ -54,7 +54,7 @@ void sockbuf_drop(struct sockbuf *sb, int len)
|
||||
next = m->m_nextpkt;
|
||||
continue;
|
||||
}
|
||||
if (m->m_len > len) {
|
||||
if ((int) m->m_len > len) {
|
||||
m->m_len -= len;
|
||||
m->m_data += len;
|
||||
sb->sb_cc -= len;
|
||||
@ -163,7 +163,7 @@ int sockbuf_appendaddr(struct sockbuf *sb, struct sockaddr *asa,
|
||||
if (n->m_next == 0) /* keep pointer to last control buf */
|
||||
break;
|
||||
}
|
||||
if (space > sbspace(sb))
|
||||
if (space > (int) sbspace(sb))
|
||||
return (0);
|
||||
if (asa->sa_len > MLEN)
|
||||
return (0);
|
||||
|
@ -73,14 +73,14 @@ void sockets_shutdown(void)
|
||||
int uiomove(caddr_t cp, int n, struct uio *uio)
|
||||
{
|
||||
struct iovec *iov;
|
||||
uint cnt;
|
||||
int cnt;
|
||||
int error = 0;
|
||||
void *ptr = NULL;
|
||||
|
||||
|
||||
while (n > 0 && uio->uio_resid) {
|
||||
iov = uio->uio_iov;
|
||||
cnt = iov->iov_len;
|
||||
|
||||
|
||||
if (cnt == 0) {
|
||||
uio->uio_iov++;
|
||||
uio->uio_iovcnt--;
|
||||
@ -88,7 +88,7 @@ int uiomove(caddr_t cp, int n, struct uio *uio)
|
||||
}
|
||||
if (cnt > n)
|
||||
cnt = n;
|
||||
|
||||
|
||||
switch (uio->uio_segflg) {
|
||||
/* XXX - once "properly" in kernel space, revisit and
|
||||
* fix this for kernel moves...
|
||||
@ -99,7 +99,7 @@ int uiomove(caddr_t cp, int n, struct uio *uio)
|
||||
ptr = memcpy(iov->iov_base, cp, cnt);
|
||||
else
|
||||
ptr = memcpy(cp, iov->iov_base, cnt);
|
||||
|
||||
|
||||
// if (!ptr)
|
||||
// return (errno);
|
||||
break;
|
||||
@ -370,10 +370,10 @@ int socket_send(struct socket *so, struct msghdr *mp, int flags, int *retsize)
|
||||
{
|
||||
struct uio auio;
|
||||
struct iovec *iov;
|
||||
int i;
|
||||
uint32 i;
|
||||
struct mbuf *to;
|
||||
struct mbuf *control;
|
||||
int len;
|
||||
uint len;
|
||||
int error;
|
||||
|
||||
auio.uio_iov = mp->msg_iov;
|
||||
@ -512,10 +512,10 @@ restart:
|
||||
if (flags & MSG_OOB)
|
||||
space += 1024;
|
||||
|
||||
if ((atomic && resid > so->so_snd.sb_hiwat) || clen > so->so_snd.sb_hiwat)
|
||||
if ((atomic && resid > (uint64) so->so_snd.sb_hiwat) || clen > so->so_snd.sb_hiwat)
|
||||
snderr(EMSGSIZE);
|
||||
|
||||
if (space < resid + clen && uio &&
|
||||
if ((uint64) space < resid + clen && uio &&
|
||||
(atomic || space < so->so_snd.sb_lowat || space < clen)) {
|
||||
if ((so->so_state & SS_NBIO)) { /* non blocking set */
|
||||
printf("so->so_state & SS_NBIO (%d)\n", so->so_state & SS_NBIO);
|
||||
@ -555,14 +555,14 @@ restart:
|
||||
|
||||
mlen = MCLBYTES;
|
||||
if (atomic && !top) {
|
||||
len = min(MCLBYTES - max_hdr, resid);
|
||||
len = min((uint64) (MCLBYTES - max_hdr), resid);
|
||||
m->m_data += max_hdr;
|
||||
} else
|
||||
len = min(MCLBYTES, resid);
|
||||
space -= len;
|
||||
} else {
|
||||
nopages:
|
||||
len = min(min(mlen, resid), space);
|
||||
len = min(min((uint64) mlen, resid), (uint64) space);
|
||||
space -= len;
|
||||
/* leave room for headers if required */
|
||||
if (atomic && !top && len < mlen)
|
||||
@ -639,8 +639,9 @@ int socket_recv(struct socket *so, struct msghdr *mp, caddr_t namelenp, int *ret
|
||||
struct iovec *iov;
|
||||
struct mbuf *control = NULL;
|
||||
struct mbuf *from = NULL;
|
||||
int error = 0, i, len = 0;
|
||||
|
||||
int error = 0, len = 0;
|
||||
uint32 i;
|
||||
|
||||
auio.uio_iov = mp->msg_iov;
|
||||
auio.uio_iovcnt = mp->msg_iovlen;
|
||||
auio.uio_segflg = UIO_USERSPACE;
|
||||
@ -660,7 +661,7 @@ int socket_recv(struct socket *so, struct msghdr *mp, caddr_t namelenp, int *ret
|
||||
if ((error = soreceive(so, &from, &auio,
|
||||
NULL, mp->msg_control ? &control : NULL,
|
||||
&mp->msg_flags)) != 0) {
|
||||
if (auio.uio_resid != len && (error == EINTR || error == EWOULDBLOCK))
|
||||
if (auio.uio_resid != (uint) len && (error == EINTR || error == EWOULDBLOCK))
|
||||
error = 0;
|
||||
}
|
||||
|
||||
@ -675,7 +676,7 @@ int socket_recv(struct socket *so, struct msghdr *mp, caddr_t namelenp, int *ret
|
||||
if (len <= 0 || !from) {
|
||||
len = 0;
|
||||
} else {
|
||||
if (len > from->m_len)
|
||||
if (len > (int) from->m_len)
|
||||
len = from->m_len;
|
||||
memcpy((caddr_t)mp->msg_name, mtod(from, caddr_t), len);
|
||||
}
|
||||
@ -703,7 +704,7 @@ static int soreceive(struct socket *so, struct mbuf **paddr, struct uio *uio, st
|
||||
int len, error = 0, offset;
|
||||
struct mbuf *nextrecord;
|
||||
int moff, type = 0;
|
||||
int orig_resid = uio->uio_resid;
|
||||
uint orig_resid = uio->uio_resid;
|
||||
struct protosw *pr = so->so_proto;
|
||||
|
||||
mp = mp0;
|
||||
@ -751,9 +752,9 @@ restart:
|
||||
* a short count if a timeout or signal occurs after we start.
|
||||
*/
|
||||
if (m == NULL || (((flags & MSG_DONTWAIT) == 0 &&
|
||||
so->so_rcv.sb_cc < uio->uio_resid) &&
|
||||
(uint) so->so_rcv.sb_cc < uio->uio_resid) &&
|
||||
(so->so_rcv.sb_cc < so->so_rcv.sb_lowat ||
|
||||
((flags & MSG_WAITALL) && uio->uio_resid <= so->so_rcv.sb_hiwat)) &&
|
||||
((flags & MSG_WAITALL) && uio->uio_resid <= (uint) so->so_rcv.sb_hiwat)) &&
|
||||
m->m_nextpkt == 0 && (pr->pr_flags & PR_ATOMIC) == 0)) {
|
||||
|
||||
if (so->so_error) {
|
||||
@ -857,15 +858,15 @@ dontblock:
|
||||
}
|
||||
so->so_state &= ~SS_RCVATMARK;
|
||||
len = uio->uio_resid;
|
||||
if (so->so_oobmark && len > so->so_oobmark - offset)
|
||||
if (so->so_oobmark && (uint) len > so->so_oobmark - offset)
|
||||
len = so->so_oobmark - offset;
|
||||
if (len > m->m_len - moff)
|
||||
if (len > (int) m->m_len - moff)
|
||||
len = m->m_len - moff;
|
||||
if (!mp)
|
||||
error = uiomove(mtod(m, caddr_t) + moff, (int)len, uio);
|
||||
else
|
||||
uio->uio_resid -= len;
|
||||
if (len == m->m_len - moff) {
|
||||
if (len == (int) m->m_len - moff) {
|
||||
if (m->m_flags & M_EOR)
|
||||
flags |= MSG_EOR;
|
||||
if (flags & MSG_PEEK) {
|
||||
@ -906,7 +907,7 @@ dontblock:
|
||||
}
|
||||
} else {
|
||||
offset += len;
|
||||
if (offset == so->so_oobmark)
|
||||
if ((uint) offset == so->so_oobmark)
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1479,7 +1480,7 @@ int socket_getsockname(struct socket *so, struct sockaddr *sa, int *alen)
|
||||
memcpy(&len, alen, sizeof(len));
|
||||
error = (*so->so_proto->pr_userreq)(so, PRU_SOCKADDR, NULL, m, NULL);
|
||||
if (error == 0) {
|
||||
if (len > m->m_len)
|
||||
if (len > (int) m->m_len)
|
||||
len = m->m_len;
|
||||
memcpy(sa, mtod(m, caddr_t), len);
|
||||
memcpy(alen, &len, sizeof(len));
|
||||
@ -1501,7 +1502,7 @@ int socket_getpeername(struct socket *so, struct sockaddr *sa, int * alen)
|
||||
memcpy(&len, alen, sizeof(len));
|
||||
error = (*so->so_proto->pr_userreq)(so, PRU_PEERADDR, NULL, m, NULL);
|
||||
if (error == 0) {
|
||||
if (len > m->m_len)
|
||||
if (len > (int) m->m_len)
|
||||
len = m->m_len;
|
||||
memcpy(sa, mtod(m, caddr_t), len);
|
||||
memcpy(alen, &len, sizeof(len));
|
||||
@ -1548,7 +1549,7 @@ int socket_accept(struct socket *so, struct socket **nso, void *data, int *alen)
|
||||
so->so_state &= ~SS_NOFDREF;
|
||||
error = (*so->so_proto->pr_userreq)(so, PRU_ACCEPT, NULL, nam, NULL);
|
||||
if (data) {
|
||||
if (len > nam->m_len)
|
||||
if (len > (int) nam->m_len)
|
||||
len = nam->m_len;
|
||||
if (memcpy(data, mtod(nam, caddr_t), len) == NULL)
|
||||
memcpy(alen, (caddr_t)&len, sizeof(len));
|
||||
|
Loading…
x
Reference in New Issue
Block a user