/* $NetBSD: net.h,v 1.10 1995/10/20 00:46:30 cgd Exp $ */12/*3* Copyright (c) 1993 Adam Glass4* Copyright (c) 1992 Regents of the University of California.5* All rights reserved.6*7* This software was developed by the Computer Systems Engineering group8* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and9* contributed to Berkeley.10*11* Redistribution and use in source and binary forms, with or without12* modification, are permitted provided that the following conditions13* are met:14* 1. Redistributions of source code must retain the above copyright15* notice, this list of conditions and the following disclaimer.16* 2. Redistributions in binary form must reproduce the above copyright17* notice, this list of conditions and the following disclaimer in the18* documentation and/or other materials provided with the distribution.19* 3. Neither the name of the University nor the names of its contributors20* may be used to endorse or promote products derived from this software21* without specific prior written permission.22*23* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND24* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE25* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE26* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE27* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL28* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS29* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)30* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT31* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY32* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF33* SUCH DAMAGE.34*/3536#ifndef _STAND_NET_H37#define _STAND_NET_H38#ifndef _KERNEL /* XXX - see <netinet/in.h> */39#undef __IPADDR40#define __IPADDR(x) htonl((uint32_t)(x))41#endif4243#include "iodesc.h"4445#define BA { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }4647enum net_proto {48NET_NONE,49NET_NFS,50NET_TFTP51};5253/* Returns true if n_long's on the same net */54#define SAMENET(a1, a2, m) ((a1.s_addr & m) == (a2.s_addr & m))5556#define MACPY(s, d) bcopy((char *)s, (char *)d, 6)5758#define MAXTMO 120 /* seconds */59#define MINTMO 2 /* seconds */6061#define FNAME_SIZE 12862#define IFNAME_SIZE 1663#define RECV_SIZE 1536 /* XXX delete this */6465/*66* How much room to leave for headers:67* 14: struct ether_header68* 20: struct ip69* 8: struct udphdr70* That's 42 but let's pad it out to 48 bytes.71*/72#define ETHER_SIZE 1473#define HEADER_SIZE 487475extern u_char bcea[6];76extern char rootpath[FNAME_SIZE];77extern int rootport;78extern char bootfile[FNAME_SIZE];79extern char hostname[FNAME_SIZE];80extern int hostnamelen;81extern char domainname[FNAME_SIZE];82extern int domainnamelen;83extern int netproto;84extern char ifname[IFNAME_SIZE];8586/* All of these are in network order. */87extern struct in_addr myip;88extern struct in_addr rootip;89extern struct in_addr swapip;90extern struct in_addr gateip;91extern struct in_addr nameip;92extern struct in_addr servip;93extern n_long netmask;94extern u_int intf_mtu;9596extern int debug; /* defined in the machdep sources */9798/* ARP/RevARP functions: */99u_char *arpwhohas(struct iodesc *, struct in_addr);100void arp_reply(struct iodesc *, void *);101int rarp_getipaddress(int);102103/* Link functions: */104ssize_t sendether(struct iodesc *d, void *pkt, size_t len,105u_char *dea, int etype);106ssize_t readether(struct iodesc *, void **, void **, time_t, uint16_t *);107108ssize_t sendip(struct iodesc *, void *, size_t, uint8_t);109ssize_t readip(struct iodesc *, void **, void **, time_t, uint8_t);110ssize_t sendudp(struct iodesc *, void *, size_t);111ssize_t readudp(struct iodesc *, void **, void **, time_t);112ssize_t sendrecv(struct iodesc *,113ssize_t (*)(struct iodesc *, void *, size_t),114void *, size_t,115ssize_t (*)(struct iodesc *, void **, void **, time_t,116void *),117void **, void **, void *);118119/* bootp/DHCP */120void bootp(int);121122/* Utilities: */123char *ether_sprintf(u_char *);124int in_cksum(void *, int);125char *inet_ntoa(struct in_addr);126char *intoa(n_long); /* similar to inet_ntoa */127n_long inet_addr(char *);128129#endif /* ! _STAND_NET_H */130131132