nmsg  0.13.2
pcap_input.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009-2015 by Farsight Security, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef NMSG_PCAP_H
18 #define NMSG_PCAP_H
19 
33 typedef enum {
34  nmsg_pcap_type_file,
35  nmsg_pcap_type_live
36 } nmsg_pcap_type;
37 
46 nmsg_pcap_t
47 nmsg_pcap_input_open(pcap_t *phandle);
48 
55 nmsg_pcap_input_close(nmsg_pcap_t *pcap);
56 
72 nmsg_pcap_input_read(nmsg_pcap_t pcap, struct nmsg_ipdg *dg,
73  struct timespec *ts);
74 
91 nmsg_pcap_input_read_raw(nmsg_pcap_t pcap, struct pcap_pkthdr **pkt_hdr,
92  const uint8_t **pkt_data, struct timespec *ts);
93 
107 nmsg_res
108 nmsg_pcap_input_setfilter(nmsg_pcap_t pcap, const char *bpfstr);
109 
122 nmsg_res
123 nmsg_pcap_input_setfilter_raw(nmsg_pcap_t pcap, const char *bpfstr);
124 
133 void
134 nmsg_pcap_input_set_raw(nmsg_pcap_t pcap, bool raw);
135 
143 int
144 nmsg_pcap_snapshot(nmsg_pcap_t pcap);
145 
154 nmsg_pcap_type
155 nmsg_pcap_get_type(nmsg_pcap_t pcap);
156 
162 int
163 nmsg_pcap_get_datalink(nmsg_pcap_t pcap);
164 
177 bool
178 nmsg_pcap_filter(nmsg_pcap_t pcap, const uint8_t *pkt, size_t len);
179 
180 #endif /* NMSG_PCAP_H */