netwerk/sctp/src/user_environment.h

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rwxr-xr-x

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     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  */
    31 #ifndef _USER_ENVIRONMENT_H_
    32 #define _USER_ENVIRONMENT_H_
    33 /* __Userspace__ */
    34 #include <sys/types.h>
    36 #ifdef __Userspace_os_FreeBSD
    37 #ifndef _SYS_MUTEX_H_
    38 #include <sys/mutex.h>
    39 #endif
    40 #endif
    41 #if defined (__Userspace_os_Windows)
    42 #include "netinet/sctp_os_userspace.h"
    43 #endif
    45 /* maxsockets is used in SCTP_ZONE_INIT call. It refers to
    46  * kern.ipc.maxsockets kernel environment variable.
    47  */
    48 extern int maxsockets;
    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;
    57 /* The following two ints define a range of available ephermal ports. */
    58 extern int ipport_firstauto, ipport_lastauto;
    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;
    65 #if !defined (__Userspace_os_Windows)
    66 #define min(a,b) ((a)>(b)?(b):(a))
    67 #define max(a,b) ((a)>(b)?(a):(b))
    68 #endif
    70 extern int read_random(void *buf, int count);
    72 /* errno's may differ per OS.  errno.h now included in sctp_os_userspace.h */
    73 /* Source: /usr/src/sys/sys/errno.h */
    74 /* #define	ENOSPC		28 */		/* No space left on device */
    75 /* #define	ENOBUFS		55 */		/* No buffer space available */
    76 /* #define	ENOMEM		12 */		/* Cannot allocate memory */
    77 /* #define	EACCES		13 */		/* Permission denied */
    78 /* #define	EFAULT		14 */		/* Bad address */
    79 /* #define	EHOSTDOWN	64 */		/* Host is down */
    80 /* #define	EHOSTUNREACH	65 */		/* No route to host */
    82 /* Source ip_output.c. extern'd in ip_var.h */
    83 extern u_short ip_id;
    85 #if defined(__Userspace_os_Linux)
    86 #define IPV6_VERSION            0x60
    87 #endif
    88 #if defined(INVARIANTS)
    89 #define panic(args...)            \
    90 	do {                      \
    91 		SCTP_PRINTF(args);\
    92 		exit(1);          \
    93 } while (0)
    94 #endif
    96 #if defined(INVARIANTS)
    97 #define KASSERT(cond, args)          \
    98 	do {                         \
    99 		if (!(cond)) {       \
   100 			printf args ;\
   101 			exit(1);     \
   102 		}                    \
   103 	} while (0)
   104 #else
   105 #define KASSERT(cond, args)
   106 #endif
   108 /* necessary for sctp_pcb.c */
   109 extern int ip_defttl;
   112 /* dummy definitions used (temporarily?) for inpcb userspace port */
   114 /* called in sctp_usrreq.c */
   115 #define in6_sin_2_v4mapsin6(arg1, arg2) /* STUB */
   117 #endif

mercurial