00001 /* 00002 * Copyright (c) 1999 - 2003 00003 * NetGroup, Politecnico di Torino (Italy) 00004 * All rights reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions 00008 * are met: 00009 * 00010 * 1. Redistributions of source code must retain the above copyright 00011 * notice, this list of conditions and the following disclaimer. 00012 * 2. Redistributions in binary form must reproduce the above copyright 00013 * notice, this list of conditions and the following disclaimer in the 00014 * documentation and/or other materials provided with the distribution. 00015 * 3. Neither the name of the Politecnico di Torino nor the names of its 00016 * contributors may be used to endorse or promote products derived from 00017 * this software without specific prior written permission. 00018 * 00019 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00020 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00021 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00022 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 00023 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00024 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00025 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00026 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00027 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00028 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00029 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00030 * 00031 */ 00032 00033 /* Definitions */ 00034 00035 /*! 00036 \brief A queue of raw packets that will be sent to the network with pcap_sendqueue_transmit(). 00037 */ 00038 struct pcap_send_queue{ 00039 u_int maxlen; ///< Maximum size of the the queue, in bytes. This variable contains the size of the buffer field. 00040 u_int len; ///< Current size of the queue, in bytes. 00041 char *buffer; ///< Buffer containing the packets to be sent. 00042 }; 00043 00044 typedef struct pcap_send_queue pcap_send_queue; 00045 00046 #define BPF_MEM_EX_IMM 0xc0 00047 #define BPF_MEM_EX_IND 0xe0 00048 00049 /*used for ST*/ 00050 #define BPF_MEM_EX 0xc0 00051 #define BPF_TME 0x08 00052 00053 #define BPF_LOOKUP 0x90 00054 #define BPF_EXECUTE 0xa0 00055 #define BPF_INIT 0xb0 00056 #define BPF_VALIDATE 0xc0 00057 #define BPF_SET_ACTIVE 0xd0 00058 #define BPF_RESET 0xe0 00059 #define BPF_SET_MEMORY 0x80 00060 #define BPF_GET_REGISTER_VALUE 0x70 00061 #define BPF_SET_REGISTER_VALUE 0x60 00062 #define BPF_SET_WORKING 0x50 00063 #define BPF_SET_ACTIVE_READ 0x40 00064 #define BPF_SET_AUTODELETION 0x30 00065 #define BPF_SEPARATION 0xff 00066 00067 /* Prototypes */ 00068 pcap_send_queue* pcap_sendqueue_alloc(u_int memsize); 00069 00070 void pcap_sendqueue_destroy(pcap_send_queue* queue); 00071 00072 int pcap_sendqueue_queue(pcap_send_queue* queue, const struct pcap_pkthdr *pkt_header, const u_char *pkt_data); 00073 00074 u_int pcap_sendqueue_transmit(pcap_t *p, pcap_send_queue* queue, int sync); 00075 00076 HANDLE pcap_getevent(pcap_t *p); 00077 00078 struct pcap_stat *pcap_stats_ex(pcap_t *p, int *pcap_stat_size); 00079 00080 int pcap_setuserbuffer(pcap_t *p, int size); 00081 00082 int pcap_live_dump(pcap_t *p, char *filename, int maxsize, int maxpacks); 00083 00084 int pcap_live_dump_ended(pcap_t *p, int sync); 00085 00086 int pcap_offline_filter(struct bpf_program *prog, const struct pcap_pkthdr *header, const u_char *pkt_data);