summaryrefslogtreecommitdiffstats
path: root/cpukit/libnetworking/kern
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2002-09-14 18:18:50 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2002-09-14 18:18:50 +0000
commitce2c216469083c54cd9047e0ace13fa737d8c084 (patch)
tree046d3850051b7eb7452d9c5b82b37044edf713dd /cpukit/libnetworking/kern
parent2002-09-14 Joel Sherrill <joel@OARcorp.com> (diff)
downloadrtems-ce2c216469083c54cd9047e0ace13fa737d8c084.tar.bz2
2002-09-14 Vyacheslav V. Burdjanadze <wr@zelax.ru>
* kern/uipc_mbuf.c, sys/mbuf.h, netinet/udp_usrreq.c: Add optional UDP broadcast forwarding support. * netinet/Makefile.am: Defined FORWARD_PROTOCOL to enabled UDP broadcast forwarding.
Diffstat (limited to 'cpukit/libnetworking/kern')
-rw-r--r--cpukit/libnetworking/kern/uipc_mbuf.c50
1 files changed, 38 insertions, 12 deletions
diff --git a/cpukit/libnetworking/kern/uipc_mbuf.c b/cpukit/libnetworking/kern/uipc_mbuf.c
index 17d2be6b26..4d97ea0bb0 100644
--- a/cpukit/libnetworking/kern/uipc_mbuf.c
+++ b/cpukit/libnetworking/kern/uipc_mbuf.c
@@ -354,9 +354,10 @@ nospace:
/*
* Copy data from an mbuf chain starting "off" bytes from the beginning,
- * continuing for "len" bytes, into the indicated buffer.
+ * continuing for "len" bytes, into the indicated buffer. Return -1 if requested
+ * size is bigger than available
*/
-void
+int
m_copydata(m, off, len, cp)
register struct mbuf *m;
register int off;
@@ -364,20 +365,36 @@ m_copydata(m, off, len, cp)
caddr_t cp;
{
register unsigned count;
+ struct mbuf *m0 = m;
if (off < 0 || len < 0)
panic("m_copydata");
while (off > 0) {
- if (m == 0)
- panic("m_copydata");
+ if (m == 0) {
+ /*printf("m_copydata: offset > mbuf length (");
+ while(m0) {
+ printf("[%d] ",m0->m_len);
+ m0 = m0->m_next;
+ }
+ printf(")\n");*/
+ return -1;
+ }
if (off < m->m_len)
break;
off -= m->m_len;
m = m->m_next;
}
while (len > 0) {
- if (m == 0)
- panic("m_copydata");
+ if (m == 0) {
+ /*printf("m_copydata: length > mbuf length (");
+ while(m0) {
+ printf("[%d] ",m0->m_len);
+ m0 = m0->m_next;
+ }
+ printf(")\n");*/
+
+ return -1;
+ }
count = min(m->m_len - off, len);
bcopy(mtod(m, caddr_t) + off, cp, count);
len -= count;
@@ -385,6 +402,7 @@ m_copydata(m, off, len, cp)
off = 0;
m = m->m_next;
}
+ return 0;
}
/*
@@ -699,7 +717,7 @@ m_devget(buf, totlen, off0, ifp, copy)
* starting "off" bytes from the beginning, extending the mbuf
* chain if necessary.
*/
-void
+int
m_copyback(m0, off, len, cp)
struct mbuf *m0;
register int off;
@@ -717,8 +735,10 @@ m_copyback(m0, off, len, cp)
totlen += mlen;
if (m->m_next == 0) {
n = m_getclr(M_DONTWAIT, m->m_type);
- if (n == 0)
- goto out;
+ if (n == 0) {
+ /*panic("m_copyback() : malformed chain\n");*/
+ return -1;
+ }
n->m_len = min(MLEN, len + off);
m->m_next = n;
}
@@ -732,17 +752,23 @@ m_copyback(m0, off, len, cp)
mlen += off;
off = 0;
totlen += mlen;
- if (len == 0)
+ if (len == 0) {
+ m->m_len = mlen;
break;
+ }
if (m->m_next == 0) {
n = m_get(M_DONTWAIT, m->m_type);
- if (n == 0)
- break;
+ if (n == 0) {
+ /*panic("m_copyback() : malformed chain 2\n");*/
+ return -1;
+ };
n->m_len = min(MLEN, len);
m->m_next = n;
}
+ m->m_len = mlen;
m = m->m_next;
}
out: if (((m = m0)->m_flags & M_PKTHDR) && (m->m_pkthdr.len < totlen))
m->m_pkthdr.len = totlen;
+ return 0;
}