Home | History | Annotate | Line # | Download | only in libsa
      1  1.8  christos /*	$NetBSD: netif.h,v 1.8 2024/02/27 16:09:19 christos Exp $	*/
      2  1.8  christos 
      3  1.8  christos /*-
      4  1.8  christos  * Copyright (c) 2024 The NetBSD Foundation, Inc.
      5  1.8  christos  * All rights reserved.
      6  1.8  christos  *
      7  1.8  christos  * Redistribution and use in source and binary forms, with or without
      8  1.8  christos  * modification, are permitted provided that the following conditions
      9  1.8  christos  * are met:
     10  1.8  christos  * 1. Redistributions of source code must retain the above copyright
     11  1.8  christos  *    notice, this list of conditions and the following disclaimer.
     12  1.8  christos  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.8  christos  *    notice, this list of conditions and the following disclaimer in the
     14  1.8  christos  *    documentation and/or other materials provided with the distribution.
     15  1.8  christos  *
     16  1.8  christos  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     17  1.8  christos  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     18  1.8  christos  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     19  1.8  christos  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     20  1.8  christos  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     21  1.8  christos  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     22  1.8  christos  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     23  1.8  christos  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     24  1.8  christos  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     25  1.8  christos  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     26  1.8  christos  * POSSIBILITY OF SUCH DAMAGE.
     27  1.8  christos  */
     28  1.1    brezak 
     29  1.1    brezak #ifndef __SYS_LIBNETBOOT_NETIF_H
     30  1.1    brezak #define __SYS_LIBNETBOOT_NETIF_H
     31  1.5  drochner 
     32  1.1    brezak #include "iodesc.h"
     33  1.1    brezak 
     34  1.5  drochner struct netif; /* forward */
     35  1.1    brezak 
     36  1.1    brezak struct netif_driver {
     37  1.1    brezak 	char	*netif_bname;
     38  1.7   tsutsui 	int	(*netif_match)(struct netif *, void *);
     39  1.7   tsutsui 	int	(*netif_probe)(struct netif *, void *);
     40  1.7   tsutsui 	void	(*netif_init)(struct iodesc *, void *);
     41  1.7   tsutsui 	int	(*netif_get)(struct iodesc *, void *, size_t, saseconds_t);
     42  1.7   tsutsui 	int	(*netif_put)(struct iodesc *, void *, size_t);
     43  1.7   tsutsui 	void	(*netif_end)(struct netif *);
     44  1.1    brezak 	struct	netif_dif *netif_ifs;
     45  1.1    brezak 	int	netif_nifs;
     46  1.1    brezak };
     47  1.1    brezak 
     48  1.1    brezak struct netif_dif {
     49  1.1    brezak 	int		dif_unit;
     50  1.1    brezak 	int		dif_nsel;
     51  1.1    brezak 	struct netif_stats *dif_stats;
     52  1.1    brezak 	void		*dif_private;
     53  1.1    brezak 	/* the following fields are used internally by the netif layer */
     54  1.1    brezak 	u_long		dif_used;
     55  1.1    brezak };
     56  1.1    brezak 
     57  1.1    brezak struct netif_stats {
     58  1.1    brezak 	int	collisions;
     59  1.1    brezak 	int	collision_error;
     60  1.1    brezak 	int	missed;
     61  1.1    brezak 	int	sent;
     62  1.1    brezak 	int	received;
     63  1.1    brezak 	int	deferred;
     64  1.1    brezak 	int	overflow;
     65  1.1    brezak };
     66  1.1    brezak 
     67  1.1    brezak struct netif {
     68  1.1    brezak 	struct netif_driver	*nif_driver;
     69  1.1    brezak 	int			nif_unit;
     70  1.1    brezak 	int			nif_sel;
     71  1.3        pk 	void			*nif_devdata;
     72  1.1    brezak };
     73  1.1    brezak 
     74  1.1    brezak extern struct netif_driver	*netif_drivers[];	/* machdep */
     75  1.1    brezak extern int			n_netif_drivers;
     76  1.1    brezak 
     77  1.1    brezak extern int			netif_debug;
     78  1.1    brezak 
     79  1.7   tsutsui void		netif_init(void);
     80  1.7   tsutsui struct netif	*netif_select(void *);
     81  1.7   tsutsui int		netif_probe(struct netif *, void *);
     82  1.7   tsutsui void		netif_attach(struct netif *, struct iodesc *, void *);
     83  1.7   tsutsui void		netif_detach(struct netif *);
     84  1.1    brezak 
     85  1.7   tsutsui int		netif_open(void *);
     86  1.7   tsutsui int		netif_close(int);
     87  1.1    brezak 
     88  1.1    brezak #endif /* __SYS_LIBNETBOOT_NETIF_H */
     89