Please wait until the page is fully downloaded and then press the "Expand" button or the blue line numbers.

0007001 /*
0007002 inet/inet.h
0007003 
0007004 Created:       Dec 30, 1991 by Philip Homburg
0007005 
0007006 Copyright 1995 Philip Homburg
0007007 */
0007008 
0007009 #ifndef INET__INET_H
0007010 #define INET__INET_H
0007011 
0007012 #define _SYSTEM       1       /* get OK and negative error codes */
At errno.h we read the comment:

The header defines the numbers of the various errors that can
occur during program execution. They are visible to user programs and
should be small positive integers. However, they are also used within
MINIX, where they must be negative. For example, the READ system call is
executed internally by calling do_read(). This function returns either a
(negative) error number or a (positive) number of bytes actually read.
To solve the problem of having the error numbers be negative inside the
the system and positive outside, the following mechanism is used. All the
definitions are are the form:

#define EPERM (_SIGN 1)

If the macro _SYSTEM is defined, then _SIGN is set to "-", otherwise it is
set to "". Thus when compiling the operating system, the macro _SYSTEM
will be defined, setting EPERM to (- 1), whereas when when this
file is included in an ordinary user program, EPERM has the value ( 1).

/* Now define _SIGN as "" or "-" depending on _SYSTEM. */
#ifdef _SYSTEM
# define _SIGN -
# define OK 0
#else
# define _SIGN
#endif




0007013 
0007014 #include <ansi.h>
0007015 
0007016 #define CRAMPED (_EM_WSIZE==2)       /* 64K code and data is quite cramped. */
0007017 #define ZERO 0       /* Used to comment out initialization code that does nothing. */
0007018 
0007019 #include <sys/types.h>
0007020 #include <errno.h>
0007021 #include <stddef.h>
0007022 #include <stdlib.h>
0007023 #include <string.h>
0007024 
0007025 #include <minix/config.h>
0007026 #include <minix/type.h>
0007027 #include <minix/const.h>
0007028 #include <minix/com.h>
0007029 #include <minix/syslib.h>
0007030 #include <net/hton.h>
0007031 #include <net/gen/ether.h>
0007032 #include <net/gen/eth_hdr.h>
0007033 #include <net/gen/eth_io.h>
0007034 #include <net/gen/in.h>
0007035 #include <net/gen/ip_hdr.h>
0007036 #include <net/gen/ip_io.h>
0007037 #include <net/gen/icmp.h>
0007038 #include <net/gen/icmp_hdr.h>
0007039 #include <net/gen/oneCsum.h>
0007040 #include <net/gen/psip_hdr.h>
0007041 #include <net/gen/psip_io.h>
0007042 #include <net/gen/route.h>
0007043 #include <net/gen/tcp.h>
0007044 #include <net/gen/tcp_hdr.h>
0007045 #include <net/gen/tcp_io.h>
0007046 #include <net/gen/udp.h>
0007047 #include <net/gen/udp_hdr.h>
0007048 #include <net/gen/udp_io.h>
0007049 #include <sys/ioctl.h>
0007050 
0007051 #include "const.h"
0007052 #include "inet_config.h"
0007053 
0007054 #define PUBLIC
0007055 #define EXTERN       extern
0007056 #define PRIVATE       static
0007057 #define FORWARD       static
0007058 
0007059 typedef int ioreq_t;
0007060 
0007061 #define THIS_FILE static char *this_file= __FILE__;
0007062 
0007063 #if CRAMPED
0007064 
0007065 /* Minimum panic info. */
0007066 #define ip_panic(print_list) panic(this_file, __LINE__)
0007067 _PROTOTYPE( void panic, (char *file, int line) );
0007068 
0007069 #else /* !CRAMPED */
0007070 
0007071 /* Maximum panic info. */
0007072 #define ip_panic(print_list) \
0007073          (panic0(this_file, __LINE__), printf print_list, panic())
0007074 _PROTOTYPE( void panic0, (char *file, int line) );
0007075 _PROTOTYPE( void panic, (void) );
0007076 
0007077 #endif /* !CRAMPED */
0007078 
0007079 #if DEBUG
0007080 #define ip_warning(print_list) \
0007081          ( \
0007082                   printf("warning at %s, %d: ", this_file, __LINE__), \
0007083                   printf print_list, \
0007084                   printf("\ninet stacktrace: "), \
0007085                   stacktrace() \
0007086          )
0007087 
0007088 #define DBLOCK(level, code) \
0007089          do { if ((level) & DEBUG) { where(); code; } } while(0)
0007090 #define DIFBLOCK(level, condition, code) \
0007091          do { if (((level) & DEBUG) && (condition)) \
0007092                   { where(); code; } } while(0)
0007093 
0007094 #else /* !DEBUG */
0007095 #define ip_warning(print_list)       0
0007096 #define DBLOCK(level, code)       0
0007097 #define DIFBLOCK(level, condition, code)       0
0007098 #endif
0007099 
0007100 #define ARGS(x) _ARGS(x)
0007101 
0007102 extern char version[];
0007103 extern int this_proc, synal_tasknr;
0007104 
0007105 void stacktrace ARGS(( void ));
0007106 
0007107 #endif /* INET__INET_H */
0007108 
0007109 /*
0007110  * $PchId: inet.h,v 1.8 1996/05/07 21:05:04 philip Exp $
0007111  */