forked from the-tcpdump-group/libpcap
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Byte-swap the T and L in TLVs as necessary when reading an NFLOG file.
That means that, when reading a LINKTYPE_NFLOG file, the type and length values are in the byte order of the host *reading* the file, rather than the host that *wrote* the file, just as they're in the byte order of the host capturing the traffic if you're doing a live capture of NFLOG messages. That way, when reading a LINKTYPE_NFLOG file and writing another one from those packets, the type and length in the output file will be in the byte order of the host writing the file, rather than the byte order of the host that wrote the input file. Export the nflog.h file containing the declarations and definitions we need, for use by tcpdump and other programs reading LINKTYPE_NFLOG files. Put the bulk of the byte-swapping code into a common routine, for use by pcap and pcap-ng readers, while we're at it.
- Loading branch information
Showing
6 changed files
with
154 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (c) 2013, Petar Alilovic, | ||
* Faculty of Electrical Engineering and Computing, University of Zagreb | ||
* All rights reserved | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* * Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* * Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. | ||
*/ | ||
|
||
#ifndef _PCAP_NFLOG_H__ | ||
#define _PCAP_NFLOG_H__ | ||
|
||
/* | ||
* Structure of an NFLOG header and TLV parts, as described at | ||
* http://www.tcpdump.org/linktypes/LINKTYPE_NFLOG.html | ||
* | ||
* The NFLOG header is big-endian. | ||
* | ||
* The TLV length and type are in host byte order. The value is either | ||
* big-endian or is an array of bytes in some externally-specified byte | ||
* order (text string, link-layer address, link-layer header, packet | ||
* data, etc.). | ||
*/ | ||
typedef struct nflog_hdr { | ||
u_int8_t nflog_family; /* adress family */ | ||
u_int8_t nflog_version; /* version */ | ||
u_int16_t nflog_rid; /* resource ID */ | ||
} nflog_hdr_t; | ||
|
||
typedef struct nflog_tlv { | ||
u_int16_t tlv_length; /* tlv length */ | ||
u_int16_t tlv_type; /* tlv type */ | ||
void* tlv_value; /* tlv value */ | ||
} nflog_tlv_t; | ||
|
||
/* | ||
* TLV types. | ||
*/ | ||
#define NFULA_PAYLOAD 9 /* packet payload */ | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters