uipc_mbuf2.c (107283) | uipc_mbuf2.c (108466) |
---|---|
1/* $FreeBSD: head/sys/kern/uipc_mbuf2.c 107283 2002-11-26 17:59:16Z sam $ */ | 1/* $FreeBSD: head/sys/kern/uipc_mbuf2.c 108466 2002-12-30 20:22:40Z sam $ */ |
2/* $KAME: uipc_mbuf2.c,v 1.31 2001/11/28 11:08:53 itojun Exp $ */ 3/* $NetBSD: uipc_mbuf.c,v 1.40 1999/04/01 00:23:25 thorpej Exp $ */ 4 5/* 6 * Copyright (C) 1999 WIDE Project. 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without --- 283 unchanged lines hidden (view full) --- 293 if ((n->m_flags & M_EXT) == 0) { 294 m_free(n); 295 n = NULL; 296 } 297 } 298 if (!n) 299 return NULL; 300 | 2/* $KAME: uipc_mbuf2.c,v 1.31 2001/11/28 11:08:53 itojun Exp $ */ 3/* $NetBSD: uipc_mbuf.c,v 1.40 1999/04/01 00:23:25 thorpej Exp $ */ 4 5/* 6 * Copyright (C) 1999 WIDE Project. 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without --- 283 unchanged lines hidden (view full) --- 293 if ((n->m_flags & M_EXT) == 0) { 294 m_free(n); 295 n = NULL; 296 } 297 } 298 if (!n) 299 return NULL; 300 |
301 if (copyhdr) 302 M_COPY_PKTHDR(n, m); | 301 if (copyhdr && !m_dup_pkthdr(n, m, wait)) { 302 m_free(n); 303 return NULL; 304 } |
303 m_copydata(m, off, len, mtod(n, caddr_t)); 304 return n; 305} 306 307/* Get a packet tag structure along with specified data following. */ 308struct m_tag * 309m_tag_alloc(u_int32_t cookie, int type, int len, int wait) 310{ --- 76 unchanged lines hidden (view full) --- 387 return p; 388 p = SLIST_NEXT(p, m_tag_link); 389 } 390 return NULL; 391} 392 393/* Copy a single tag. */ 394struct m_tag * | 305 m_copydata(m, off, len, mtod(n, caddr_t)); 306 return n; 307} 308 309/* Get a packet tag structure along with specified data following. */ 310struct m_tag * 311m_tag_alloc(u_int32_t cookie, int type, int len, int wait) 312{ --- 76 unchanged lines hidden (view full) --- 389 return p; 390 p = SLIST_NEXT(p, m_tag_link); 391 } 392 return NULL; 393} 394 395/* Copy a single tag. */ 396struct m_tag * |
395m_tag_copy(struct m_tag *t) | 397m_tag_copy(struct m_tag *t, int how) |
396{ 397 struct m_tag *p; 398 399 KASSERT(t, ("m_tag_copy: null tag")); | 398{ 399 struct m_tag *p; 400 401 KASSERT(t, ("m_tag_copy: null tag")); |
400 p = m_tag_alloc(t->m_tag_cookie, t->m_tag_id, t->m_tag_len, M_NOWAIT); | 402 p = m_tag_alloc(t->m_tag_cookie, t->m_tag_id, t->m_tag_len, how); |
401 if (p == NULL) 402 return (NULL); 403 bcopy(t + 1, p + 1, t->m_tag_len); /* Copy the data */ 404 return p; 405} 406 407/* 408 * Copy two tag chains. The destination mbuf (to) loses any attached 409 * tags even if the operation fails. This should not be a problem, as 410 * m_tag_copy_chain() is typically called with a newly-allocated 411 * destination mbuf. 412 */ 413int | 403 if (p == NULL) 404 return (NULL); 405 bcopy(t + 1, p + 1, t->m_tag_len); /* Copy the data */ 406 return p; 407} 408 409/* 410 * Copy two tag chains. The destination mbuf (to) loses any attached 411 * tags even if the operation fails. This should not be a problem, as 412 * m_tag_copy_chain() is typically called with a newly-allocated 413 * destination mbuf. 414 */ 415int |
414m_tag_copy_chain(struct mbuf *to, struct mbuf *from) | 416m_tag_copy_chain(struct mbuf *to, struct mbuf *from, int how) |
415{ 416 struct m_tag *p, *t, *tprev = NULL; 417 418 KASSERT(to && from, 419 ("m_tag_copy_chain: null argument, to %p from %p", to, from)); 420 m_tag_delete_chain(to, NULL); 421 SLIST_FOREACH(p, &from->m_pkthdr.tags, m_tag_link) { | 417{ 418 struct m_tag *p, *t, *tprev = NULL; 419 420 KASSERT(to && from, 421 ("m_tag_copy_chain: null argument, to %p from %p", to, from)); 422 m_tag_delete_chain(to, NULL); 423 SLIST_FOREACH(p, &from->m_pkthdr.tags, m_tag_link) { |
422 t = m_tag_copy(p); | 424 t = m_tag_copy(p, how); |
423 if (t == NULL) { 424 m_tag_delete_chain(to, NULL); 425 return 0; 426 } 427 if (tprev == NULL) 428 SLIST_INSERT_HEAD(&to->m_pkthdr.tags, t, m_tag_link); 429 else { 430 SLIST_INSERT_AFTER(tprev, t, m_tag_link); --- 26 unchanged lines hidden --- | 425 if (t == NULL) { 426 m_tag_delete_chain(to, NULL); 427 return 0; 428 } 429 if (tprev == NULL) 430 SLIST_INSERT_HEAD(&to->m_pkthdr.tags, t, m_tag_link); 431 else { 432 SLIST_INSERT_AFTER(tprev, t, m_tag_link); --- 26 unchanged lines hidden --- |