Skip to content

Commit 5ca0fd6

Browse files
committed
Added packetcapture API
1 parent 345c9ff commit 5ca0fd6

9 files changed

Lines changed: 1793 additions & 0 deletions

File tree

src/services/pcn-packetcapture/src/api/PacketcaptureApi.cpp

Lines changed: 1199 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**
2+
* packetcapture API generated from packetcapture.yang
3+
*
4+
* NOTE: This file is auto generated by polycube-codegen
5+
* https://github.com/polycube-network/polycube-codegen
6+
*/
7+
8+
9+
/* Do not edit this file manually */
10+
11+
12+
#include "FiltersBase.h"
13+
#include "../Packetcapture.h"
14+
15+
16+
FiltersBase::FiltersBase(Packetcapture &parent)
17+
: parent_(parent) {}
18+
19+
FiltersBase::~FiltersBase() {}
20+
21+
void FiltersBase::update(const FiltersJsonObject &conf) {
22+
23+
if (conf.snaplenIsSet()) {
24+
setSnaplen(conf.getSnaplen());
25+
}
26+
if (conf.srcIsSet()) {
27+
setSrc(conf.getSrc());
28+
}
29+
if (conf.dstIsSet()) {
30+
setDst(conf.getDst());
31+
}
32+
if (conf.l4protoIsSet()) {
33+
setL4proto(conf.getL4proto());
34+
}
35+
if (conf.sportIsSet()) {
36+
setSport(conf.getSport());
37+
}
38+
if (conf.dportIsSet()) {
39+
setDport(conf.getDport());
40+
}
41+
}
42+
43+
FiltersJsonObject FiltersBase::toJsonObject() {
44+
FiltersJsonObject conf;
45+
46+
conf.setSnaplen(getSnaplen());
47+
conf.setSrc(getSrc());
48+
conf.setDst(getDst());
49+
conf.setL4proto(getL4proto());
50+
conf.setSport(getSport());
51+
conf.setDport(getDport());
52+
53+
return conf;
54+
}
55+
56+
std::shared_ptr<spdlog::logger> FiltersBase::logger() {
57+
return parent_.logger();
58+
}
59+
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/**
2+
* packetcapture API generated from packetcapture.yang
3+
*
4+
* NOTE: This file is auto generated by polycube-codegen
5+
* https://github.com/polycube-network/polycube-codegen
6+
*/
7+
8+
9+
/* Do not edit this file manually */
10+
11+
/*
12+
* FiltersBase.h
13+
*
14+
*
15+
*/
16+
17+
#pragma once
18+
19+
#include "../serializer/FiltersJsonObject.h"
20+
21+
22+
23+
24+
25+
26+
#include <spdlog/spdlog.h>
27+
28+
using namespace polycube::service::model;
29+
30+
class Packetcapture;
31+
32+
class FiltersBase {
33+
public:
34+
35+
FiltersBase(Packetcapture &parent);
36+
37+
virtual ~FiltersBase();
38+
virtual void update(const FiltersJsonObject &conf);
39+
virtual FiltersJsonObject toJsonObject();
40+
41+
/// <summary>
42+
/// Snapshot length
43+
/// </summary>
44+
virtual uint32_t getSnaplen() = 0;
45+
virtual void setSnaplen(const uint32_t &value) = 0;
46+
47+
/// <summary>
48+
/// IP source filter
49+
/// </summary>
50+
virtual std::string getSrc() = 0;
51+
virtual void setSrc(const std::string &value) = 0;
52+
53+
/// <summary>
54+
/// IP destination filter
55+
/// </summary>
56+
virtual std::string getDst() = 0;
57+
virtual void setDst(const std::string &value) = 0;
58+
59+
/// <summary>
60+
/// Level 4 protocol filter
61+
/// </summary>
62+
virtual std::string getL4proto() = 0;
63+
virtual void setL4proto(const std::string &value) = 0;
64+
65+
/// <summary>
66+
/// Source port filter
67+
/// </summary>
68+
virtual uint16_t getSport() = 0;
69+
virtual void setSport(const uint16_t &value) = 0;
70+
71+
/// <summary>
72+
/// Destination port filter
73+
/// </summary>
74+
virtual uint16_t getDport() = 0;
75+
virtual void setDport(const uint16_t &value) = 0;
76+
77+
std::shared_ptr<spdlog::logger> logger();
78+
protected:
79+
Packetcapture &parent_;
80+
};
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/**
2+
* packetcapture API generated from packetcapture.yang
3+
*
4+
* NOTE: This file is auto generated by polycube-codegen
5+
* https://github.com/polycube-network/polycube-codegen
6+
*/
7+
8+
9+
/* Do not edit this file manually */
10+
11+
12+
#include "GlobalheaderBase.h"
13+
#include "../Packetcapture.h"
14+
15+
16+
GlobalheaderBase::GlobalheaderBase(Packetcapture &parent)
17+
: parent_(parent) {}
18+
19+
GlobalheaderBase::~GlobalheaderBase() {}
20+
21+
void GlobalheaderBase::update(const GlobalheaderJsonObject &conf) {
22+
23+
if (conf.magicIsSet()) {
24+
setMagic(conf.getMagic());
25+
}
26+
if (conf.versionMajorIsSet()) {
27+
setVersionMajor(conf.getVersionMajor());
28+
}
29+
if (conf.versionMinorIsSet()) {
30+
setVersionMinor(conf.getVersionMinor());
31+
}
32+
if (conf.thiszoneIsSet()) {
33+
setThiszone(conf.getThiszone());
34+
}
35+
if (conf.sigfigsIsSet()) {
36+
setSigfigs(conf.getSigfigs());
37+
}
38+
if (conf.snaplenIsSet()) {
39+
setSnaplen(conf.getSnaplen());
40+
}
41+
if (conf.linktypeIsSet()) {
42+
setLinktype(conf.getLinktype());
43+
}
44+
}
45+
46+
GlobalheaderJsonObject GlobalheaderBase::toJsonObject() {
47+
GlobalheaderJsonObject conf;
48+
49+
conf.setMagic(getMagic());
50+
conf.setVersionMajor(getVersionMajor());
51+
conf.setVersionMinor(getVersionMinor());
52+
conf.setThiszone(getThiszone());
53+
conf.setSigfigs(getSigfigs());
54+
conf.setSnaplen(getSnaplen());
55+
conf.setLinktype(getLinktype());
56+
57+
return conf;
58+
}
59+
60+
std::shared_ptr<spdlog::logger> GlobalheaderBase::logger() {
61+
return parent_.logger();
62+
}
63+
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/**
2+
* packetcapture API generated from packetcapture.yang
3+
*
4+
* NOTE: This file is auto generated by polycube-codegen
5+
* https://github.com/polycube-network/polycube-codegen
6+
*/
7+
8+
9+
/* Do not edit this file manually */
10+
11+
/*
12+
* GlobalheaderBase.h
13+
*
14+
*
15+
*/
16+
17+
#pragma once
18+
19+
#include "../serializer/GlobalheaderJsonObject.h"
20+
21+
22+
23+
24+
25+
26+
#include <spdlog/spdlog.h>
27+
28+
using namespace polycube::service::model;
29+
30+
class Packetcapture;
31+
32+
class GlobalheaderBase {
33+
public:
34+
35+
GlobalheaderBase(Packetcapture &parent);
36+
37+
virtual ~GlobalheaderBase();
38+
virtual void update(const GlobalheaderJsonObject &conf);
39+
virtual GlobalheaderJsonObject toJsonObject();
40+
41+
/// <summary>
42+
/// magic number
43+
/// </summary>
44+
virtual uint32_t getMagic() = 0;
45+
virtual void setMagic(const uint32_t &value) = 0;
46+
47+
/// <summary>
48+
/// major version number
49+
/// </summary>
50+
virtual uint16_t getVersionMajor() = 0;
51+
virtual void setVersionMajor(const uint16_t &value) = 0;
52+
53+
/// <summary>
54+
/// minor version number
55+
/// </summary>
56+
virtual uint16_t getVersionMinor() = 0;
57+
virtual void setVersionMinor(const uint16_t &value) = 0;
58+
59+
/// <summary>
60+
/// GMT to local correction
61+
/// </summary>
62+
virtual int32_t getThiszone() = 0;
63+
virtual void setThiszone(const int32_t &value) = 0;
64+
65+
/// <summary>
66+
/// accuracy of timestamps
67+
/// </summary>
68+
virtual uint32_t getSigfigs() = 0;
69+
virtual void setSigfigs(const uint32_t &value) = 0;
70+
71+
/// <summary>
72+
/// max length of captured packets, in octets
73+
/// </summary>
74+
virtual uint32_t getSnaplen() = 0;
75+
virtual void setSnaplen(const uint32_t &value) = 0;
76+
77+
/// <summary>
78+
/// Capture linktype (eg. ethernet, wifi..)
79+
/// </summary>
80+
virtual uint32_t getLinktype() = 0;
81+
virtual void setLinktype(const uint32_t &value) = 0;
82+
83+
std::shared_ptr<spdlog::logger> logger();
84+
protected:
85+
Packetcapture &parent_;
86+
};
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
* packetcapture API generated from packetcapture.yang
3+
*
4+
* NOTE: This file is auto generated by polycube-codegen
5+
* https://github.com/polycube-network/polycube-codegen
6+
*/
7+
8+
9+
/* Do not edit this file manually */
10+
11+
12+
#include "PacketBase.h"
13+
#include "../Packetcapture.h"
14+
15+
16+
PacketBase::PacketBase(Packetcapture &parent)
17+
: parent_(parent) {}
18+
19+
PacketBase::~PacketBase() {}
20+
21+
void PacketBase::update(const PacketJsonObject &conf) {
22+
23+
if (conf.capturelenIsSet()) {
24+
setCapturelen(conf.getCapturelen());
25+
}
26+
if (conf.packetlenIsSet()) {
27+
setPacketlen(conf.getPacketlen());
28+
}
29+
if (conf.timestampSecondsIsSet()) {
30+
setTimestampSeconds(conf.getTimestampSeconds());
31+
}
32+
if (conf.timestampMicrosecondsIsSet()) {
33+
setTimestampMicroseconds(conf.getTimestampMicroseconds());
34+
}
35+
if (conf.rawdataIsSet()) {
36+
setRawdata(conf.getRawdata());
37+
}
38+
}
39+
40+
PacketJsonObject PacketBase::toJsonObject() {
41+
PacketJsonObject conf;
42+
43+
conf.setCapturelen(getCapturelen());
44+
conf.setPacketlen(getPacketlen());
45+
conf.setTimestampSeconds(getTimestampSeconds());
46+
conf.setTimestampMicroseconds(getTimestampMicroseconds());
47+
conf.setRawdata(getRawdata());
48+
49+
return conf;
50+
}
51+
52+
std::shared_ptr<spdlog::logger> PacketBase::logger() {
53+
return parent_.logger();
54+
}
55+

0 commit comments

Comments
 (0)