bpfdesc.h revision 0a0e9771ca0211c15f3ac4466b661c145feeb9e4
/* $NetBSD: bpfdesc.h,v 1.29 2009/03/14 14:46:10 dsl Exp $ */
/*
* Copyright (c) 1990, 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
* Berkeley Laboratory.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)bpfdesc.h 8.1 (Berkeley) 6/10/93
*
* @(#) Header: bpfdesc.h,v 1.14 96/06/16 22:28:07 leres Exp (LBL)
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _NET_BPFDESC_H_
#define _NET_BPFDESC_H_
/*
* Descriptor associated with each open bpf file.
*/
struct bpf_d {
/*
* Buffer slots: two mbuf clusters buffer the incoming packets.
* The model has three slots. Sbuf is always occupied.
* sbuf (store) - Receive interrupt puts packets here.
* hbuf (hold) - When sbuf is full, put cluster here and
* wakeup read (replace sbuf with fbuf).
* fbuf (free) - When read is done, put cluster here.
* On receiving, if sbuf is full and fbuf is 0, packet is dropped.
*/
void * bd_sbuf; /* store slot */
void * bd_hbuf; /* hold slot */
void * bd_fbuf; /* free slot */
int bd_slen; /* current length of store buffer */
int bd_hlen; /* current length of hold buffer */
int bd_bufsize; /* absolute length of buffers */
int bd_hdrcmplt; /* false to fill in src lladdr */
int bd_seesent; /* true if bpf should see sent pkts */
int bd_async; /* non-zero if packet reception .. */
/* .. should generate signal */
int bd_nonblock; /* non-zero for non-blocking read */
int bd_timedout;
void *bd_sih; /* soft interrupt handle */
/*
* Solaris specific bits after this.
*/
int bd_fmode; /* flags from bpfopen */
int bd_inuse;
int bd_waiting;
/*
* bd_promisc_flags is used to store the promiscuous state of the
* the interface in BPF so that the correct mode of operation can
* be kept across changing DLT or network interface.
*/
int bd_promisc_flags;
};
/* Values for bd_state */
#define BPF_IDLE 0 /* no select in progress */
/*
* Description associated with the external representation of each
* open bpf file.
*/
struct bpf_d_ext {
char bde_ifname[IFNAMSIZ];
};
/*
* Access to "layer 2" networking is provided through each such provider
* delcaring a set of functions to use in the structure below. It has been
* modeled around what's required to use the mac layer. All of the functions
* below must be declared, even if only filled by a stub function.
*/
typedef struct bpf_provider_s {
int bpr_unit;
int);
void (*bpr_promisc_remove)(uintptr_t);
int (*bpr_getlinkid)(const char *, datalink_id_t *,
zoneid_t);
void (*bpr_client_close)(uintptr_t);
const char *(*bpr_client_name)(uintptr_t);
typedef struct bpf_provider_list {
/*
* The bpr_field from bpf_provider_t expects an integer that comes from
* the list of defines below.
*/
#define BPR_MAC 1
#define BPR_IPNET 2
/*
* Descriptor associated with each attached hardware interface.
*/
struct bpf_if {
/*
* Solaris specific bits after this.
*/
int bif_inuse;
};
#ifdef _KERNEL
typedef struct bpf_kstats_s {
} bpf_kstats_t;
#endif
typedef void (*bpf_detach_fn_t)(uintptr_t);
typedef int (*bpf_provider_reg_fn_t)(bpf_provider_t *);
extern bpf_provider_t *bpf_find_provider_by_id(int);
extern void bpf_open_zone(const zoneid_t);
extern int bpf_provider_tickle(char *, zoneid_t);
#endif /* !_NET_BPFDESC_H_ */