OLD | NEW |
1 /*- | 1 /*- |
2 * Copyright (c) 2006-2007, by Cisco Systems, Inc. All rights reserved. | 2 * Copyright (c) 2006-2007, by Cisco Systems, Inc. All rights reserved. |
3 * Copyright (c) 2008-2011, by Randall Stewart. All rights reserved. | 3 * Copyright (c) 2008-2011, by Randall Stewart. All rights reserved. |
4 * Copyright (c) 2008-2011, by Michael Tuexen. All rights reserved. | 4 * Copyright (c) 2008-2011, by Michael Tuexen. All rights reserved. |
5 * Copyright (c) 2008-2011, by Brad Penoff. All rights reserved. | 5 * Copyright (c) 2008-2011, by Brad Penoff. All rights reserved. |
6 * | 6 * |
7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
8 * modification, are permitted provided that the following conditions are met: | 8 * modification, are permitted provided that the following conditions are met: |
9 * | 9 * |
10 * a) Redistributions of source code must retain the above copyright notice, | 10 * a) Redistributions of source code must retain the above copyright notice, |
(...skipping 26 matching lines...) Expand all Loading... |
37 * Userspace includes | 37 * Userspace includes |
38 * All the opt_xxx.h files are placed in the kernel build directory. | 38 * All the opt_xxx.h files are placed in the kernel build directory. |
39 * We will place them in userspace stack build directory. | 39 * We will place them in userspace stack build directory. |
40 */ | 40 */ |
41 | 41 |
42 #include <errno.h> | 42 #include <errno.h> |
43 | 43 |
44 #if defined(__Userspace_os_Windows) | 44 #if defined(__Userspace_os_Windows) |
45 #include <winsock2.h> | 45 #include <winsock2.h> |
46 #include <ws2tcpip.h> | 46 #include <ws2tcpip.h> |
47 #include <ws2ipdef.h> | |
48 #include <ws2def.h> | |
49 #include <iphlpapi.h> | 47 #include <iphlpapi.h> |
50 #include <Mswsock.h> | 48 #include <Mswsock.h> |
51 #include <Windows.h> | 49 #include <Windows.h> |
52 #include "user_environment.h" | 50 #include "user_environment.h" |
53 typedef CRITICAL_SECTION userland_mutex_t; | 51 typedef CRITICAL_SECTION userland_mutex_t; |
54 #if WINVER < 0x0600 | 52 #if WINVER < 0x0600 |
55 enum { | 53 enum { |
56 C_SIGNAL = 0, | 54 C_SIGNAL = 0, |
57 C_BROADCAST = 1, | 55 C_BROADCAST = 1, |
58 C_MAX_EVENTS = 2 | 56 C_MAX_EVENTS = 2 |
59 }; | 57 }; |
60 typedef struct | 58 typedef struct |
61 { | 59 { |
62 u_int waiters_count; | 60 u_int waiters_count; |
63 CRITICAL_SECTION waiters_count_lock; | 61 CRITICAL_SECTION waiters_count_lock; |
64 HANDLE events_[C_MAX_EVENTS]; | 62 HANDLE events_[C_MAX_EVENTS]; |
65 } userland_cond_t; | 63 } userland_cond_t; |
| 64 void InitializeXPConditionVariable(userland_cond_t *); |
| 65 void DeleteXPConditionVariable(userland_cond_t *); |
| 66 int SleepXPConditionVariable(userland_cond_t *, userland_mutex_t *); |
| 67 void WakeAllXPConditionVariable(userland_cond_t *); |
66 #define InitializeConditionVariable(cond) InitializeXPConditionVariable(cond) | 68 #define InitializeConditionVariable(cond) InitializeXPConditionVariable(cond) |
67 #define DeleteConditionVariable(cond) DeleteXPConditionVariable(cond) | 69 #define DeleteConditionVariable(cond) DeleteXPConditionVariable(cond) |
68 #define SleepConditionVariableCS(cond, mtx, time) SleepXPConditionVariable(cond,
mtx) | 70 #define SleepConditionVariableCS(cond, mtx, time) SleepXPConditionVariable(cond,
mtx) |
69 #define WakeAllConditionVariable(cond) WakeAllXPConditionVariable(cond) | 71 #define WakeAllConditionVariable(cond) WakeAllXPConditionVariable(cond) |
70 #else | 72 #else |
71 #define DeleteConditionVariable(cond) | 73 #define DeleteConditionVariable(cond) |
72 typedef CONDITION_VARIABLE userland_cond_t; | 74 typedef CONDITION_VARIABLE userland_cond_t; |
73 #endif | 75 #endif |
74 typedef HANDLE userland_thread_t; | 76 typedef HANDLE userland_thread_t; |
75 #define ADDRESS_FAMILY unsigned __int8 | 77 #define ADDRESS_FAMILY unsigned __int8 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 #endif | 205 #endif |
204 #ifndef ESTALE | 206 #ifndef ESTALE |
205 #define ESTALE WSAESTALE | 207 #define ESTALE WSAESTALE |
206 #endif | 208 #endif |
207 #ifndef EREMOTE | 209 #ifndef EREMOTE |
208 #define EREMOTE WSAEREMOTE | 210 #define EREMOTE WSAEREMOTE |
209 #endif | 211 #endif |
210 | 212 |
211 typedef char* caddr_t; | 213 typedef char* caddr_t; |
212 | 214 |
| 215 int Win_getifaddrs(struct ifaddrs**); |
213 #define getifaddrs(interfaces) (int)Win_getifaddrs(interfaces) | 216 #define getifaddrs(interfaces) (int)Win_getifaddrs(interfaces) |
214 #define if_nametoindex(x) (int)win_if_nametoindex(x) | 217 int win_if_nametoindex(const char *); |
| 218 #define if_nametoindex(x) win_if_nametoindex(x) |
215 | 219 |
216 #define bzero(buf, len) memset(buf, 0, len) | 220 #define bzero(buf, len) memset(buf, 0, len) |
217 #define bcopy(srcKey, dstKey, len) memcpy(dstKey, srcKey, len) | 221 #define bcopy(srcKey, dstKey, len) memcpy(dstKey, srcKey, len) |
218 #define snprintf(data, size, format, name) _snprintf_s(data, size, _TRUNCATE, fo
rmat, name) | 222 #define snprintf(data, size, format, name) _snprintf_s(data, size, _TRUNCATE, fo
rmat, name) |
219 #define inline __inline | 223 #define inline __inline |
220 #define __inline__ __inline | 224 #define __inline__ __inline |
221 #define random() rand() | 225 #define random() rand() |
222 #define srandom(s) srand(s) | 226 #define srandom(s) srand(s) |
223 #define MSG_EOR 0x8 /* data completes record */ | 227 #define MSG_EOR 0x8 /* data completes record */ |
224 #define MSG_DONTWAIT 0x80 /* this message should be nonblocking */ | 228 #define MSG_DONTWAIT 0x80 /* this message should be nonblocking */ |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 #include <stdio.h> | 408 #include <stdio.h> |
405 #include <string.h> | 409 #include <string.h> |
406 /* #include <sys/param.h> in FreeBSD defines MSIZE */ | 410 /* #include <sys/param.h> in FreeBSD defines MSIZE */ |
407 /* #include <sys/ktr.h> */ | 411 /* #include <sys/ktr.h> */ |
408 /* #include <sys/systm.h> */ | 412 /* #include <sys/systm.h> */ |
409 #if defined(__Userspace_os_Windows) | 413 #if defined(__Userspace_os_Windows) |
410 #include <user_queue.h> | 414 #include <user_queue.h> |
411 #else | 415 #else |
412 #include <sys/queue.h> | 416 #include <sys/queue.h> |
413 #endif | 417 #endif |
| 418 #include <user_malloc.h> |
414 /* #include <sys/kernel.h> */ | 419 /* #include <sys/kernel.h> */ |
415 /* #include <sys/sysctl.h> */ | 420 /* #include <sys/sysctl.h> */ |
416 /* #include <sys/protosw.h> */ | 421 /* #include <sys/protosw.h> */ |
417 /* on FreeBSD, this results in a redefintion of SOCK(BUF)_(UN)LOCK and | 422 /* on FreeBSD, this results in a redefintion of SOCK(BUF)_(UN)LOCK and |
418 * uknown type of struct mtx for sb_mtx in struct sockbuf */ | 423 * uknown type of struct mtx for sb_mtx in struct sockbuf */ |
| 424 #include "user_socketvar.h" /* MALLOC_DECLARE's M_PCB. Replacement for sys/socke
tvar.h */ |
419 /* #include <sys/jail.h> */ | 425 /* #include <sys/jail.h> */ |
420 /* #include <sys/sysctl.h> */ | 426 /* #include <sys/sysctl.h> */ |
| 427 #include <user_environment.h> |
421 #include <user_atomic.h> | 428 #include <user_atomic.h> |
422 #include <user_environment.h> | |
423 #include <user_malloc.h> | |
424 #include <user_mbuf.h> | 429 #include <user_mbuf.h> |
425 #include "user_socketvar.h" /* MALLOC_DECLARE's M_PCB. Replacement for sys/socke
tvar.h */ | |
426 /* #include <sys/uio.h> */ | 430 /* #include <sys/uio.h> */ |
427 /* #include <sys/lock.h> */ | 431 /* #include <sys/lock.h> */ |
428 #if defined(__FreeBSD__) && __FreeBSD_version > 602000 | 432 #if defined(__FreeBSD__) && __FreeBSD_version > 602000 |
429 #include <sys/rwlock.h> | 433 #include <sys/rwlock.h> |
430 #endif | 434 #endif |
431 /* #include <sys/kthread.h> */ | 435 /* #include <sys/kthread.h> */ |
432 #if defined(__FreeBSD__) && __FreeBSD_version > 602000 | 436 #if defined(__FreeBSD__) && __FreeBSD_version > 602000 |
433 #include <sys/priv.h> | 437 #include <sys/priv.h> |
434 #endif | 438 #endif |
435 /* #include <sys/random.h> */ | 439 /* #include <sys/random.h> */ |
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
986 */ | 990 */ |
987 /* #define USE_SCTP_SHA1 */ | 991 /* #define USE_SCTP_SHA1 */ |
988 | 992 |
989 /* #define HAVE_SHA2 sha2.h exists on Linux? */ | 993 /* #define HAVE_SHA2 sha2.h exists on Linux? */ |
990 | 994 |
991 | 995 |
992 #define SCTP_READ_RANDOM(buf, len) read_random(buf, len) | 996 #define SCTP_READ_RANDOM(buf, len) read_random(buf, len) |
993 | 997 |
994 | 998 |
995 #include <netinet/sctp_sha1.h> | 999 #include <netinet/sctp_sha1.h> |
996 #if 0 /*this was old _KERNEL code... */ | 1000 |
997 #include <crypto/sha1.h> | |
998 /* map standard crypto API names */ | |
999 #define SHA1_Init» SHA1Init | |
1000 #define SHA1_Update» SHA1Update | |
1001 #define SHA1_Final(x,y)»SHA1Final((caddr_t)x, y) | |
1002 #endif | |
1003 | 1001 |
1004 #if defined(HAVE_SHA2) | 1002 #if defined(HAVE_SHA2) |
1005 #include <crypto/sha2/sha2.h> | 1003 #include <crypto/sha2/sha2.h> |
1006 #endif | 1004 #endif |
1007 #if 0 | 1005 #if 0 |
1008 /* going to have to port so generic across OS's... */ | 1006 /* going to have to port so generic across OS's... */ |
1009 #if 1 /* openssl header files on FreeBSD 6.3 on Emulab and libssl-dev for Ubuntu
*/ | 1007 #if 1 /* openssl header files on FreeBSD 6.3 on Emulab and libssl-dev for Ubuntu
*/ |
1010 #include <openssl/md5.h> | 1008 #include <openssl/md5.h> |
1011 #include <openssl/sha.h> | 1009 #include <openssl/sha.h> |
1012 /* libssl-dev calls this SHA_CTX, but it's refered to as SHA1_CTX within the | 1010 /* libssl-dev calls this SHA_CTX, but it's refered to as SHA1_CTX within the |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1155 for ((var) = ((head)->tqh_first); \ | 1153 for ((var) = ((head)->tqh_first); \ |
1156 (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \ | 1154 (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \ |
1157 (var) = (tvar)) | 1155 (var) = (tvar)) |
1158 | 1156 |
1159 #define LIST_FOREACH_SAFE(var, head, field, tvar) \ | 1157 #define LIST_FOREACH_SAFE(var, head, field, tvar) \ |
1160 for ((var) = ((head)->lh_first); \ | 1158 for ((var) = ((head)->lh_first); \ |
1161 (var) && ((tvar) = LIST_NEXT((var), field), 1); \ | 1159 (var) && ((tvar) = LIST_NEXT((var), field), 1); \ |
1162 (var) = (tvar)) | 1160 (var) = (tvar)) |
1163 #endif | 1161 #endif |
1164 #endif | 1162 #endif |
OLD | NEW |