Skip to content

Commit dc072c0

Browse files
author
Jordan Holland
authored
Merge pull request #5 from nprint/organize
lint and re-org / rename for tab completion
2 parents 1128503 + e41b851 commit dc072c0

20 files changed

+74
-81
lines changed

Makefile.am

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,21 @@ AUTOMAKE_OPTIONS = subdir-objects
22

33
bin_PROGRAMS = pcapml
44

5+
56
pcapml_SOURCES = include/dir/dir.hpp include/label/label.hpp include/label/labeler.hpp \
6-
include/pcap/pcap_reader.hpp include/pcapng/pcapng_reader.hpp include/pcapng/pcapng_writer.hpp \
7-
include/pcapng/block.hpp include/pcapng/pcapng_sorter.hpp include/sample/sample.hpp \
8-
include/sample/sampler.hpp include/util.hpp include/pcapng/pcapng_splitter.hpp \
9-
include/pcap/pcap_writer.hpp \
7+
include/pcap/reader_pcap.hpp include/pcap/writer_pcap.hpp \
8+
include/pcapng/block_pcapng.hpp include/pcapng/reader_pcapng.hpp \
9+
include/pcapng/sorter_pcapng.hpp include/pcapng/splitter_pcapng.hpp \
10+
include/pcapng/writer_pcapng.hpp \
11+
include/sample/sample.hpp include/sample/sampler.hpp \
12+
include/util.hpp \
1013
src/dir/dir.cpp src/label/label.cpp src/label/labeler.cpp \
11-
src/pcap/pcap_reader.cpp src/pcapng/pcapng_reader.cpp src/pcapng/pcapng_writer.cpp \
12-
src/pcapng/block.cpp src/pcapng/pcapng_sorter.cpp src/sample/sample.cpp \
13-
src/sample/sampler.cpp src/util.cpp src/pcapml.cpp src/pcapng/pcapng_splitter.cpp \
14-
src/pcap/pcap_writer.cpp
14+
src/pcap/reader_pcap.cpp src/pcap/writer_pcap.cpp \
15+
src/pcapng/block_pcapng.cpp src/pcapng/reader_pcapng.cpp \
16+
src/pcapng/sorter_pcapng.cpp src/pcapng/splitter_pcapng.cpp \
17+
src/pcapng/writer_pcapng.cpp \
18+
src/sample/sample.cpp src/sample/sampler.cpp \
19+
src/util.cpp src/pcapml.cpp
1520

1621
AM_CPPFLAGS = -I include/ -I include/dir -I include/pcap/ -I include/pcapng -I include/sample -I include/label -pedantic -Wall -std=gnu++11 $(WRAPPER_CPPFLAGS)
1722
AM_LDFLAGS = $(WRAPPER_LDFLAGS)

include/dir/dir.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@
2424
#include <string>
2525
#include <fstream>
2626

27-
28-
#include "pcap_reader.hpp"
29-
#include "pcapng_writer.hpp"
3027
#include "util.hpp"
28+
#include "reader_pcap.hpp"
29+
#include "writer_pcapng.hpp"
3130

3231
class DirLabeler {
3332
public:

include/label/labeler.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
#include "util.hpp"
1515
#include "label.hpp"
16-
#include "pcap_reader.hpp"
17-
#include "pcapng_writer.hpp"
16+
#include "reader_pcap.hpp"
17+
#include "writer_pcapng.hpp"
1818

1919
#define LABEL_FILE_LOC 0
2020
#define FILTER_LOC 1

include/pcap/pcap_reader.hpp renamed to include/pcap/reader_pcap.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* of the License at https://www.apache.org/licenses/LICENSE-2.0
66
*/
77

8-
#ifndef INCLUDE_PCAP_PCAP_READER_HPP_
9-
#define INCLUDE_PCAP_PCAP_READER_HPP_
8+
#ifndef INCLUDE_PCAP_READER_PCAP_HPP_
9+
#define INCLUDE_PCAP_READER_PCAP_HPP_
1010

1111
#if defined(__NetBSD__)
1212
#include <net/if_ether.h>
@@ -30,4 +30,4 @@ class PcapReader {
3030
pcap_t *get_pcap_handle();
3131
};
3232

33-
#endif // INCLUDE_PCAP_PCAP_READER_HPP_
33+
#endif // INCLUDE_PCAP_READER_PCAP_HPP_

include/pcap/pcap_writer.hpp renamed to include/pcap/writer_pcap.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* of the License at https://www.apache.org/licenses/LICENSE-2.0
66
*/
77

8-
#ifndef INCLUDE_PCAP_WRITER_HPP_
9-
#define INCLUDE_PCAP_WRITER_HPP_
8+
#ifndef INCLUDE_PCAP_WRITER_PCAP_HPP_
9+
#define INCLUDE_PCAP_WRITER_PCAP_HPP_
1010

1111
#if defined(__NetBSD__)
1212
#include <net/if_ether.h>
@@ -31,4 +31,4 @@ class PcapWriter {
3131
pcap_t *get_pcap_handle();
3232
};
3333

34-
#endif // INCLUDE_PCAP_PCAP_READER_HPP_
34+
#endif // INCLUDE_PCAP_WRITER_PCAP_HPP_

include/pcapng/block.hpp renamed to include/pcapng/block_pcapng.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* of the License at https://www.apache.org/licenses/LICENSE-2.0
66
*/
77

8-
#ifndef INCLUDE_PCAPNG_BLOCK_HPP_
9-
#define INCLUDE_PCAPNG_BLOCK_HPP_
8+
#ifndef INCLUDE_PCAPNG_BLOCK_PCAPNG_HPP_
9+
#define INCLUDE_PCAPNG_BLOCK_PCAPNG_HPP_
1010

1111
#include <stdio.h>
1212
#include <stdlib.h>
@@ -102,4 +102,4 @@ class Block {
102102
};
103103

104104

105-
#endif // INCLUDE_PCAPNG_BLOCK_HPP_
105+
#endif // INCLUDE_PCAPNG_BLOCK_PCAPNG_HPP_

include/pcapng/pcapng_reader.hpp renamed to include/pcapng/reader_pcapng.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* of the License at https://www.apache.org/licenses/LICENSE-2.0
66
*/
77

8-
#ifndef INCLUDE_PCAPNG_PCAPNG_READER_HPP_
9-
#define INCLUDE_PCAPNG_PCAPNG_READER_HPP_
8+
#ifndef INCLUDE_PCAPNG_READER_PCAPNG_HPP_
9+
#define INCLUDE_PCAPNG_READER_PCAPNG_HPP_
1010

1111
#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
1212

@@ -36,7 +36,7 @@
3636
#include <algorithm>
3737

3838
#include "util.hpp"
39-
#include "block.hpp"
39+
#include "block_pcapng.hpp"
4040

4141
class PcapNGReader {
4242
public:
@@ -70,4 +70,4 @@ class PcapNGReader {
7070
void read_section_header(Block *b);
7171
};
7272

73-
#endif // INCLUDE_PCAPNG_PCAPNG_READER_HPP_
73+
#endif // INCLUDE_PCAPNG_READER_PCAPNG_HPP_

include/pcapng/pcapng_sorter.hpp renamed to include/pcapng/sorter_pcapng.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
* of the License at https://www.apache.org/licenses/LICENSE-2.0
66
*/
77

8-
#ifndef INCLUDE_PCAPNG_PCAPNG_SORTER_HPP_
9-
#define INCLUDE_PCAPNG_PCAPNG_SORTER_HPP_
8+
#ifndef INCLUDE_PCAPNG_SORTER_PCAPNG_HPP_
9+
#define INCLUDE_PCAPNG_SORTER_PCAPNG_HPP_
1010

1111
#include <vector>
1212
#include <algorithm>
1313

1414
#include "util.hpp"
15-
#include "block.hpp"
16-
#include "pcapng_reader.hpp"
15+
#include "block_pcapng.hpp"
16+
#include "reader_pcapng.hpp"
1717

1818
struct PacketSortInfo {
1919
size_t sid;
@@ -42,4 +42,4 @@ class Sorter : public PcapNGReader {
4242
std::vector<PacketSortInfo> pkt_blocks;
4343
};
4444

45-
#endif // INCLUDE_PCAPNG_PCAPNG_SORTER_HPP_
45+
#endif // INCLUDE_PCAPNG_SORTER_PCAPNG_HPP_

include/pcapng/pcapng_splitter.hpp renamed to include/pcapng/splitter_pcapng.hpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
* of the License at https://www.apache.org/licenses/LICENSE-2.0
66
*/
77

8-
#ifndef INCLUDE_PCAPNG_PCAPNG_SPLITTER_HPP_
9-
#define INCLUDE_PCAPNG_PCAPNG_SPLITTER_HPP_
8+
#ifndef INCLUDE_PCAPNG_SPLITTER_PCAPNG_HPP_
9+
#define INCLUDE_PCAPNG_SPLITTER_PCAPNG_HPP_
10+
11+
#include <string>
1012

1113
#include "util.hpp"
12-
#include "block.hpp"
13-
#include "pcapng_reader.hpp"
14-
#include "pcap_writer.hpp"
14+
#include "writer_pcap.hpp"
15+
#include "block_pcapng.hpp"
16+
#include "reader_pcapng.hpp"
1517

1618
class Splitter : public PcapNGReader {
1719
public:
@@ -23,13 +25,12 @@ class Splitter : public PcapNGReader {
2325
std::string cur_sid = "";
2426
std::string cur_metadata = "";
2527
FILE *mdf = NULL;
26-
28+
2729
FILE *fopen_mkdir(char *path);
2830
FILE *open_metadata_file(char *path);
2931
void recursive_mkdir(char *path);
3032
bool process_idb(Block *b);
3133
bool process_packet_block(Block *b);
32-
bool update_io(std::vector<std::string> &tokens);
3334
};
3435

35-
#endif // INCLUDE_PCAPNG_PCAPNG_SPLITTER_HPP_
36+
#endif // INCLUDE_PCAPNG_SPLITTER_PCAPNG_HPP_

include/pcapng/pcapng_writer.hpp renamed to include/pcapng/writer_pcapng.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* of the License at https://www.apache.org/licenses/LICENSE-2.0
66
*/
77

8-
#ifndef INCLUDE_PCAPNG_PCAPNG_WRITER_HPP_
9-
#define INCLUDE_PCAPNG_PCAPNG_WRITER_HPP_
8+
#ifndef INCLUDE_PCAPNG_WRITER_PCAPNG_HPP_
9+
#define INCLUDE_PCAPNG_WRITER_PCAPNG_HPP_
1010

1111
#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
1212

@@ -34,7 +34,7 @@
3434
#include <exception>
3535

3636
#include "util.hpp"
37-
#include "block.hpp"
37+
#include "block_pcapng.hpp"
3838

3939
class PcapNGWriter {
4040
public:
@@ -54,4 +54,4 @@ class PcapNGWriter {
5454
int pad_packet(int pkt_len);
5555
};
5656

57-
#endif // INCLUDE_PCAPNG_PCAPNG_WRITER_HPP_
57+
#endif // INCLUDE_PCAPNG_WRITER_PCAPNG_HPP_

include/sample/sampler.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
#ifndef INCLUDE_SAMPLE_SAMPLER_HPP_
99
#define INCLUDE_SAMPLE_SAMPLER_HPP_
1010

11-
#include "block.hpp"
1211
#include "sample.hpp"
13-
#include "pcapng_reader.hpp"
12+
#include "block_pcapng.hpp"
13+
#include "reader_pcapng.hpp"
1414

1515
class Sampler : public PcapNGReader {
1616
public:

include/util.hpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,24 @@
99
#define INCLUDE_UTIL_HPP_
1010

1111
#include <sys/stat.h>
12+
1213
#include <pcap.h>
1314

1415
#include <string>
1516
#include <vector>
1617
#include <sstream>
1718
#include <tuple>
1819

19-
20-
#include "block.hpp"
20+
#include "block_pcapng.hpp"
2121

2222
struct pcap_packet_info {
2323
struct pcap_pkthdr hdr;
2424
const uint8_t *buf;
2525
};
2626

27-
void tokenize_string(std::string s, std::vector<std::string> &to_fill,
28-
char delimiter);
27+
bool check_file_exists(char *f);
2928
uint64_t transform_ts(uint32_t low, uint32_t high);
3029
std::tuple<size_t, std::string> get_info_from_pkt_comment(std::string comment);
31-
bool check_file_exists(char *f);
30+
void tokenize_string(std::string s, std::vector<std::string> &to_fill, char delimiter);
3231

3332
#endif // INCLUDE_UTIL_HPP_

src/pcap/pcap_reader.cpp renamed to src/pcap/reader_pcap.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* of the License at https://www.apache.org/licenses/LICENSE-2.0
66
*/
77

8-
#include "pcap_reader.hpp"
8+
#include "reader_pcap.hpp"
99

1010
int PcapReader::open_file(char *infile) {
1111
char errbuf[PCAP_ERRBUF_SIZE];

src/pcap/pcap_writer.cpp renamed to src/pcap/writer_pcap.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* of the License at https://www.apache.org/licenses/LICENSE-2.0
66
*/
77

8-
#include "pcap_writer.hpp"
8+
#include "writer_pcap.hpp"
99

1010
int PcapWriter::open_file(char *outfile) {
1111
pd = pcap_open_dead(DLT_EN10MB, 65535 /* snaplen */);
@@ -21,5 +21,5 @@ int PcapWriter::write_packet(pcap_pkthdr *hdr, uint8_t *buf) {
2121
}
2222

2323
void PcapWriter::close_file() {
24-
if(pd != NULL) pcap_close(pd);
24+
if (pd != NULL) pcap_close(pd);
2525
}

src/pcapml.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212
#include "dir.hpp"
1313
#include "labeler.hpp"
14-
#include "pcapng_reader.hpp"
15-
#include "pcapng_sorter.hpp"
16-
#include "pcapng_splitter.hpp"
14+
#include "reader_pcapng.hpp"
15+
#include "sorter_pcapng.hpp"
16+
#include "splitter_pcapng.hpp"
1717

1818
const char *argp_program_version = "pcapml 0.0.1";
1919
const char *argp_program_bug_address = "https://github.com/nprint/pcapml";

src/pcapng/block.cpp renamed to src/pcapng/block_pcapng.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* of the License at https://www.apache.org/licenses/LICENSE-2.0
66
*/
77

8-
#include "block.hpp"
8+
#include "block_pcapng.hpp"
99

1010
Block::Block(BlockHeader *bh, uint64_t f_start) {
1111
this->bh = bh;

src/pcapng/pcapng_reader.cpp renamed to src/pcapng/reader_pcapng.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* of the License at https://www.apache.org/licenses/LICENSE-2.0
66
*/
77

8-
#include "pcapng_reader.hpp"
8+
#include "reader_pcapng.hpp"
99

1010
int PcapNGReader::open_pcapng(char *infile) {
1111
packets_processed = 0;

src/pcapng/pcapng_sorter.cpp renamed to src/pcapng/sorter_pcapng.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* of the License at https://www.apache.org/licenses/LICENSE-2.0
66
*/
77

8-
#include "pcapng_sorter.hpp"
8+
#include "sorter_pcapng.hpp"
99

1010
bool Sorter::process_block(Block *b, void *p) {
1111
uint32_t block_type;

0 commit comments

Comments
 (0)