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