DataMuseum.dk

Presents historical artifacts from the history of:

Regnecentalen RC-900

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Regnecentalen RC-900

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download

⟦7d5735c70⟧ TextFile

    Length: 7823 (0x1e8f)
    Types: TextFile
    Notes: UNIX file
    Names: »if.h«

Derivation

└─⟦8c4f54e61⟧ Bits:30004068/disk2.imd Interactive TCP/IP v.1.2
└─⟦8c4f54e61⟧ UNIX Filesystem
    └─⟦this⟧ »hb/new/usr/include/net/if.h« 

TextFile

/*
 * Copyright (c) 1982, 1986 Regents of the University of California.
 * All rights reserved.  The Berkeley software License Agreement
 * specifies the terms and conditions for redistribution.
 *
 *      @(#)if.h	5.4 - 87/07/16
 *
 *      Portions of this software copyrighted as an unpublished work.
 *      (c) Copyright 1988 INTERACTIVE Systems Corporation
 *      All rights reserved.
 *
 *      RESTRICTED RIGHTS:
 *
 *      These programs are supplied under a license.  They may be used,
 *      disclosed, and/or copied only as permitted under such license
 *      agreement.  Any copy must contain the above copyright notice and
 *      this restricted rights notice.  Use, copying, and/or disclosure
 *      of the programs is strictly prohibited unless otherwise provided
 *      in the license agreement.
 */

#ifndef _h_IF
#define _h_IF
#ident "@(#)if.h	2.1 - 89/04/21"

/*
 * Structures defining a network interface, providing a packet
 * transport mechanism (ala level 0 of the PUP protocols).
 *
 * Each interface accepts output datagrams of a specified maximum
 * length, and provides higher level routines with input datagrams
 * received from its medium.
 *
 * Output occurs when the routine if_output is called, with three parameters:
 *	(*ifp->if_output)(ifp, m, dst)
 * Here m is the mbuf chain to be sent and dst is the destination address.
 * The output routine encapsulates the supplied datagram if necessary,
 * and then transmits it on its medium.
 *
 * On input, each interface unwraps the data received by it, and either
 * places it on the input queue of a internetwork datagram routine
 * and posts the associated software interrupt, or passes the datagram to a raw
 * packet input routine.
 *
 * Routines exist for locating interfaces by their addresses
 * or for locating a interface on a certain network, as well as more general
 * routing and gateway routines maintaining information used to locate
 * interfaces.  These routines live in the files if.c and route.c
 */

/*
 * Structure defining a queue for a network interface.
 *
 * (Would like to call this struct ``if'', but C isn't PL/1.)
 */
struct ifnet {
	char	*if_name;		/* name, e.g. ``en'' or ``lo'' */
	short	if_unit;		/* sub-unit for lower level driver */
	short	if_mtu;			/* maximum transmission unit */
	short	if_flags;		/* up/down, broadcast, etc. */
	int	if_metric;	/* routing metric */
	struct	ifaddr *if_addrlist;	/* linked list of addresses per if */
	queue_t *if_snd;	/* output queue */
	struct	ifnet *if_next;
	mblk_t *if_mblk;	/* points to mblk_t defining this ifnet */
	long    if_index;	/* used for unlinking */
};

#define	IFF_UP		0x1		/* interface is up */
#define	IFF_BROADCAST	0x2		/* broadcast address valid */
#define	IFF_DEBUG	0x4		/* turn on debugging */
#define	IFF_LOOPBACK	0x8		/* is a loopback net */
#define	IFF_POINTOPOINT	0x10		/* interface is point-to-point link */
#define	IFF_NOTRAILERS	0x20		/* avoid use of trailers */
#define	IFF_RUNNING	0x40		/* resources allocated */
#define	IFF_NOARP	0x80		/* no address resolution protocol */
/* next two not supported now, but reserved: */
#define	IFF_PROMISC	0x100		/* receive all packets */
#define	IFF_ALLMULTI	0x200		/* receive all multicast packets */
/* Streams specific flags */
#define IFF_NONAME	0x400		/* name is not set for ARP device */
#define IFF_ARPDEV	0x800		/* There is ARP on stream */
#define	IFF_SUBARP	0x1000		/* ARP subnet gateway hack */
/* flags set internally only: */
#define	IFF_CANTCHANGE	(IFF_BROADCAST | IFF_POINTOPOINT | IFF_RUNNING | IFF_ARPDEV)

/*
 * Output queues (ifp->if_snd) and internetwork datagram level (pup level 1)
 * input routines have queues of messages stored on ifqueue structures
 * (defined above).  Entries are added to and deleted from these structures
 * by these macros, which should be called with ipl raised to splimp().
 */
#define	IF_QFULL(ifq)		(!canput(ifq))
#define	IF_DROP(ifq)		((ifq)->ifq_drops++)
#define	IF_ENQUEUE(ifq, m) 	(putnext(ifq, m))
#define	IF_PREPEND(ifq, m) 	(putbq(ifq, m))
/*
 * Packets destined for level-1 protocol input routines
 * have a pointer to the receiving interface prepended to the data.
 * IF_DEQUEUEIF extracts and returns this pointer when dequeueing the packet.
 * IF_ADJ should be used otherwise to adjust for its presence.
 */
#define	IF_ADJ(m) { \
	(m)->b_rptr += sizeof(struct ifnet *); \
	if (m_len(m) == 0) { \
		mblk_t *n; \
		M_FREE((m), n); \
		(m) = n; \
	} \
}
#define	IF_DEQUEUEIF(ifq, m, ifp) { \
		m = getq(ifq); \
		(ifp) = *(mtod((m), struct ifnet **)); \
		IF_ADJ(m); \
	} \
}
#define	IF_DEQUEUE(ifq, m) { \
  		m = getq(ifq); \
}

#define	IFQ_MAXLEN	50
#define	IFNET_SLOWHZ	1		/* granularity is 1 second */
#define IFNET_DEFMTU	576		/* everyone must support this */

/*
 * The ifaddr structure contains information about one address
 * of an interface.  They are maintained by the different address families,
 * are allocated and attached when an address is set, and are linked
 * together so all addresses for an interface can be located.
 */
struct ifaddr {
	struct	sockaddr ifa_addr;	/* address of interface */
	union {
		struct	sockaddr ifu_broadaddr;
		struct	sockaddr ifu_dstaddr;
	} ifa_ifu;
#define	ifa_broadaddr	ifa_ifu.ifu_broadaddr	/* broadcast address */
#define	ifa_dstaddr	ifa_ifu.ifu_dstaddr	/* other end of p-to-p link */
	struct	ifnet *ifa_ifp;		/* back-pointer to interface */
	struct	ifaddr *ifa_next;	/* next address for interface */
};

/*
 * Interface operational statistics retrieved via the DLGSTAT ioctl
 */
struct ifstats {
    ulong	ifs_nstats;	/* number of stat fields */
    /* non-hardware */
    ulong	ifs_nobuffer;	/* 0 */
    ulong	ifs_blocked;	/* 1 */
    ulong	ifs_blocked2;	/* 2 */
    ulong	ifs_multicast;	/* 3 */

       /* transmit */
   ulong	ifs_xpkts;	/* 4 */
   ulong	ifs_xbytes;	/* 5 */
   ulong	ifs_excoll;	/* 6 */
   ulong	ifs_coll;	/* 7 */
   ulong	ifs_under;	/* 8 */
   ulong	ifs_carrier;	/* 9 */

       /* receive */
   ulong	ifs_rpkts;	/* 10 */
   ulong	ifs_rbytes;	/* 11 */
   ulong	ifs_fcs;	/* 12 */
   ulong	ifs_align;	/* 13 */
   ulong	ifs_overflow;	/* 14 */
   ulong	ifs_short;	/* 15 */
};

/*
 * Interface request structure used for socket
 * ioctl's.  All interface ioctl's must have parameter
 * definitions which begin with ifr_name.  The
 * remainder may be interface specific.
 */
struct	ifreq {
#define	IFNAMSIZ	16
	char	ifr_name[IFNAMSIZ];		/* if name, e.g. "en0" */
	union {
		struct	sockaddr ifru_addr;
		struct	sockaddr ifru_dstaddr;
		struct	sockaddr ifru_broadaddr;
		short	ifru_flags;
		int	ifru_metric;
		int	ifru_lindex;
		caddr_t	ifru_data;
		struct	ifstats	ifru_stats;
	} ifr_ifru;
#define	ifr_addr	ifr_ifru.ifru_addr	/* address */
#define	ifr_dstaddr	ifr_ifru.ifru_dstaddr	/* other end of p-to-p link */
#define	ifr_broadaddr	ifr_ifru.ifru_broadaddr	/* broadcast address */
#define	ifr_flags	ifr_ifru.ifru_flags	/* flags */
#define	ifr_metric	ifr_ifru.ifru_metric	/* metric */
#define ifr_lindex	ifr_ifru.ifru_lindex    /* link index for if name set */
#define	ifr_data	ifr_ifru.ifru_data	/* for use by interface */
#define	ifr_stats	ifr_ifru.ifru_stats	/* interface statistics */
};

/*
 * Structure used in SIOCGIFCONF request.
 * Used to retrieve interface configuration
 * for machine (useful for programs which
 * must know all networks accessible).
 */
struct	ifconf {
	int	ifc_len;		/* size of associated buffer */
	union {
		caddr_t	ifcu_buf; /* NOT USED */
		struct	ifreq ifcu_req[1];
	} ifc_ifcu;
#define	ifc_buf	ifc_ifcu.ifcu_buf	/* buffer address */
#define	ifc_req	ifc_ifcu.ifcu_req	/* array of structures returned */
};

#ifdef KERNEL
#include "../net/if_arp.h"
extern struct ifnet *ifnet;
extern struct ifaddr *ifa_ifwithaddr(), *ifa_ifwithnet();
extern struct ifaddr *ifa_ifwithdstaddr();
#else
#include "../net/if_arp.h"
#endif
#endif /* _h_IF */