comparison packages/net/tcpip/current/include/netinet6/osdep.h @ 97:ced4577552cd ecos-sw-2000-06-06

Merge from eCos master repository on 2000-06-06-08:44:00-BST
author jlarmour
date Tue, 06 Jun 2000 08:39:36 +0000
parents
children e0c0827131d1
comparison
equal deleted inserted replaced
96:b15c60e34c84 97:ced4577552cd
1 //==========================================================================
2 //
3 // include/netinet6_osdep.h
4 //
5 //
6 //
7 //==========================================================================
8 //####COPYRIGHTBEGIN####
9 //
10 // -------------------------------------------
11 // The contents of this file are subject to the Red Hat eCos Public License
12 // Version 1.1 (the "License"); you may not use this file except in
13 // compliance with the License. You may obtain a copy of the License at
14 // http://www.redhat.com/
15 //
16 // Software distributed under the License is distributed on an "AS IS"
17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
18 // License for the specific language governing rights and limitations under
19 // the License.
20 //
21 // The Original Code is eCos - Embedded Configurable Operating System,
22 // released September 30, 1998.
23 //
24 // The Initial Developer of the Original Code is Red Hat.
25 // Portions created by Red Hat are
26 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
27 // All Rights Reserved.
28 // -------------------------------------------
29 //
30 //####COPYRIGHTEND####
31 //####BSDCOPYRIGHTBEGIN####
32 //
33 // -------------------------------------------
34 //
35 // Portions of this software may have been derived from OpenBSD or other sources,
36 // and are covered by the appropriate copyright disclaimers included herein.
37 //
38 // -------------------------------------------
39 //
40 //####BSDCOPYRIGHTEND####
41 //==========================================================================
42 //#####DESCRIPTIONBEGIN####
43 //
44 // Author(s): gthomas
45 // Contributors: gthomas
46 // Date: 2000-01-10
47 // Purpose:
48 // Description:
49 //
50 //
51 //####DESCRIPTIONEND####
52 //
53 //==========================================================================
54
55
56 /* $OpenBSD: osdep.h,v 1.3 1999/12/10 08:53:18 angelos Exp $ */
57 /*
58 %%% copyright-nrl-97
59 This software is Copyright 1997-1998 by Randall Atkinson, Ronald Lee,
60 Daniel McDonald, Bao Phan, and Chris Winters. All Rights Reserved. All
61 rights under this copyright have been assigned to the US Naval Research
62 Laboratory (NRL). The NRL Copyright Notice and License Agreement Version
63 1.1 (January 17, 1995) applies to this software.
64 You should have received a copy of the license with this software. If you
65 didn't get a copy, you may request one from <license@ipv6.nrl.navy.mil>.
66
67 %%% copyright-cmetz-97
68 This software is Copyright 1997-1998 by Craig Metz, All Rights Reserved.
69 The Inner Net License Version 2 applies to this software.
70 You should have received a copy of the license with this software. If
71 you didn't get a copy, you may request one from <license@inner.net>.
72
73 */
74 #ifndef _NETINET6_OSDEP_H_
75 #define _NETINET6_OSDEP_H_
76
77 #define OSDEP_BSD 1
78
79 #include <sys/types.h>
80 #include <sys/param.h>
81 #include <sys/socket.h>
82 #ifdef KERNEL
83 #ifndef ATSH_ADD
84 #include <sys/systm.h>
85 #endif /* ATSH_ADD */
86 #ifndef MLEN
87 #include <sys/mbuf.h>
88 #endif /* MLEN */
89 #include <sys/kernel.h>
90 #include <sys/malloc.h>
91 #ifndef SB_MAX
92 #include <sys/socketvar.h>
93 #endif /* SB_MAX */
94 #include <sys/proc.h>
95 #ifndef RTM_RTTUNIT
96 #include <net/route.h>
97 #endif /* RTM_RTTUNIT */
98 #endif /* KERNEL */
99 struct ifnet;
100 struct mbuf;
101 #include <netinet/in.h>
102 struct route6;
103
104 #ifdef KERNEL
105 /* XXX */
106 #define OSDEP_CRITICALDCL int __s;
107 #define OSDEP_CRITICALSTART __s = splnet()
108 #define OSDEP_CRITICALEND splx(__s)
109 #define OSDEP_TIMESECONDS (time.tv_sec)
110 #define OSDEP_PROCESS struct proc
111 #define OSDEP_PROCESSCURRENT (curproc)
112 #define OSDEP_PROCESSPARENT(x) ((x)->p_pptr)
113 #define OSDEP_PROCESSPID(x) ((x)->p_pid)
114
115 #ifdef SS_PRIV
116 #define OSDEP_SOCKETPRIVELEGED(socket) (socket->so_state & SS_PRIV)
117 #else /* SS_PRIV */
118 /* XXX? */
119 #define OSDEP_SOCKETPRIVELEGED(socket) (!curproc || !curproc->p_ucred || !curproc->p_ucred->cr_uid)
120 #endif /* SS_PRIV */
121 #define OSDEP_PCAST(x) ((unsigned int)(x) & 0xffffffff)
122 #define OSDEP_SOCKET struct socket
123 #define OSDEP_PACKET struct mbuf
124 struct mbuf;
125
126 #define OSDEP_REAL_MALLOC(n) malloc((unsigned long)(n), M_TEMP, M_DONTWAIT)
127 #define OSDEP_REAL_FREE(p) free((void *)p, M_TEMP)
128 #define OSDEP_FAMILY(socket) (socket->so_proto->pr_domain->dom_family)
129 #define OSDEP_PSEUDORANDOM (uint32_t)random()
130
131 struct ifnet;
132 struct mbuf *m_devget(char *, int, int, struct ifnet *, void (*)(const void *, void *, size_t));
133
134 static __inline__ int __osdep_datatopacket(void *data, int len, OSDEP_PACKET **packet)
135 {
136 if (!(*packet = m_devget(data, len, 0, NULL, NULL)))
137 return -ENOMEM;
138
139 return 0;
140 };
141
142 #define OSDEP_DATATOPACKET(data, len, packet) __osdep_datatopacket(data, len, packet)
143
144 #define OSDEP_ZEROPACKET(packet) m_zero(packet)
145 #define OSDEP_FREEPACKET(packet) m_freem(packet)
146
147 #define memcpy(dst, src, len) bcopy(src, dst, len)
148 #define memmove(dst, src, len) bcopy(src, dst, len)
149 #define memset(p, zero, len) bzero(p, len) /* XXX */
150 #define memcmp(p1, p2, len) bcmp(p1, p2, len)
151
152 #define OSDEP_COPYFROMUSER(dst, src, len) copyin(src, dst, len)
153 #define OSDEP_COPYTOUSER(dst, src, len) copyout(src, dst, len)
154
155 #endif /* KERNEL */
156 #define OSDEP_SALEN 1
157 #define OSDEP_ERROR(x) (x)
158
159 #define ENETSECURITYPOLICY -ECOMM
160
161 #ifdef DEBUG_MALLOC
162 #undef OSDEP_MALLOC
163 #undef OSDEP_FREE
164 #define OSDEP_MALLOC(n) debug_malloc_malloc(n, DEBUG_STATUS)
165 #define OSDEP_FREE(p) debug_malloc_free(p)
166 #else /* DEBUG_MALLOC */
167 #undef OSDEP_MALLOC
168 #define OSDEP_MALLOC(n) OSDEP_REAL_MALLOC(n)
169 #undef OSDEP_FREE
170 #define OSDEP_FREE(p) OSDEP_REAL_FREE(p)
171 #endif /* DEBUG_MALLOC */
172
173 #endif // _NETINET6_OSDEP_H_