bpfdesc.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /* $OpenBSD: bpfdesc.h,v 1.24 2015/02/10 00:53:55 pelikan Exp $ */
  2. /* $NetBSD: bpfdesc.h,v 1.11 1995/09/27 18:30:42 thorpej Exp $ */
  3. /*
  4. * Copyright (c) 1990, 1991, 1993
  5. * The Regents of the University of California. All rights reserved.
  6. *
  7. * This code is derived from the Stanford/CMU enet packet filter,
  8. * (net/enet.c) distributed as part of 4.3BSD, and code contributed
  9. * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
  10. * Berkeley Laboratory.
  11. *
  12. * Redistribution and use in source and binary forms, with or without
  13. * modification, are permitted provided that the following conditions
  14. * are met:
  15. * 1. Redistributions of source code must retain the above copyright
  16. * notice, this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright
  18. * notice, this list of conditions and the following disclaimer in the
  19. * documentation and/or other materials provided with the distribution.
  20. * 3. Neither the name of the University nor the names of its contributors
  21. * may be used to endorse or promote products derived from this software
  22. * without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  25. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  27. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  28. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  30. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  31. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  32. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  33. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  34. * SUCH DAMAGE.
  35. *
  36. * @(#)bpfdesc.h 8.1 (Berkeley) 6/10/93
  37. */
  38. #ifndef _NET_BPFDESC_H_
  39. #define _NET_BPFDESC_H_
  40. #ifdef _KERNEL
  41. #include <sys/selinfo.h>
  42. /*
  43. * Descriptor associated with each open bpf file.
  44. */
  45. struct bpf_d {
  46. struct bpf_d *bd_next; /* Linked list of descriptors */
  47. /*
  48. * Buffer slots: two mbuf clusters buffer the incoming packets.
  49. * The model has three slots. Sbuf is always occupied.
  50. * sbuf (store) - Receive interrupt puts packets here.
  51. * hbuf (hold) - When sbuf is full, put cluster here and
  52. * wakeup read (replace sbuf with fbuf).
  53. * fbuf (free) - When read is done, put cluster here.
  54. * On receiving, if sbuf is full and fbuf is 0, packet is dropped.
  55. */
  56. caddr_t bd_sbuf; /* store slot */
  57. caddr_t bd_hbuf; /* hold slot */
  58. caddr_t bd_fbuf; /* free slot */
  59. int bd_slen; /* current length of store buffer */
  60. int bd_hlen; /* current length of hold buffer */
  61. int bd_bufsize; /* absolute length of buffers */
  62. struct bpf_if * bd_bif; /* interface descriptor */
  63. u_long bd_rtout; /* Read timeout in 'ticks' */
  64. u_long bd_rdStart; /* when the read started */
  65. struct bpf_insn *bd_rfilter; /* read filter code */
  66. struct bpf_insn *bd_wfilter; /* write filter code */
  67. u_long bd_rcount; /* number of packets received */
  68. u_long bd_dcount; /* number of packets dropped */
  69. u_char bd_promisc; /* true if listening promiscuously */
  70. u_char bd_state; /* idle, waiting, or timed out */
  71. u_char bd_immediate; /* true to return on packet arrival */
  72. u_char bd_locked; /* true if descriptor is locked */
  73. u_char bd_fildrop; /* true if filtered packets will be dropped */
  74. u_char bd_dirfilt; /* direction filter */
  75. u_int bd_queue; /* the queue the user wants to watch (0 == all) */
  76. int bd_hdrcmplt; /* false to fill in src lladdr automatically */
  77. int bd_async; /* non-zero if packet reception should generate signal */
  78. int bd_sig; /* signal to send upon packet reception */
  79. pid_t bd_pgid; /* process or group id for signal */
  80. uid_t bd_siguid; /* uid for process that set pgid */
  81. uid_t bd_sigeuid; /* euid for process that set pgid */
  82. u_int bd_ref; /* reference count */
  83. struct selinfo bd_sel; /* bsd select info */
  84. int bd_unit; /* logical unit number */
  85. LIST_ENTRY(bpf_d) bd_list; /* descriptor list */
  86. };
  87. /*
  88. * Descriptor associated with each attached hardware interface.
  89. */
  90. struct bpf_if {
  91. struct bpf_if *bif_next; /* list of all interfaces */
  92. struct bpf_d *bif_dlist; /* descriptor list */
  93. struct bpf_if **bif_driverp; /* pointer into softc */
  94. u_int bif_dlt; /* link layer type */
  95. u_int bif_hdrlen; /* length of header (with padding) */
  96. struct ifnet *bif_ifp; /* corresponding interface */
  97. };
  98. int bpf_setf(struct bpf_d *, struct bpf_program *, int);
  99. #endif /* _KERNEL */
  100. #endif /* _NET_BPFDESC_H_ */