138451Smsmith/*	$NetBSD: netif.h,v 1.4 1995/09/14 23:45:30 pk Exp $	*/
238451Smsmith
364185Sjhb/* $FreeBSD$ */
464185Sjhb
538451Smsmith#ifndef __SYS_LIBNETBOOT_NETIF_H
638451Smsmith#define __SYS_LIBNETBOOT_NETIF_H
738451Smsmith#include "iodesc.h"
838451Smsmith
938451Smsmith#define NENTS(x)	sizeof(x)/sizeof(x[0])
1038451Smsmith
1138451Smsmithstruct netif_driver {
1264185Sjhb	const	char *netif_bname;
1338451Smsmith	int	(*netif_match)(struct netif *, void *);
1438451Smsmith	int	(*netif_probe)(struct netif *, void *);
1538451Smsmith	void	(*netif_init)(struct iodesc *, void *);
1638451Smsmith	int	(*netif_get)(struct iodesc *, void *, size_t, time_t);
1738451Smsmith	int	(*netif_put)(struct iodesc *, void *, size_t);
1838451Smsmith	void	(*netif_end)(struct netif *);
1938451Smsmith	struct	netif_dif *netif_ifs;
2038451Smsmith	int	netif_nifs;
2138451Smsmith};
2238451Smsmith
2338451Smsmithstruct netif_dif {
2438451Smsmith	int		dif_unit;
2538451Smsmith	int		dif_nsel;
2638451Smsmith	struct netif_stats *dif_stats;
2738451Smsmith	void		*dif_private;
2838451Smsmith	/* the following fields are used internally by the netif layer */
2938451Smsmith	u_long		dif_used;
3038451Smsmith};
3138451Smsmith
3238451Smsmithstruct netif_stats {
3338451Smsmith	int	collisions;
3438451Smsmith	int	collision_error;
3538451Smsmith	int	missed;
3638451Smsmith	int	sent;
3738451Smsmith	int	received;
3838451Smsmith	int	deferred;
3938451Smsmith	int	overflow;
4038451Smsmith};
4138451Smsmith
4238451Smsmithstruct netif {
4338451Smsmith	struct netif_driver	*nif_driver;
4438451Smsmith	int			nif_unit;
4538451Smsmith	int			nif_sel;
4638451Smsmith	void			*nif_devdata;
4738451Smsmith};
4838451Smsmith
4938451Smsmithextern struct netif_driver	*netif_drivers[];	/* machdep */
5038451Smsmithextern int			n_netif_drivers;
5138451Smsmith
5238451Smsmithextern int			netif_debug;
5338451Smsmith
5438451Smsmithvoid		netif_init(void);
5538451Smsmithstruct netif	*netif_select(void *);
5638451Smsmithint		netif_probe(struct netif *, void *);
5738451Smsmithvoid		netif_attach(struct netif *, struct iodesc *, void *);
5838451Smsmithvoid		netif_detach(struct netif *);
5938451Smsmithssize_t		netif_get(struct iodesc *, void *, size_t, time_t);
6038451Smsmithssize_t		netif_put(struct iodesc *, void *, size_t);
6138451Smsmith
6238451Smsmithint		netif_open(void *);
6338451Smsmithint		netif_close(int);
6438451Smsmith
6538451Smsmithstruct iodesc	*socktodesc(int);
6638451Smsmith
6738451Smsmith#endif /* __SYS_LIBNETBOOT_NETIF_H */
68