/src/usrsctp/usrsctplib/user_environment.h
Line | Count | Source (jump to first uncovered line) |
1 | | /*- |
2 | | * Copyright (c) 2009-2010 Brad Penoff |
3 | | * Copyright (c) 2009-2010 Humaira Kamal |
4 | | * Copyright (c) 2011-2012 Irene Ruengeler |
5 | | * Copyright (c) 2011-2012 Michael Tuexen |
6 | | * |
7 | | * All rights reserved. |
8 | | * |
9 | | * Redistribution and use in source and binary forms, with or without |
10 | | * modification, are permitted provided that the following conditions |
11 | | * are met: |
12 | | * 1. Redistributions of source code must retain the above copyright |
13 | | * notice, this list of conditions and the following disclaimer. |
14 | | * 2. Redistributions in binary form must reproduce the above copyright |
15 | | * notice, this list of conditions and the following disclaimer in the |
16 | | * documentation and/or other materials provided with the distribution. |
17 | | * |
18 | | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
19 | | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
20 | | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
21 | | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
22 | | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
23 | | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
24 | | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
25 | | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
26 | | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
27 | | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
28 | | * SUCH DAMAGE. |
29 | | */ |
30 | | |
31 | | #ifndef _USER_ENVIRONMENT_H_ |
32 | | #define _USER_ENVIRONMENT_H_ |
33 | | /* __Userspace__ */ |
34 | | #include <sys/types.h> |
35 | | |
36 | | #ifdef __FreeBSD__ |
37 | | #ifndef _SYS_MUTEX_H_ |
38 | | #include <sys/mutex.h> |
39 | | #endif |
40 | | #endif |
41 | | #if defined(_WIN32) |
42 | | #include "netinet/sctp_os_userspace.h" |
43 | | #endif |
44 | | |
45 | | /* maxsockets is used in SCTP_ZONE_INIT call. It refers to |
46 | | * kern.ipc.maxsockets kernel environment variable. |
47 | | */ |
48 | | extern int maxsockets; |
49 | | |
50 | | /* int hz; is declared in sys/kern/subr_param.c and refers to kernel timer frequency. |
51 | | * See http://ivoras.sharanet.org/freebsd/vmware.html for additional info about kern.hz |
52 | | * hz is initialized in void init_param1(void) in that file. |
53 | | */ |
54 | | extern int hz; |
55 | | |
56 | | |
57 | | /* The following two ints define a range of available ephemeral ports. */ |
58 | | extern int ipport_firstauto, ipport_lastauto; |
59 | | |
60 | | /* nmbclusters is used in sctp_usrreq.c (e.g., sctp_init). In the FreeBSD kernel, |
61 | | * this is 1024 + maxusers * 64. |
62 | | */ |
63 | | extern int nmbclusters; |
64 | | |
65 | | #if !defined(_MSC_VER) && !defined(__MINGW32__) |
66 | 65.1M | #define min(a,b) (((a)>(b))?(b):(a)) |
67 | 19.7k | #define max(a,b) (((a)>(b))?(a):(b)) |
68 | | #endif |
69 | | |
70 | | void init_random(void); |
71 | | void read_random(void *, size_t); |
72 | | void finish_random(void); |
73 | | |
74 | | /* errno's may differ per OS. errno.h now included in sctp_os_userspace.h */ |
75 | | /* Source: /usr/src/sys/sys/errno.h */ |
76 | | /* #define ENOSPC 28 */ /* No space left on device */ |
77 | | /* #define ENOBUFS 55 */ /* No buffer space available */ |
78 | | /* #define ENOMEM 12 */ /* Cannot allocate memory */ |
79 | | /* #define EACCES 13 */ /* Permission denied */ |
80 | | /* #define EFAULT 14 */ /* Bad address */ |
81 | | /* #define EHOSTDOWN 64 */ /* Host is down */ |
82 | | /* #define EHOSTUNREACH 65 */ /* No route to host */ |
83 | | |
84 | | /* Source ip_output.c. extern'd in ip_var.h */ |
85 | | extern u_short ip_id; |
86 | | |
87 | | #if defined(__linux__) |
88 | | #define IPV6_VERSION 0x60 |
89 | | #endif |
90 | | |
91 | | #if defined(INVARIANTS) |
92 | | #include <stdlib.h> |
93 | | |
94 | | #if defined(_WIN32) |
95 | | static inline void __declspec(noreturn) |
96 | | #else |
97 | | static inline void __attribute__((__noreturn__)) |
98 | | #endif |
99 | 0 | terminate_non_graceful(void) { |
100 | 0 | abort(); |
101 | 0 | } Unexecuted instantiation: user_socket.c:terminate_non_graceful Unexecuted instantiation: sctp_bsd_addr.c:terminate_non_graceful Unexecuted instantiation: sctp_callout.c:terminate_non_graceful Unexecuted instantiation: sctp_crc32.c:terminate_non_graceful Unexecuted instantiation: sctp_input.c:terminate_non_graceful Unexecuted instantiation: sctp_output.c:terminate_non_graceful Unexecuted instantiation: sctp_pcb.c:terminate_non_graceful Unexecuted instantiation: sctp_peeloff.c:terminate_non_graceful Unexecuted instantiation: sctp_timer.c:terminate_non_graceful Unexecuted instantiation: sctp_userspace.c:terminate_non_graceful Unexecuted instantiation: sctp_usrreq.c:terminate_non_graceful Unexecuted instantiation: sctputil.c:terminate_non_graceful Unexecuted instantiation: sctp6_usrreq.c:terminate_non_graceful Unexecuted instantiation: user_environment.c:terminate_non_graceful Unexecuted instantiation: user_mbuf.c:terminate_non_graceful Unexecuted instantiation: user_recv_thread.c:terminate_non_graceful Unexecuted instantiation: sctp_asconf.c:terminate_non_graceful Unexecuted instantiation: sctp_auth.c:terminate_non_graceful Unexecuted instantiation: sctp_cc_functions.c:terminate_non_graceful Unexecuted instantiation: sctp_indata.c:terminate_non_graceful Unexecuted instantiation: sctp_ss_functions.c:terminate_non_graceful Unexecuted instantiation: sctp_sysctl.c:terminate_non_graceful |
102 | | |
103 | | #define panic(...) \ |
104 | 0 | do { \ |
105 | 0 | SCTP_PRINTF("%s(): ", __func__); \ |
106 | 0 | SCTP_PRINTF(__VA_ARGS__); \ |
107 | 0 | SCTP_PRINTF("\n"); \ |
108 | 0 | terminate_non_graceful(); \ |
109 | 0 | } while (0) |
110 | | |
111 | | #define KASSERT(cond, args) \ |
112 | 109M | do { \ |
113 | 109M | if (!(cond)) { \ |
114 | 0 | panic args ; \ |
115 | 0 | } \ |
116 | 109M | } while (0) |
117 | | #else |
118 | | #define KASSERT(cond, args) |
119 | | #endif |
120 | | |
121 | | /* necessary for sctp_pcb.c */ |
122 | | extern int ip_defttl; |
123 | | #endif |