1/*	$NetBSD: netif.h,v 1.4 1995/09/14 23:45:30 pk Exp $	*/
2
3/* $FreeBSD$ */
4
5#ifndef __SYS_LIBNETBOOT_NETIF_H
6#define __SYS_LIBNETBOOT_NETIF_H
7#include "iodesc.h"
8
9#define NENTS(x)	sizeof(x)/sizeof(x[0])
10
11struct netif_driver {
12	const	char *netif_bname;
13	int	(*netif_match)(struct netif *, void *);
14	int	(*netif_probe)(struct netif *, void *);
15	void	(*netif_init)(struct iodesc *, void *);
16	int	(*netif_get)(struct iodesc *, void *, size_t, time_t);
17	int	(*netif_put)(struct iodesc *, void *, size_t);
18	void	(*netif_end)(struct netif *);
19	struct	netif_dif *netif_ifs;
20	int	netif_nifs;
21};
22
23struct netif_dif {
24	int		dif_unit;
25	int		dif_nsel;
26	struct netif_stats *dif_stats;
27	void		*dif_private;
28	/* the following fields are used internally by the netif layer */
29	u_long		dif_used;
30};
31
32struct netif_stats {
33	int	collisions;
34	int	collision_error;
35	int	missed;
36	int	sent;
37	int	received;
38	int	deferred;
39	int	overflow;
40};
41
42struct netif {
43	struct netif_driver	*nif_driver;
44	int			nif_unit;
45	int			nif_sel;
46	void			*nif_devdata;
47};
48
49extern struct netif_driver	*netif_drivers[];	/* machdep */
50extern int			n_netif_drivers;
51
52extern int			netif_debug;
53
54void		netif_init(void);
55struct netif	*netif_select(void *);
56int		netif_probe(struct netif *, void *);
57void		netif_attach(struct netif *, struct iodesc *, void *);
58void		netif_detach(struct netif *);
59ssize_t		netif_get(struct iodesc *, void *, size_t, time_t);
60ssize_t		netif_put(struct iodesc *, void *, size_t);
61
62int		netif_open(void *);
63int		netif_close(int);
64
65struct iodesc	*socktodesc(int);
66
67#endif /* __SYS_LIBNETBOOT_NETIF_H */
68