IP6_EXTHDR_GET performs a basic mbuf operation, which has nothing to do
with IPv6. So declare an IP-independent M_REGION_GET, and make IP6_EXTHDR_GET an alias to it.
This commit is contained in:
parent
67d5d4e2eb
commit
9a3fc3b376
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ip6.h,v 1.24 2018/05/18 18:28:40 maxv Exp $ */
|
||||
/* $NetBSD: ip6.h,v 1.25 2018/05/18 18:52:17 maxv Exp $ */
|
||||
/* $KAME: ip6.h,v 1.45 2003/06/05 04:46:38 keiichi Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -266,30 +266,8 @@ struct ip6_frag {
|
|||
#define IPV6_MAXPACKET 65535 /* ip6 max packet size without Jumbo payload*/
|
||||
|
||||
#ifdef _KERNEL
|
||||
/*
|
||||
* IP6_EXTHDR_GET ensures that intermediate protocol header (from "off" to
|
||||
* "len") is located in single mbuf, on contiguous memory region.
|
||||
* The pointer to the region will be returned to pointer variable "val",
|
||||
* with type "typ".
|
||||
*/
|
||||
#define IP6_EXTHDR_GET(val, typ, m, off, len) \
|
||||
do { \
|
||||
struct mbuf *_t; \
|
||||
int _tmp; \
|
||||
if ((m)->m_len >= (off) + (len)) \
|
||||
(val) = (typ)(mtod((m), char *) + (off)); \
|
||||
else { \
|
||||
_t = m_pulldown((m), (off), (len), &_tmp); \
|
||||
if (_t) { \
|
||||
if (_t->m_len < _tmp + (len)) \
|
||||
panic("m_pulldown malfunction"); \
|
||||
(val) = (typ)(mtod(_t, char *) + _tmp); \
|
||||
} else { \
|
||||
(val) = (typ)NULL; \
|
||||
(m) = NULL; \
|
||||
} \
|
||||
} \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
M_REGION_GET(val, typ, m, off, len)
|
||||
#endif /*_KERNEL*/
|
||||
|
||||
#endif /* !_NETINET_IP6_H_ */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mbuf.h,v 1.205 2018/05/03 21:37:29 christos Exp $ */
|
||||
/* $NetBSD: mbuf.h,v 1.206 2018/05/18 18:52:17 maxv Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996, 1997, 1999, 2001, 2007 The NetBSD Foundation, Inc.
|
||||
|
@ -644,6 +644,31 @@ do { \
|
|||
#define M_SETCTX(m, c) ((void)((m)->m_pkthdr._rcvif.ctx = (void *)(c)))
|
||||
#define M_CLEARCTX(m) M_SETCTX((m), NULL)
|
||||
|
||||
/*
|
||||
* M_REGION_GET ensures that the "len"-sized region of type "typ" starting
|
||||
* from "off" within "m" is located in a single mbuf, contiguously.
|
||||
*
|
||||
* The pointer to the region will be returned to pointer variable "val".
|
||||
*/
|
||||
#define M_REGION_GET(val, typ, m, off, len) \
|
||||
do { \
|
||||
struct mbuf *_t; \
|
||||
int _tmp; \
|
||||
if ((m)->m_len >= (off) + (len)) \
|
||||
(val) = (typ)(mtod((m), char *) + (off)); \
|
||||
else { \
|
||||
_t = m_pulldown((m), (off), (len), &_tmp); \
|
||||
if (_t) { \
|
||||
if (_t->m_len < _tmp + (len)) \
|
||||
panic("m_pulldown malfunction"); \
|
||||
(val) = (typ)(mtod(_t, char *) + _tmp); \
|
||||
} else { \
|
||||
(val) = (typ)NULL; \
|
||||
(m) = NULL; \
|
||||
} \
|
||||
} \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
|
||||
#endif /* defined(_KERNEL) */
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue