/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000,2007 Apple Inc. All rights reserved.
*
- * @APPLE_LICENSE_HEADER_START@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
- * compliance with the License. Please obtain a copy of the License at
- * http://www.opensource.apple.com/apsl/ and read it before using this
- * file.
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
+ *
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* Please see the License for the specific language governing rights and
* limitations under the License.
*
- * @APPLE_LICENSE_HEADER_END@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/* $FreeBSD: src/sys/netinet/ip_encap.c,v 1.1.2.2 2001/07/03 11:01:46 ume Exp $ */
/* $KAME: ip_encap.c,v 1.41 2001/03/15 08:35:08 itojun Exp $ */
{
struct encaptab *ep;
int error;
- int s;
- s = splnet();
/* sanity check on args */
if (sp->sa_len > sizeof(ep->src) || dp->sa_len > sizeof(ep->dst)) {
error = EINVAL;
encap_add(ep);
error = 0;
- splx(s);
return ep;
fail:
- splx(s);
return NULL;
}
{
struct encaptab *ep;
int error;
- int s;
- s = splnet();
/* sanity check on args */
if (!func) {
error = EINVAL;
encap_add(ep);
error = 0;
- splx(s);
return ep;
fail:
- splx(s);
return NULL;
}
return 0;
}
+struct encaptabtag {
+ void* *arg;
+};
+
static void
-encap_fillarg(m, ep)
- struct mbuf *m;
- const struct encaptab *ep;
+encap_fillarg(
+ struct mbuf *m,
+ const struct encaptab *ep)
{
-#if 0
- m->m_pkthdr.aux = ep->arg;
-#else
- struct mbuf *n;
-
- n = m_aux_add(m, AF_INET, IPPROTO_IPV4);
- if (n) {
- *mtod(n, void **) = ep->arg;
- n->m_len = sizeof(void *);
+ struct m_tag *tag;
+ struct encaptabtag *et;
+
+ tag = m_tag_alloc(KERNEL_MODULE_TAG_ID, KERNEL_TAG_TYPE_ENCAP,
+ sizeof(struct encaptabtag), M_WAITOK);
+
+ if (tag != NULL) {
+ et = (struct encaptabtag*)(tag + 1);
+ et->arg = ep->arg;
+ m_tag_prepend(m, tag);
}
-#endif
}
void *
encap_getarg(m)
struct mbuf *m;
{
- void *p;
-#if 0
- p = m->m_pkthdr.aux;
- m->m_pkthdr.aux = NULL;
- return p;
-#else
- struct mbuf *n;
-
- p = NULL;
- n = m_aux_find(m, AF_INET, IPPROTO_IPV4);
- if (n) {
- if (n->m_len == sizeof(void *))
- p = *mtod(n, void **);
- m_aux_delete(m, n);
+ struct m_tag *tag;
+ struct encaptabtag *et;
+ void *p = NULL;
+
+ tag = m_tag_locate(m, KERNEL_MODULE_TAG_ID, KERNEL_TAG_TYPE_ENCAP, NULL);
+ if (tag) {
+ et = (struct encaptabtag*)(tag + 1);
+ p = et->arg;
+ m_tag_delete(m, tag);
}
+
return p;
-#endif
}