xref: /haiku/src/libs/compat/openbsd_network/compat/sys/mbuf.h (revision 4a55cc230cf7566cadcbb23b1928eefff8aea9a2)
1 /*
2  * Copyright 2022, Haiku, Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _OBSD_COMPAT_SYS_MBUF_H_
6 #define _OBSD_COMPAT_SYS_MBUF_H_
7 
8 #include <sys/systm.h>
9 
10 /* FreeBSD KASSERT */
11 #undef KASSERT
12 #define KASSERT KASSERT_FREEBSD
13 
14 #include_next <sys/mbuf.h>
15 
16 /* back to OpenBSD KASSERT */
17 #undef KASSERT
18 #define KASSERT KASSERT_OPENBSD
19 
20 #include <sys/mutex.h>
21 
22 
23 #define ph_cookie PH_loc.ptr
24 
25 #define M_DATABUF(m)	M_START(m)
26 #define M_READONLY(m)	(!M_WRITABLE(m))
27 
28 #define MAXMCLBYTES MJUM16BYTES
29 
30 
31 static struct mbuf*
32 MCLGETL(struct mbuf* m, int how, int size)
33 {
34 	if (m == NULL)
35 		return m_get2(size, how, MT_DATA, M_PKTHDR);
36 
37 	m_cljget(m, how, size);
38 	return m;
39 }
40 
41 static int
42 m_dup_pkthdr_openbsd(struct mbuf* to, const struct mbuf* from, int how)
43 {
44 	return !m_dup_pkthdr(to, from, how);
45 }
46 #define m_dup_pkthdr m_dup_pkthdr_openbsd
47 
48 static int
49 m_tag_copy_chain_openbsd(struct mbuf* to, const struct mbuf* from, int how)
50 {
51 	return !m_tag_copy_chain(to, from, how);
52 }
53 #define m_tag_copy_chain m_tag_copy_chain_openbsd
54 
55 
56 /* FreeBSD methods not compatible with their OpenBSD counterparts */
57 #define m_defrag(mbuf, how) __m_defrag_unimplemented()
58 
59 
60 #include "mbuf-obsd.h"
61 
62 
63 #endif	/* _OBSD_COMPAT_SYS_MBUF_H_ */
64