Initial revision

This commit is contained in:
Ben Gras
2005-04-21 14:53:53 +00:00
commit 9865aeaa79
2264 changed files with 411685 additions and 0 deletions
+73
View File
@@ -0,0 +1,73 @@
/* net/gen/dhcp.h - DHCP packet format Author: Kees J. Bot
* 1 Dec 2000
*/
#ifndef __NET__GEN__DHCP_H__
#define __NET__GEN__DHCP_H__
typedef struct dhcp {
u8_t op; /* Message opcode/type. */
u8_t htype; /* Hardware address type. */
u8_t hlen; /* Hardware address length. */
u8_t hops; /* Hop count when relaying. */
u32_t xid; /* Transaction ID. */
u16_t secs; /* Seconds past since client began. */
u16_t flags; /* Flags. */
ipaddr_t ciaddr; /* Client IP address. */
ipaddr_t yiaddr; /* "Your" IP address. */
ipaddr_t siaddr; /* Boot server IP address. */
ipaddr_t giaddr; /* Relay agent (gateway) IP address. */
u8_t chaddr[16]; /* Client hardware address. */
u8_t sname[64]; /* Server host name. */
u8_t file[128]; /* Boot file. */
u32_t magic; /* Magic number. */
u8_t options[308]; /* Optional parameters. */
} dhcp_t;
/* DHCP operations and stuff: */
#define DHCP_BOOTREQUEST 1 /* Boot request message. */
#define DHCP_BOOTREPLY 2 /* Boot reply message. */
#define DHCP_HTYPE_ETH 1 /* Ethernet hardware type. */
#define DHCP_HLEN_ETH 6 /* Ethernet hardware address length. */
#define DHCP_FLAGS_BCAST 0x8000U /* Reply must be broadcast to client. */
/* "Magic" first four option bytes. */
#define DHCP_MAGIC HTONL(0x63825363UL)
/* DHCP common tags: */
#define DHCP_TAG_NETMASK 1 /* Netmask. */
#define DHCP_TAG_GATEWAY 3 /* Gateway list. */
#define DHCP_TAG_DNS 6 /* DNS Nameserver list. */
#define DHCP_TAG_HOSTNAME 12 /* Host name. */
#define DHCP_TAG_DOMAIN 15 /* Domain. */
#define DHCP_TAG_IPMTU 26 /* Interface MTU. */
/* DHCP protocol tags: */
#define DHCP_TAG_REQIP 50 /* Request this IP. */
#define DHCP_TAG_LEASE 51 /* Lease time requested/offered. */
#define DHCP_TAG_OVERLOAD 52 /* Options continued in file/sname. */
#define DHCP_TAG_TYPE 53 /* DHCP message (values below). */
#define DHCP_TAG_SERVERID 54 /* Server identifier. */
#define DHCP_TAG_REQPAR 55 /* Parameters requested. */
#define DHCP_TAG_MESSAGE 56 /* Error message. */
#define DHCP_TAG_MAXDHCP 57 /* Max DHCP packet size. */
#define DHCP_TAG_RENEWAL 58 /* Time to go into renewal state. */
#define DHCP_TAG_REBINDING 59 /* Time to go into rebinding state. */
#define DHCP_TAG_CLASSID 60 /* Class identifier. */
#define DHCP_TAG_CLIENTID 61 /* Client identifier. */
/* DHCP messages: */
#define DHCP_DISCOVER 1 /* Locate available servers. */
#define DHCP_OFFER 2 /* Parameters offered to client. */
#define DHCP_REQUEST 3 /* (Re)request offered parameters. */
#define DHCP_DECLINE 4 /* Client declines offer. */
#define DHCP_ACK 5 /* Server acknowlegdes request. */
#define DHCP_NAK 6 /* Server denies request. */
#define DHCP_RELEASE 7 /* Client relinguishes address. */
#define DHCP_INFORM 8 /* Client requests just local config. */
void dhcp_init(dhcp_t *_dp);
int dhcp_settag(dhcp_t *_dp, int _tag, void *_data, size_t _len);
int dhcp_gettag(dhcp_t *_dp, int _searchtag, u8_t **_pdata, size_t *_plen);
#endif /* __NET__GEN__DHCP_H__ */
+59
View File
@@ -0,0 +1,59 @@
/*
emu.h - bsd sockets lookalike interface
*/
#ifndef __EMU_H__
#define __EMU_H__
typedef int socklen_t;
typedef int sa_family_t;
typedef int in_port_t;
typedef unsigned long sin_addr_t;
typedef unsigned long in_addr_t;
/* generic socket address */
struct sockaddr {
unsigned char sa_len; /* total address size */
sa_family_t sa_family; /* address type (family) */
char sa_data[14]; /* family-dependent addr (may be longer) */
};
struct in_addr {
in_addr_t s_addr;
};
/* internet-domain (AF_INET) socket address */
struct sockaddr_in {
unsigned char sin_len;
sa_family_t sin_family;
in_port_t sin_port;
struct in_addr sin_addr;
char sin_zero[8];
};
/* type argument to socket() */
#define SOCK_STREAM 2
#define SOCK_DGRAM 3
/* protocol argument to socket() */
#define IPPROTO_ICMP 1
#define IPPROTO_TCP 6
#define IPPROTO_UDP 17
/* 2nd args to shutdown() */
#define SHUT_RD 0
#define SHUT_WR 1
#define SHUT_RDWR 2
/* bsd-lookalike functions */
int socket(int, int, int);
int bind(int, struct sockaddr *, socklen_t);
int listen(int, int);
int shutdown(int, int);
int connect(int, struct sockaddr *, socklen_t);
int recv(int s, void *buf, size_t len, int flags);
int send(int s, void *buf, size_t len, int flags);
#endif /* __EMU_H__ */
+15
View File
@@ -0,0 +1,15 @@
/*
server/ip/gen/eth_hdr.h
*/
#ifndef __SERVER__IP__GEN__ETH_HDR_H__
#define __SERVER__IP__GEN__ETH_HDR_H__
typedef struct eth_hdr
{
ether_addr_t eh_dst;
ether_addr_t eh_src;
ether_type_t eh_proto;
} eth_hdr_t;
#endif /* __SERVER__IP__GEN__ETH_HDR_H__ */
+79
View File
@@ -0,0 +1,79 @@
/*
server/gen/ip/eth_io.h
*/
#ifndef __SERVER__IP__GEN__ETH_IO_H__
#define __SERVER__IP__GEN__ETH_IO_H__
typedef struct nwio_ethopt
{
u32_t nweo_flags;
ether_addr_t nweo_multi, nweo_rem;
ether_type_t nweo_type;
} nwio_ethopt_t;
#define NWEO_NOFLAGS 0x0000L
#define NWEO_ACC_MASK 0x0003L
# define NWEO_EXCL 0x00000001L
# define NWEO_SHARED 0x00000002L
# define NWEO_COPY 0x00000003L
#define NWEO_LOC_MASK 0x0010L
# define NWEO_EN_LOC 0x00000010L
# define NWEO_DI_LOC 0x00100000L
#define NWEO_BROAD_MASK 0x0020L
# define NWEO_EN_BROAD 0x00000020L
# define NWEO_DI_BROAD 0x00200000L
#define NWEO_MULTI_MASK 0x0040L
# define NWEO_EN_MULTI 0x00000040L
# define NWEO_DI_MULTI 0x00400000L
#define NWEO_PROMISC_MASK 0x0080L
# define NWEO_EN_PROMISC 0x00000080L
# define NWEO_DI_PROMISC 0x00800000L
#define NWEO_REM_MASK 0x0100L
# define NWEO_REMSPEC 0x00000100L
# define NWEO_REMANY 0x01000000L
#define NWEO_TYPE_MASK 0x0200L
# define NWEO_TYPESPEC 0x00000200L
# define NWEO_TYPEANY 0x02000000L
#define NWEO_RW_MASK 0x1000L
# define NWEO_RWDATONLY 0x00001000L
# define NWEO_RWDATALL 0x10000000L
typedef struct eth_stat
{
unsigned long ets_recvErr, /* # receive errors */
ets_sendErr, /* # send error */
ets_OVW, /* # buffer overwrite warnings,
(packets arrive faster than
can be processed) */
ets_CRCerr, /* # crc errors of read */
ets_frameAll, /* # frames not alligned (# bits
not a mutiple of 8) */
ets_missedP, /* # packets missed due to too
slow packet processing */
ets_packetR, /* # packets received */
ets_packetT, /* # packets transmitted */
ets_transDef, /* # transmission defered (there
was a transmission of an
other station in progress */
ets_collision, /* # collissions */
ets_transAb, /* # transmissions aborted due
to accesive collisions */
ets_carrSense, /* # carrier sense lost */
ets_fifoUnder, /* # fifo underruns (processor
is too busy) */
ets_fifoOver, /* # fifo overruns (processor is
too busy) */
ets_CDheartbeat, /* # times unable to transmit
collision signal */
ets_OWC; /* # times out of window
collision */
} eth_stat_t;
typedef struct nwio_ethstat
{
ether_addr_t nwes_addr;
eth_stat_t nwes_stat;
} nwio_ethstat_t;
#endif /* __SERVER__IP__GEN__ETH_IO_H__ */
+25
View File
@@ -0,0 +1,25 @@
/*
server/ip/gen/ether.h
*/
#ifndef __SERVER__IP__GEN__ETHER_H__
#define __SERVER__IP__GEN__ETHER_H__
#define ETH_MIN_PACK_SIZE 60
#define ETH_MAX_PACK_SIZE 1514
#define ETH_MAX_PACK_SIZE_TAGGED 1518
#define ETH_HDR_SIZE 14
#define ETH_CRC_SIZE 4
typedef struct ether_addr
{
u8_t ea_addr[6];
} ether_addr_t;
typedef u16_t ether_type_t;
typedef U16_t Ether_type_t;
#define ETH_ARP_PROTO 0x806
#define ETH_IP_PROTO 0x800
#endif /* __SERVER__IP__GEN__ETHER_H__ */
+40
View File
@@ -0,0 +1,40 @@
/*
server/ip/gen/icmp.h
*/
#ifndef __SERVER__IP__GEN__ICMP_H__
#define __SERVER__IP__GEN__ICMP_H__
#define ICMP_MIN_HDR_LEN 4
#define ICMP_TYPE_ECHO_REPL 0
#define ICMP_TYPE_DST_UNRCH 3
# define ICMP_NET_UNRCH 0
# define ICMP_HOST_UNRCH 1
# define ICMP_PROTOCOL_UNRCH 2
# define ICMP_PORT_UNRCH 3
# define ICMP_FRAGM_AND_DF 4
# define ICMP_SOURCE_ROUTE_FAILED 5
#define ICMP_TYPE_SRC_QUENCH 4
#define ICMP_TYPE_REDIRECT 5
# define ICMP_REDIRECT_NET 0
# define ICMP_REDIRECT_HOST 1
# define ICMP_REDIRECT_TOS_AND_NET 2
# define ICMP_REDIRECT_TOS_AND_HOST 3
#define ICMP_TYPE_ECHO_REQ 8
#define ICMP_TYPE_ROUTER_ADVER 9
#define ICMP_TYPE_ROUTE_SOL 10
#define ICMP_TYPE_TIME_EXCEEDED 11
# define ICMP_TTL_EXC 0
# define ICMP_FRAG_REASSEM 1
#define ICMP_TYPE_PARAM_PROBLEM 12
#define ICMP_TYPE_TS_REQ 13
#define ICMP_TYPE_TS_REPL 14
#define ICMP_TYPE_INFO_REQ 15
#define ICMP_TYPE_INFO_REPL 16
#endif /* __SERVER__IP__GEN__ICMP_H__ */
/*
* $PchId: icmp.h,v 1.5 1995/11/17 22:38:46 philip Exp $
*/
+55
View File
@@ -0,0 +1,55 @@
/*
server/ip/gen/icmp_hdr.h
*/
#ifndef __SERVER__IP__GEN__ICMP_HDR_H__
#define __SERVER__IP__GEN__ICMP_HDR_H__
typedef struct icmp_id_seq
{
u16_t iis_id, iis_seq;
} icmp_id_seq_t;
typedef struct icmp_ip_id
{
ip_hdr_t iii_hdr;
/* ip_hdr_options and 64 bytes of data */
} icmp_ip_id_t;
typedef struct icmp_ram /* RFC 1256 */
{
u8_t iram_na;
u8_t iram_aes;
u16_t iram_lt;
} icmp_ram_t;
typedef struct icmp_pp
{
u8_t ipp_ptr;
u8_t ipp_unused[3];
} icmp_pp_t;
typedef struct icmp_hdr
{
u8_t ih_type, ih_code;
u16_t ih_chksum;
union
{
u32_t ihh_unused;
icmp_id_seq_t ihh_idseq;
ipaddr_t ihh_gateway;
icmp_ram_t ihh_ram;
icmp_pp_t ihh_pp;
} ih_hun;
union
{
icmp_ip_id_t ihd_ipid;
u8_t uhd_data[1];
} ih_dun;
} icmp_hdr_t;
#endif /* __SERVER__IP__GEN__ICMP_HDR_H__ */
/*
* $PchId: icmp_hdr.h,v 1.4 1995/11/17 22:28:58 philip Exp $
*/
+18
View File
@@ -0,0 +1,18 @@
/*
server/ip/gen/if_ether.h
*/
#ifndef __SERVER__IP__GEN__IF_ETHER_H__
#define __SERVER__IP__GEN__IF_ETHER_H__
struct ether_addr;
#define _PATH_ETHERS "/etc/ethers"
char *ether_ntoa _ARGS(( struct ether_addr *e ));
struct ether_addr *ether_aton _ARGS(( const char *s ));
int ether_ntohost _ARGS(( char *hostname, struct ether_addr *e ));
int ether_hostton _ARGS(( char *hostname, struct ether_addr *e ));
int ether_line _ARGS(( char *l, struct ether_addr *e, char *hostname ));
#endif /* __SERVER__IP__GEN__IF_ETHER_H__ */
+33
View File
@@ -0,0 +1,33 @@
/*
server/ip/gen/in.h
*/
#ifndef __SERVER__IP__GEN__IN_H__
#define __SERVER__IP__GEN__IN_H__
#define IP_MIN_HDR_SIZE 20
#define IP_MAX_HDR_SIZE 60 /* 15 * 4 */
#define IP_VERSION 4
#define IP_MAX_TTL 255
#define IP_DEF_MSS 576
#define IP_MAX_PACKSIZE 40000 /* 8192 */
/* Note: this restriction is not part of the IP-protocol but
introduced by this implementation. */
#define IPPROTO_ICMP 1
#define IPPROTO_TCP 6
#define IPPROTO_UDP 17
typedef u32_t ipaddr_t;
typedef u8_t ipproto_t;
typedef struct ip_hdropt
{
u8_t iho_opt_siz;
u8_t iho_data[IP_MAX_HDR_SIZE-IP_MIN_HDR_SIZE];
} ip_hdropt_t;
#endif /* __SERVER__IP__GEN__IN_H__ */
/*
* $PchId: in.h,v 1.3 1995/11/17 22:27:50 philip Exp $
*/
+13
View File
@@ -0,0 +1,13 @@
/*
server/ip/gen/inet.h
*/
#ifndef __SERVER__IP__GEN__INET_H__
#define __SERVER__IP__GEN__INET_H__
ipaddr_t inet_addr _ARGS(( const char *addr ));
ipaddr_t inet_network _ARGS(( const char *addr ));
char *inet_ntoa _ARGS(( ipaddr_t addr ));
int inet_aton _ARGS(( const char *cp, ipaddr_t *pin ));
#endif /* __SERVER__IP__GEN__INET_H__ */
+42
View File
@@ -0,0 +1,42 @@
/*
server/ip/gen/ip_hdr.h
*/
#ifndef __SERVER__IP__GEN__HDR_H__
#define __SERVER__IP__GEN__HDR_H__
typedef struct ip_hdr
{
u8_t ih_vers_ihl,
ih_tos;
u16_t ih_length,
ih_id,
ih_flags_fragoff;
u8_t ih_ttl,
ih_proto;
u16_t ih_hdr_chk;
ipaddr_t ih_src,
ih_dst;
} ip_hdr_t;
#define IH_IHL_MASK 0xf
#define IH_VERSION_MASK 0xf
#define IH_FRAGOFF_MASK 0x1fff
#define IH_MORE_FRAGS 0x2000
#define IH_DONT_FRAG 0x4000
#define IH_FLAGS_UNUSED 0x8000
#define IP_OPT_COPIED 0x80
#define IP_OPT_NUMBER 0x1f
#define IP_OPT_EOL 0x00
#define IP_OPT_NOP 0x01
#define IP_OPT_LSRR 0x83
#define IP_OPT_RR 0x07
#define IP_OPT_RR_MIN 4
#endif /* __SERVER__IP__GEN__HDR_H__ */
/*
* $PchId: ip_hdr.h,v 1.4 1995/11/17 22:26:00 philip Exp $
*/
+55
View File
@@ -0,0 +1,55 @@
/*
server/ip/gen/ip_io.h
*/
#ifndef __SERVER__IP__GEN__IP_IO_H__
#define __SERVER__IP__GEN__IP_IO_H__
typedef struct nwio_ipconf
{
u32_t nwic_flags;
ipaddr_t nwic_ipaddr;
ipaddr_t nwic_netmask;
} nwio_ipconf_t;
#define NWIC_NOFLAGS 0x0
#define NWIC_FLAGS 0x3
# define NWIC_IPADDR_SET 0x1
# define NWIC_NETMASK_SET 0x2
typedef struct nwio_ipopt
{
u32_t nwio_flags;
ipaddr_t nwio_rem;
ip_hdropt_t nwio_hdropt;
u8_t nwio_tos;
u8_t nwio_ttl;
u8_t nwio_df;
ipproto_t nwio_proto;
} nwio_ipopt_t;
#define NWIO_NOFLAGS 0x0000l
#define NWIO_ACC_MASK 0x0003l
# define NWIO_EXCL 0x00000001l
# define NWIO_SHARED 0x00000002l
# define NWIO_COPY 0x00000003l
#define NWIO_LOC_MASK 0x0010l
# define NWIO_EN_LOC 0x00000010l
# define NWIO_DI_LOC 0x00100000l
#define NWIO_BROAD_MASK 0x0020l
# define NWIO_EN_BROAD 0x00000020l
# define NWIO_DI_BROAD 0x00200000l
#define NWIO_REM_MASK 0x0100l
# define NWIO_REMSPEC 0x00000100l
# define NWIO_REMANY 0x01000000l
#define NWIO_PROTO_MASK 0x0200l
# define NWIO_PROTOSPEC 0x00000200l
# define NWIO_PROTOANY 0x02000000l
#define NWIO_HDR_O_MASK 0x0400l
# define NWIO_HDR_O_SPEC 0x00000400l
# define NWIO_HDR_O_ANY 0x04000000l
#define NWIO_RW_MASK 0x1000l
# define NWIO_RWDATONLY 0x00001000l
# define NWIO_RWDATALL 0x10000000l
#endif /* __SERVER__IP__GEN__IP_IO_H__ */
+124
View File
@@ -0,0 +1,124 @@
/*
* Copyright (c) 1983, 1989 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that: (1) source distributions retain this entire copyright
* notice and comment, and (2) distributions including binaries display
* the following acknowledgement: ``This product includes software
* developed by the University of California, Berkeley and its contributors''
* in the documentation or other materials provided with the distribution
* and in all advertising materials mentioning features or use of this
* software. Neither the name of the University nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* @(#)nameser.h 5.24 (Berkeley) 6/1/90
*/
/*
server/ip/gen/nameser.h
Created Sept 18, 1991 by Philip Homburg
*/
#ifndef __SERVER__IP__GEN__NAEMSER_H__
#define __SERVER__IP__GEN__NAEMSER_H__
typedef struct dns_hdr
{
u16_t dh_id;
u8_t dh_flag1;
u8_t dh_flag2;
u16_t dh_qdcount;
u16_t dh_ancount;
u16_t dh_nscount;
u16_t dh_arcount;
} dns_hdr_t;
#define DHF_QR 0x80
#define DHF_OPCODE 0x78
#define DHF_AA 0x04
#define DHF_TC 0x02
#define DHF_RD 0x01
#define DHF_RA 0x80
#define DHF_PR 0x40
#define DHF_UNUSED 0x30
#define DHF_RCODE 0x0F
/*
Define constants based on rfc883
*/
#define PACKETSZ 512 /* maximum packet size */
#define MAXDNAME 256 /* maximum domain name */
#define MAXCDNAME 255 /* maximum compressed domain name */
#define MAXLABEL 63 /* maximum length of domain label */
/* Number of bytes of fixed size data in query structure */
#define QFIXEDSZ 4
/* number of bytes of fixed size data in resource record */
#define RRFIXEDSZ 10
#define INDIR_MASK 0xc0
/* Defines for handling compressed domain names */
/*
Opcodes for DNS
*/
#define QUERY 0x0 /* standard query */
#define IQUERY 0x1 /* inverse query */
/*
Error codes
*/
#define NOERROR 0 /* no error */
#define FORMERR 1 /* format error */
#define SERVFAIL 2 /* server failure */
#define NXDOMAIN 3 /* non existent domain */
#define NOTIMP 4 /* not implemented */
#define REFUSED 5 /* query refused */
/* non standard */
#define NOCHANGE 0xf /* update failed to change db */
/* Valid types */
#define T_A 1 /* host address */
#define T_NS 2 /* authoritative server */
#define T_MD 3 /* mail destination */
#define T_MF 4 /* mail forwarder */
#define T_CNAME 5 /* connonical name */
#define T_SOA 6 /* start of authority zone */
#define T_MB 7 /* mailbox domain name */
#define T_MG 8 /* mail group member */
#define T_MR 9 /* mail rename name */
#define T_NULL 10 /* null resource record */
#define T_WKS 11 /* well known service */
#define T_PTR 12 /* domain name pointer */
#define T_HINFO 13 /* host information */
#define T_MINFO 14 /* mailbox information */
#define T_MX 15 /* mail routing information */
#define T_TXT 16 /* text strings */
/* non standard */
#define T_UINFO 100 /* user (finger) information */
#define T_UID 101 /* user ID */
#define T_GID 102 /* group ID */
#define T_UNSPEC 103 /* Unspecified format (binary data) */
/* Query type values which do not appear in resource records */
#define T_AXFR 252 /* transfer zone of authority */
#define T_MAILB 253 /* transfer mailbox records */
#define T_MAILA 254 /* transfer mail agent records */
#define T_ANY 255 /* wildcard match */
/* Valid classes */
#define C_IN 1 /* the internet */
#define C_CHAOS 3 /* for chaos net (MIT) */
#define C_HS 4 /* for Hesiod name server at MIT */
#define C_ANY 255 /* wildcard */
#endif /* __SERVER__IP__GEN__NAEMSER_H__ */
+128
View File
@@ -0,0 +1,128 @@
/*-
* Copyright (c) 1980, 1983, 1988 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)netdb.h 5.15 (Berkeley) 4/3/91
*/
#ifndef _NETDB_H_
#define _NETDB_H_
#define _PATH_HEQUIV "/etc/hosts.equiv"
#define _PATH_HOSTS "/etc/hosts"
#define _PATH_NETWORKS "/etc/networks"
#define _PATH_PROTOCOLS "/etc/protocols"
#define _PATH_SERVICES "/etc/services"
#define _PATH_SERVACCES "/etc/serv.access"
/*
* Structures returned by network data base library. All addresses are
* supplied in host order, and returned in network order (suitable for
* use in system calls).
*/
struct hostent {
char *h_name; /* official name of host */
char **h_aliases; /* alias list */
int h_addrtype; /* host address type */
int h_length; /* length of address */
char **h_addr_list; /* list of addresses from name server */
#define h_addr h_addr_list[0] /* address, for backward compatiblity */
};
/*
* Assumption here is that a network number
* fits in 32 bits -- probably a poor one.
*/
struct netent {
char *n_name; /* official name of net */
char **n_aliases; /* alias list */
int n_addrtype; /* net address type */
unsigned long n_net; /* network # */
};
struct servent {
char *s_name; /* official service name */
char **s_aliases; /* alias list */
int s_port; /* port # */
char *s_proto; /* protocol to use */
};
struct protoent {
char *p_name; /* official protocol name */
char **p_aliases; /* alias list */
int p_proto; /* protocol # */
};
/*
* Error return codes from gethostbyname() and gethostbyaddr()
* (left in extern int h_errno).
*/
extern int h_errno;
#define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */
#define TRY_AGAIN 2 /* Non-Authoritive Host not found, or SERVERFAIL */
#define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
#define NO_DATA 4 /* Valid name, no data record of requested type */
#define NO_ADDRESS NO_DATA /* no address, look for MX record */
#ifndef _ANSI_H
#include <ansi.h>
#endif
void endhostent _ARGS((void));
void endnetent _ARGS((void));
void endprotoent _ARGS((void));
void endservent _ARGS((void));
struct hostent *gethostbyaddr _ARGS((const char *, int, int));
struct hostent *gethostbyname _ARGS((const char *));
struct hostent *gethostent _ARGS((void));
struct netent *getnetbyaddr _ARGS((long, int)); /* u_long? */
struct netent *getnetbyname _ARGS((const char *));
struct netent *getnetent _ARGS((void));
struct protoent *getprotobyname _ARGS((const char *));
struct protoent *getprotobynumber _ARGS((int));
struct protoent *getprotoent _ARGS((void));
struct servent *getservbyname _ARGS((const char *, const char *));
struct servent *getservbyport _ARGS((int, const char *));
struct servent *getservent _ARGS((void));
void herror _ARGS((const char *));
void sethostent _ARGS((int));
/* void sethostfile _ARGS((const char *)); */
void setnetent _ARGS((int));
void setprotoent _ARGS((int));
void setservent _ARGS((int));
#ifdef _MINIX
int servxcheck _ARGS((unsigned long _peer, const char *_service,
void (*_logf) _ARGS((int _pass, const char *_name))));
char *servxfile _ARGS((const char *_file));
#endif
#endif /* !_NETDB_H_ */
+10
View File
@@ -0,0 +1,10 @@
/*
server/ip/gen/oneCsum.h
*/
#ifndef __SERVER__IP__GEN__ONECSUM_H__
#define __SERVER__IP__GEN__ONECSUM_H__
u16_t oneC_sum _ARGS(( U16_t prev, void *data, size_t data_len ));
#endif /* __SERVER__IP__GEN__ONECSUM_H__ */
+22
View File
@@ -0,0 +1,22 @@
/*
server/ip/gen/psip_hdr.h
*/
#ifndef __SERVER__IP__GEN__PSIP_HDR_H__
#define __SERVER__IP__GEN__PSIP_HDR_H__
typedef struct psip_io_hdr
{
u8_t pih_flags;
u8_t pih_dummy[3];
} psip_io_hdr_t;
#define PF_LOC_REM_MASK 1
#define PF_LOC2REM 0
#define PF_REM2LOC 1
#endif /* __SERVER__IP__GEN__PSIP_HDR_H__ */
/*
* $PchId: psip_hdr.h,v 1.2 1995/11/17 22:22:35 philip Exp $
*/
+21
View File
@@ -0,0 +1,21 @@
/*
server/ip/gen/psip_io.h
*/
#ifndef __SERVER__IP__GEN__PSIP_IO_H__
#define __SERVER__IP__GEN__PSIP_IO_H__
typedef struct nwio_psipopt
{
unsigned long nwpo_flags;
} nwio_psipopt_t;
#define NWPO_PROMISC_MASK 0x0001L
#define NWPO_EN_PROMISC 0x00000001L
#define NWUO_DI_PROMISC 0x00010000L
#endif /* __SERVER__IP__GEN__PSIP_IO_H__ */
/*
* $PchId: psip_io.h,v 1.2 1995/11/17 22:22:16 philip Exp $
*/
+107
View File
@@ -0,0 +1,107 @@
/*
* Copyright (c) 1983, 1987, 1989 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that: (1) source distributions retain this entire copyright
* notice and comment, and (2) distributions including binaries display
* the following acknowledgement: ``This product includes software
* developed by the University of California, Berkeley and its contributors''
* in the documentation or other materials provided with the distribution
* and in all advertising materials mentioning features or use of this
* software. Neither the name of the University nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* @(#)resolv.h 5.10 (Berkeley) 6/1/90
*/
#ifndef _NET__GEN__RESOLV_H
#define _NET__GEN__RESOLV_H
/*
* Resolver configuration file.
* Normally not present, but may contain the address of the
* inital name server(s) to query and the domain search list.
*/
#ifndef _PATH_RESCONF
#define _PATH_RESCONF "/etc/resolv.conf"
#endif
/*
* Global defines and variables for resolver stub.
*/
#define MAXNS 3 /* max # name servers we'll track */
#define MAXDFLSRCH 3 /* # default domain levels to try */
#define MAXDNSRCH 6 /* max # domains in search path */
#define LOCALDOMAINPARTS 2 /* min levels in name that is "local" */
#define RES_TIMEOUT 5 /* min. seconds between retries */
#define NAMESERVER_PORT 53
struct state {
int retrans; /* retransmition time interval */
int retry; /* number of times to retransmit */
long options; /* option flags - see below. */
int nscount; /* number of name servers */
ipaddr_t nsaddr_list[MAXNS]; /* address of name server */
#define nsaddr nsaddr_list[0] /* for backward compatibility */
u16_t nsport_list[MAXNS]; /* port of name server */
u16_t id; /* current packet id */
char defdname[MAXDNAME]; /* default domain */
char *dnsrch[MAXDNSRCH+1]; /* components of domain to search */
};
/*
* Resolver options
*/
#define RES_INIT 0x0001 /* address initialized */
#define RES_DEBUG 0x0002 /* print debug messages */
#define RES_AAONLY 0x0004 /* authoritative answers only */
#define RES_USEVC 0x0008 /* use virtual circuit */
#define RES_PRIMARY 0x0010 /* query primary server only */
#define RES_IGNTC 0x0020 /* ignore trucation errors */
#define RES_RECURSE 0x0040 /* recursion desired */
#define RES_DEFNAMES 0x0080 /* use default domain name */
#define RES_STAYOPEN 0x0100 /* Keep TCP socket open */
#define RES_DNSRCH 0x0200 /* search up local domain tree */
#define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | RES_DNSRCH )
extern struct state _res;
struct rrec;
int res_init _ARGS(( void ));
int res_mkquery _ARGS(( int op, const char *dname, int class, int type,
const char *data, int datalen, const struct rrec *newrr,
char *buf, int buflen ));
int res_query _ARGS(( char *name, int class, int type, u8_t *answer,
int anslen ));
int res_querydomain _ARGS(( char *name, char *domain, int class, int type,
u8_t *answer, int anslen ));
int res_search _ARGS(( char *name, int class, int type, u8_t *answer,
int anslen ));
int res_send _ARGS(( const char *buf, int buflen, char *answer, int anslen ));
void _res_close _ARGS(( void ));
int dn_comp _ARGS(( const u8_t *exp_dn, u8_t *comp_dn, int length,
u8_t **dnptrs, u8_t **lastdnptr ));
int dn_expand _ARGS(( const u8_t *msg, const u8_t *eomorig,
const u8_t *comp_dn, u8_t *exp_dn, int length ));
int dn_skipname _ARGS(( const u8_t *comp_dn, const u8_t *eom ));
char *__hostalias _ARGS(( const char *name ));
u16_t _getshort _ARGS(( const u8_t *msgp ));
u32_t _getlong _ARGS(( const u8_t *msgp ));
void __putshort _ARGS(( U16_t s, u8_t *msgp ));
void __putlong _ARGS(( u32_t l, u8_t *msgp ));
void p_query _ARGS(( char *msg ));
#endif /* _NET__GEN__RESOLV_H */
+77
View File
@@ -0,0 +1,77 @@
/*
net/gen/rip.h
Definitions for the Routing Information Protocol (RFC-1058).
Created: Aug 16, 1993 by Philip Homburg <philip@cs.vu.nl>
*/
#ifndef NET__GEN__RIP_H
#define NET__GEN__RIP_H
typedef struct rip_hdr
{
u8_t rh_command;
u8_t rh_version;
u16_t rh_zero;
} rip_hdr_t;
#define RHC_REQUEST 1
#define RHC_RESPONSE 2
#define RIP_ENTRY_MAX 25
typedef struct rip_entry
{
union
{
struct rip_entry_v1
{
u16_t re_family;
u16_t re_zero0;
u32_t re_address;
u32_t re_zero1;
u32_t re_zero2;
u32_t re_metric;
} v1;
struct rip_entry_v2
{
u16_t re_family;
u16_t re_tag;
u32_t re_address;
u32_t re_mask;
u32_t re_nexthop;
u32_t re_metric;
} v2;
} u;
} rip_entry_t;
#define RIP_FAMILY_IP 2
#define RIP_INFINITY 16
#define RIP_UDP_PORT 520
#define RIP_PERIOD 30 /* A responce is sent once every
* RIP_PERIOD seconds
*/
#define RIP_FUZZ 10 /* The actual value used is RIP_FREQUENCE -
* a random number of at most RIP_FUZZ.
*/
#define RIP_TIMEOUT 180 /* A route is dead after RIP_TIMEOUT seconds */
#define RIP_DELETE_TO 120 /* A dead route is removed after RIP_DELETE_TO
* seconds
*/
#ifdef __RIP_DEBUG
#undef RIP_PERIOD
#define RIP_PERIOD 15
#undef RIP_TIMEOUT
#define RIP_TIMEOUT 10
#undef RIP_DELETE_TO
#define RIP_DELETE_TO 10
#endif /* __RIP_DEBUG */
#endif /* NET__GEN__RIP_H */
/*
* $PchId: rip.h,v 1.3 1995/11/17 22:21:16 philip Exp $
*/
+31
View File
@@ -0,0 +1,31 @@
/*
server/ip/gen/route.h
*/
#ifndef __SERVER__IP__GEN__ROUTE_H__
#define __SERVER__IP__GEN__ROUTE_H__
typedef struct nwio_route
{
u32_t nwr_ent_no;
u32_t nwr_ent_count;
ipaddr_t nwr_dest;
ipaddr_t nwr_netmask;
ipaddr_t nwr_gateway;
u32_t nwr_dist;
u32_t nwr_flags;
u32_t nwr_pref;
u32_t nwr_mtu; /* Ignored, compatibility with VMD */
ipaddr_t nwr_ifaddr;
} nwio_route_t;
#define NWRF_EMPTY 0
#define NWRF_INUSE 1
#define NWRF_STATIC 2
#define NWRF_UNREACHABLE 4
#endif /* __SERVER__IP__GEN__ROUTE_H__ */
/*
* $PchId: route.h,v 1.3 1995/11/17 22:19:50 philip Exp $
*/
+41
View File
@@ -0,0 +1,41 @@
/*
server/ip/gen/socket.h
*/
#ifndef __SERVER__IP__GEN__SOCKET_H__
#define __SERVER__IP__GEN__SOCKET_H__
/* From SunOS: /usr/include/sys/socketh */
/*
* Address families.
*/
#define AF_UNSPEC 0 /* unspecified */
#define AF_UNIX 1 /* local to host (pipes, portals) */
#define AF_INET 2 /* internetwork: UDP, TCP, etc. */
#define AF_IMPLINK 3 /* arpanet imp addresses */
#define AF_PUP 4 /* pup protocols: e.g. BSP */
#define AF_CHAOS 5 /* mit CHAOS protocols */
#define AF_NS 6 /* XEROX NS protocols */
#define AF_NBS 7 /* nbs protocols */
#define AF_ECMA 8 /* european computer manufacturers */
#define AF_DATAKIT 9 /* datakit protocols */
#define AF_CCITT 10 /* CCITT protocols, X.25 etc */
#define AF_SNA 11 /* IBM SNA */
#define AF_DECnet 12 /* DECnet */
#define AF_DLI 13 /* Direct data link interface */
#define AF_LAT 14 /* LAT */
#define AF_HYLINK 15 /* NSC Hyperchannel */
#define AF_APPLETALK 16 /* Apple Talk */
#define AF_NIT 17 /* Network Interface Tap */
#define AF_802 18 /* IEEE 802.2, also ISO 8802 */
#define AF_OSI 19 /* umbrella for all families used
* by OSI (e.g. protosw lookup) */
#define AF_X25 20 /* CCITT X.25 in particular */
#define AF_OSINET 21 /* AFI = 47, IDI = 4 */
#define AF_GOSIP 22 /* U.S. Government OSI */
#define AF_MAX 21
#endif /* __SERVER__IP__GEN__SOCKET_H__ */
+19
View File
@@ -0,0 +1,19 @@
/*
server/ip/gen/tcp.h
*/
#ifndef __SERVER__IP__GEN__TCP_H__
#define __SERVER__IP__GEN__TCP_H__
#define TCP_MIN_HDR_SIZE 20
#define TCP_MAX_HDR_SIZE 60
#define TCPPORT_TELNET 23
#define TCPPORT_FINGER 79
#define TCPPORT_RESERVED 1024
typedef u16_t tcpport_t;
typedef U16_t Tcpport_t; /* for use in prototypes */
#endif /* __SERVER__IP__GEN__TCP_H__ */
+45
View File
@@ -0,0 +1,45 @@
/*
server/ip/gen/tcp_hdr.h
*/
#ifndef __SERVER__IP__GEN__TCP_HDR_H__
#define __SERVER__IP__GEN__TCP_HDR_H__
typedef struct tcp_hdr
{
tcpport_t th_srcport;
tcpport_t th_dstport;
u32_t th_seq_nr;
u32_t th_ack_nr;
u8_t th_data_off;
u8_t th_flags;
u16_t th_window;
u16_t th_chksum;
u16_t th_urgptr;
} tcp_hdr_t;
#define TH_DO_MASK 0xf0
#define TH_FLAGS_MASK 0x3f
#define THF_FIN 0x1
#define THF_SYN 0x2
#define THF_RST 0x4
#define THF_PSH 0x8
#define THF_ACK 0x10
#define THF_URG 0x20
typedef struct tcp_hdropt
{
int tho_opt_siz;
u8_t tho_data[TCP_MAX_HDR_SIZE-TCP_MIN_HDR_SIZE];
} tcp_hdropt_t;
#define TCP_OPT_EOL 0
#define TCP_OPT_NOP 1
#define TCP_OPT_MSS 2
#endif /* __SERVER__IP__GEN__TCP_HDR_H__ */
/*
* $PchId: tcp_hdr.h,v 1.3 1995/11/17 22:18:13 philip Exp $
*/
+66
View File
@@ -0,0 +1,66 @@
/*
server/ip/gen/tcp_io.h
*/
#ifndef __SERVER__IP__GEN__TCP_IO_H__
#define __SERVER__IP__GEN__TCP_IO_H__
typedef struct nwio_tcpconf
{
u32_t nwtc_flags;
ipaddr_t nwtc_locaddr;
ipaddr_t nwtc_remaddr;
tcpport_t nwtc_locport;
tcpport_t nwtc_remport;
} nwio_tcpconf_t;
#define NWTC_NOFLAGS 0x0000L
#define NWTC_ACC_MASK 0x0003L
# define NWTC_EXCL 0x00000001L
# define NWTC_SHARED 0x00000002L
# define NWTC_COPY 0x00000003L
#define NWTC_LOCPORT_MASK 0x0030L
# define NWTC_LP_UNSET 0x00000010L
# define NWTC_LP_SET 0x00000020L
# define NWTC_LP_SEL 0x00000030L
#define NWTC_REMADDR_MASK 0x0100L
# define NWTC_SET_RA 0x00000100L
# define NWTC_UNSET_RA 0x01000000L
#define NWTC_REMPORT_MASK 0x0200L
# define NWTC_SET_RP 0x00000200L
# define NWTC_UNSET_RP 0x02000000L
typedef struct nwio_tcpcl
{
long nwtcl_flags;
long nwtcl_ttl;
} nwio_tcpcl_t;
typedef struct nwio_tcpatt
{
long nwta_flags;
} nwio_tcpatt_t;
typedef struct nwio_tcpopt
{
u32_t nwto_flags;
} nwio_tcpopt_t;
#define NWTO_NOFLAG 0x0000L
#define NWTO_SND_URG_MASK 0x0001L
# define NWTO_SND_URG 0x00000001L
# define NWTO_SND_NOTURG 0x00010000L
#define NWTO_RCV_URG_MASK 0x0002L
# define NWTO_RCV_URG 0x00000002L
# define NWTO_RCV_NOTURG 0x00020000L
#define NWTO_BSD_URG_MASK 0x0004L
# define NWTO_BSD_URG 0x00000004L
# define NWTO_NOTBSD_URG 0x00040000L
#define NWTO_DEL_RST_MASK 0x0008L
# define NWTO_DEL_RST 0x00000008L
#endif /* __SERVER__IP__GEN__TCP_IO_H__ */
/*
* $PchId: tcp_io.h,v 1.4 1995/11/17 22:17:47 philip Exp $
*/
+14
View File
@@ -0,0 +1,14 @@
/*
server/ip/gen/udp.h
*/
#ifndef __SERVER__IP__GEN__UDP_H__
#define __SERVER__IP__GEN__UDP_H__
typedef u16_t udpport_t;
typedef U16_t Udpport_t;
#define UDP_HDR_SIZE 8
#define UDP_IO_HDR_SIZE 16
#endif /* __SERVER__IP__GEN__UDP_H__ */
+26
View File
@@ -0,0 +1,26 @@
/*
server/ip/gen/udp_hdr.h
*/
#ifndef __SERVER__IP__GEN__UDP_HDR_H__
#define __SERVER__IP__GEN__UDP_HDR_H__
typedef struct udp_hdr
{
udpport_t uh_src_port;
udpport_t uh_dst_port;
u16_t uh_length;
u16_t uh_chksum;
} udp_hdr_t;
typedef struct udp_io_hdr
{
ipaddr_t uih_src_addr;
ipaddr_t uih_dst_addr;
udpport_t uih_src_port;
udpport_t uih_dst_port;
u16_t uih_ip_opt_len;
u16_t uih_data_len;
} udp_io_hdr_t;
#endif /* __SERVER__IP__GEN__UDP_HDR_H__ */
+45
View File
@@ -0,0 +1,45 @@
/*
server/ip/gen/udp_io.h
*/
#ifndef __SERVER__IP__GEN__UDP_IO_H__
#define __SERVER__IP__GEN__UDP_IO_H__
typedef struct nwio_udpopt
{
unsigned long nwuo_flags;
udpport_t nwuo_locport;
udpport_t nwuo_remport;
ipaddr_t nwuo_locaddr;
ipaddr_t nwuo_remaddr;
} nwio_udpopt_t;
#define NWUO_NOFLAGS 0x0000L
#define NWUO_ACC_MASK 0x0003L
#define NWUO_EXCL 0x00000001L
#define NWUO_SHARED 0x00000002L
#define NWUO_COPY 0x00000003L
#define NWUO_LOCPORT_MASK 0x000CL
#define NWUO_LP_SEL 0x00000004L
#define NWUO_LP_SET 0x00000008L
#define NWUO_LP_ANY 0x0000000CL
#define NWUO_LOCADDR_MASK 0x0010L
#define NWUO_EN_LOC 0x00000010L
#define NWUO_DI_LOC 0x00100000L
#define NWUO_BROAD_MASK 0x0020L
#define NWUO_EN_BROAD 0x00000020L
#define NWUO_DI_BROAD 0x00200000L
#define NWUO_REMPORT_MASK 0x0100L
#define NWUO_RP_SET 0x00000100L
#define NWUO_RP_ANY 0x01000000L
#define NWUO_REMADDR_MASK 0x0200L
#define NWUO_RA_SET 0x00000200L
#define NWUO_RA_ANY 0x02000000L
#define NWUO_RW_MASK 0x1000L
#define NWUO_RWDATONLY 0x00001000L
#define NWUO_RWDATALL 0x10000000L
#define NWUO_IPOPT_MASK 0x2000L
#define NWUO_EN_IPOPT 0x00002000L
#define NWUO_DI_IPOPT 0x20000000L
#endif /* __SERVER__IP__GEN__UDP_IO_H__ */
+85
View File
@@ -0,0 +1,85 @@
/*
net/gen/vjhc.h
Defines for Van Jacobson TCP/IP Header Compression as defined in RFC-1144
Created: Nov 15, 1993 by Philip Homburg <philip@cs.vu.nl>
*/
#ifndef __NET__GEN__VJHC_H__
#define __NET__GEN__VJHC_H__
#define VJHC_FLAG_U 0x01
#define VJHC_FLAG_W 0x02
#define VJHC_FLAG_A 0x04
#define VJHC_FLAG_S 0x08
#define VJHC_FLAG_P 0x10
#define VJHC_FLAG_I 0x20
#define VJHC_FLAG_C 0x40
#define VJHC_SPEC_I (VJHC_FLAG_S | VJHC_FLAG_W | VJHC_FLAG_U)
#define VJHC_SPEC_D (VJHC_FLAG_S | VJHC_FLAG_A | VJHC_FLAG_W | VJHC_FLAG_U)
#define VJHC_SPEC_MASK (VJHC_FLAG_S | VJHC_FLAG_A | VJHC_FLAG_W | VJHC_FLAG_U)
#define VJHC_ENCODE(cp, n) \
{ \
if ((u16_t)(n) >= 256) \
{ \
*(cp)++= 0; \
*(cp)++= (n >> 8); \
*(cp)++= (n); \
} \
else \
*(cp)++= (n); \
}
#define VJHC_ENCODEZ(cp, n) \
{ \
if ((u16_t)(n) == 0 || (u16_t)(n) >= 256) \
{ \
*(cp)++= 0; \
*(cp)++= (n >> 8); \
*(cp)++= (n); \
} \
else \
*(cp)++= (n); \
}
#define VJHC_DECODEL(cp, l) \
{ \
if (*(cp) == 0) \
{ \
(l)= htonl(ntohl((l)) + (((cp)[1] << 8) | (cp)[2])); \
(cp) += 3; \
} \
else \
(l)= htonl(ntohl((l)) + (u32_t)*(cp)++); \
}
#define VJHC_DECODES(cp, s) \
{ \
if (*(cp) == 0) \
{ \
(s)= htons(ntohs((s)) + (((cp)[1] << 8) | (cp)[2])); \
(cp) += 3; \
} \
else \
(s)= htons(ntohs((s)) + (u16_t)*(cp)++); \
}
#define VJHC_DECODEU(cp, s) \
{ \
if (*(cp) == 0) \
{ \
(s)= htons(((cp)[1] << 8) | (cp)[2]); \
(cp) += 3; \
} \
else \
(s)= htons((u16_t)*(cp)++); \
}
#endif /* __NET__GEN__VJHC_H__ */
/*
* $PchId: vjhc.h,v 1.2 1995/11/17 22:14:46 philip Exp $
*/
+83
View File
@@ -0,0 +1,83 @@
/*
The following macro definitions convert to and from the network standard byte
order. The macros with their name in lower case guarantee to evaluate their
argument exactly once. The function of the macros is encoded in their names;
htons means convert a (unsigned) short in host byte order to network byte order.
*/
#ifndef _NET__HTON_H
#define _NET__HTON_H
#include <minix/config.h>
extern u16_t _tmp;
extern u32_t _tmp_l;
/* Find out about the byte order. */
/* assume <minix/config.h> is included, let's check */
#if (CHIP == 0)
#include "CHIP macro not set, include <minix/config.h>"
#endif
#if (CHIP == INTEL)
#define LITTLE_ENDIAN 1
#endif
#if (CHIP == M68000 || CHIP == SPARC)
#define BIG_ENDIAN 1
#endif
#if (LITTLE_ENDIAN) && (BIG_ENDIAN)
#include "both LITTLE_ENDIAN and BIG_ENDIAN are defined"
/* LITTLE_ENDIAN and BIG_ENDIAN are both defined */
#endif
#if !(LITTLE_ENDIAN) && !(BIG_ENDIAN)
#include "neither LITTLE_ENDIAN nor BIG_ENDIAN is defined"
/* LITTLE_ENDIAN and BIG_ENDIAN are both NOT defined */
#endif
#if LITTLE_ENDIAN
#define HTONS(x) ( ( (((unsigned short)(x)) >>8) & 0xff) | \
((((unsigned short)(x)) & 0xff)<<8) )
#define NTOHS(x) ( ( (((unsigned short)(x)) >>8) & 0xff) | \
((((unsigned short)(x)) & 0xff)<<8) )
#define HTONL(x) ((((x)>>24) & 0xffL) | (((x)>>8) & 0xff00L) | \
(((x)<<8) & 0xff0000L) | (((x)<<24) & 0xff000000L))
#define NTOHL(x) ((((x)>>24) & 0xffL) | (((x)>>8) & 0xff00L) | \
(((x)<<8) & 0xff0000L) | (((x)<<24) & 0xff000000L))
#if _WORD_SIZE > 2
#define htons(x) (_tmp=(x), ((_tmp>>8) & 0xff) | ((_tmp<<8) & 0xff00))
#define ntohs(x) (_tmp=(x), ((_tmp>>8) & 0xff) | ((_tmp<<8) & 0xff00))
#define htonl(x) (_tmp_l=(x), ((_tmp_l>>24) & 0xffL) | \
((_tmp_l>>8) & 0xff00L) | \
((_tmp_l<<8) & 0xff0000L) | ((_tmp_l<<24) & 0xff000000L))
#define ntohl(x) (_tmp_l=(x), ((_tmp_l>>24) & 0xffL) \
| ((_tmp_l>>8) & 0xff00L) | \
((_tmp_l<<8) & 0xff0000L) | ((_tmp_l<<24) & 0xff000000L))
#else /* _WORD_SIZE == 2 */
/* The above macros are too unwieldy for a 16-bit machine. */
u16_t htons(u16_t x);
u16_t ntohs(u16_t x);
u32_t htonl(u32_t x);
u32_t ntohl(u32_t x);
#endif /* _WORD_SIZE == 2 */
#endif /* LITTLE_ENDIAN */
#if BIG_ENDIAN
#define htons(x) (x)
#define HTONS(x) (x)
#define ntohs(x) (x)
#define NTOHS(x) (x)
#define htonl(x) (x)
#define HTONL(x) (x)
#define ntohl(x) (x)
#define NTOHL(x) (x)
#endif /* BIG_ENDIAN */
#endif /* _NET__HTON_H */
+44
View File
@@ -0,0 +1,44 @@
/* net/ioctl.h - Network ioctl() command codes. Author: Kees J. Bot
* 23 Nov 2002
*
*/
#ifndef _NET__IOCTL_H
#define _NET__IOCTL_H
#include <minix/ioctl.h>
/* Network ioctls. */
#define NWIOSETHOPT _IOW('n', 16, struct nwio_ethopt)
#define NWIOGETHOPT _IOR('n', 17, struct nwio_ethopt)
#define NWIOGETHSTAT _IOR('n', 18, struct nwio_ethstat)
#define NWIOSIPCONF _IOW('n', 32, struct nwio_ipconf)
#define NWIOGIPCONF _IOR('n', 33, struct nwio_ipconf)
#define NWIOSIPOPT _IOW('n', 34, struct nwio_ipopt)
#define NWIOGIPOPT _IOR('n', 35, struct nwio_ipopt)
#define NWIOGIPOROUTE _IORW('n', 40, struct nwio_route)
#define NWIOSIPOROUTE _IOW ('n', 41, struct nwio_route)
#define NWIODIPOROUTE _IOW ('n', 42, struct nwio_route)
#define NWIOGIPIROUTE _IORW('n', 43, struct nwio_route)
#define NWIOSIPIROUTE _IOW ('n', 44, struct nwio_route)
#define NWIODIPIROUTE _IOW ('n', 45, struct nwio_route)
#define NWIOSTCPCONF _IOW('n', 48, struct nwio_tcpconf)
#define NWIOGTCPCONF _IOR('n', 49, struct nwio_tcpconf)
#define NWIOTCPCONN _IOW('n', 50, struct nwio_tcpcl)
#define NWIOTCPLISTEN _IOW('n', 51, struct nwio_tcpcl)
#define NWIOTCPATTACH _IOW('n', 52, struct nwio_tcpatt)
#define NWIOTCPSHUTDOWN _IO ('n', 53)
#define NWIOSTCPOPT _IOW('n', 54, struct nwio_tcpopt)
#define NWIOGTCPOPT _IOR('n', 55, struct nwio_tcpopt)
#define NWIOSUDPOPT _IOW('n', 64, struct nwio_udpopt)
#define NWIOGUDPOPT _IOR('n', 65, struct nwio_udpopt)
#define NWIOSPSIPOPT _IOW('n', 80, struct nwio_psipopt)
#define NWIOGPSIPOPT _IOR('n', 81, struct nwio_psipopt)
#endif /* _NET__IOCTL_H */
+22
View File
@@ -0,0 +1,22 @@
/*
net/netlib.h
*/
#ifndef _NET__NETLIB_H_
#define _NET__NETLIB_H_
#ifndef _ANSI
#include <ansi.h>
#endif
_PROTOTYPE (int iruserok, (unsigned long raddr, int superuser,
const char *ruser, const char *luser) );
_PROTOTYPE (int rcmd, (char **ahost, int rport, const char *locuser,
const char *remuser, const char *cmd, int *fd2p) );
#define ETH_DEVICE "/dev/eth"
#define IP_DEVICE "/dev/ip"
#define TCP_DEVICE "/dev/tcp"
#define UDP_DEVICE "/dev/udp"
#endif /* _NET__NETLIB_H_ */
+13
View File
@@ -0,0 +1,13 @@
#ifndef __NET_SOCKET_H__
#define __NET_SOCKET_H__ 1
#include <sys/types.h>
#include <net/hton.h>
#include <net/gen/in.h>
#include <net/gen/socket.h>
#include <net/gen/emu.h>
#include <net/gen/netdb.h>
#endif