nmsg 1.1.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
33typedef enum {
34 nmsg_pcap_type_file,
35 nmsg_pcap_type_live
36} nmsg_pcap_type;
37
46nmsg_pcap_t
47nmsg_pcap_input_open(pcap_t *phandle);
48
55nmsg_pcap_input_close(nmsg_pcap_t *pcap);
56
72nmsg_pcap_input_read(nmsg_pcap_t pcap, struct nmsg_ipdg *dg,
73 struct timespec *ts);
74
91nmsg_pcap_input_read_raw(nmsg_pcap_t pcap, struct pcap_pkthdr **pkt_hdr,
92 const uint8_t **pkt_data, struct timespec *ts);
93
108nmsg_pcap_input_setfilter(nmsg_pcap_t pcap, const char *bpfstr);
109
123nmsg_pcap_input_setfilter_raw(nmsg_pcap_t pcap, const char *bpfstr);
124
133void
134nmsg_pcap_input_set_raw(nmsg_pcap_t pcap, bool raw);
135
143int
144nmsg_pcap_snapshot(nmsg_pcap_t pcap);
145
154nmsg_pcap_type
155nmsg_pcap_get_type(nmsg_pcap_t pcap);
156
162int
163nmsg_pcap_get_datalink(nmsg_pcap_t pcap);
164
177bool
178nmsg_pcap_filter(nmsg_pcap_t pcap, const uint8_t *pkt, size_t len);
179
180#endif /* NMSG_PCAP_H */
int nmsg_pcap_snapshot(nmsg_pcap_t pcap)
Get the snapshot length of the underlying pcap handle.
nmsg_res nmsg_pcap_input_setfilter_raw(nmsg_pcap_t pcap, const char *bpfstr)
Set a bpf filter on an nmsg_pcap_t object.
nmsg_pcap_t nmsg_pcap_input_open(pcap_t *phandle)
Initialize a new nmsg_pcap_t input from a libpcap source.
void nmsg_pcap_input_set_raw(nmsg_pcap_t pcap, bool raw)
Set raw mode.
nmsg_res nmsg_pcap_input_read(nmsg_pcap_t pcap, struct nmsg_ipdg *dg, struct timespec *ts)
Read an IP datagram from an nmsg_pcap_t input, performing reassembly if necessary.
bool nmsg_pcap_filter(nmsg_pcap_t pcap, const uint8_t *pkt, size_t len)
Return the result of filtering a packet.
int nmsg_pcap_get_datalink(nmsg_pcap_t pcap)
Get the datalink type of the underlying pcap handle.
nmsg_pcap_type nmsg_pcap_get_type(nmsg_pcap_t pcap)
Get the type of the underlying pcap handle.
nmsg_res nmsg_pcap_input_close(nmsg_pcap_t *pcap)
Close an nmsg_pcap_t object and release all associated resources.
nmsg_res nmsg_pcap_input_read_raw(nmsg_pcap_t pcap, struct pcap_pkthdr **pkt_hdr, const uint8_t **pkt_data, struct timespec *ts)
Read a raw packet from an nmsg_pcap_t input.
nmsg_res nmsg_pcap_input_setfilter(nmsg_pcap_t pcap, const char *bpfstr)
Set a bpf filter on an nmsg_pcap_t object.
nmsg_res
nmsg result code
Definition res.h:25
Parsed IP datagram.
Definition ipdg.h:31