8 #ifndef COFMSG_PACKET_IN_H_
9 #define COFMSG_PACKET_IN_H_ 1
11 #include "rofl/common/openflow/messages/cofmsg.h"
12 #include "rofl/common/openflow/cofmatch.h"
13 #include "rofl/common/cpacket.h"
30 uint8_t* ofhu_packet_in;
36 #define ofh_packet_in ofhu.ofhu_packet_in
37 #define ofh10_packet_in ofhu.ofhu10_packet_in
38 #define ofh12_packet_in ofhu.ofhu12_packet_in
39 #define ofh13_packet_in ofhu.ofhu13_packet_in
41 #define OFP10_PACKET_IN_STATIC_HDR_LEN (sizeof(struct openflow10::ofp_packet_in) - 2)
42 #define OFP12_PACKET_IN_STATIC_HDR_LEN (sizeof(struct openflow12::ofp_packet_in) - sizeof(struct openflow12::ofp_match)) // length without struct openflow12::ofp_match
43 #define OFP13_PACKET_IN_STATIC_HDR_LEN (sizeof(struct openflow13::ofp_packet_in) - sizeof(struct openflow13::ofp_match)) // length without struct openflow13::ofp_match
52 uint8_t of_version = 0,
54 uint32_t buffer_id = 0,
55 uint16_t total_len = 0,
58 uint64_t of13_cookie = 0,
59 uint16_t of10_in_port = 0,
61 uint8_t *data = (uint8_t*)0,
118 pack(uint8_t *buf = (uint8_t*)0,
size_t buflen = 0);
125 unpack(uint8_t *buf,
size_t buflen);
141 get_buffer_id()
const;
147 set_buffer_id(uint32_t buffer_id);
153 get_total_len()
const;
159 set_total_len(uint16_t total_len);
171 set_reason(uint8_t reason);
177 get_table_id()
const;
183 set_table_id(uint8_t table_id);
213 set_match() {
return match; };
219 get_match()
const {
return match; };
225 set_packet() {
return packet; };
231 get_packet()
const {
return packet; };
237 os << dynamic_cast<cofmsg const&>( msg );
238 os <<
indent(2) <<
"<cofmsg_packet_in >" << std::endl;
239 switch (msg.get_version()) {
240 case openflow10::OFP_VERSION: {
242 os <<
indent(4) <<
"<buffer-id:" << (int)msg.get_buffer_id() <<
" >" << std::endl;
243 os <<
indent(4) <<
"<total-len:" << (int)msg.get_total_len() <<
" >" << std::endl;
244 switch (msg.get_reason()) {
245 case rofl::openflow10::OFPR_NO_MATCH: {
246 os <<
indent(4) <<
"<reason: NO-MATCH >" << std::endl;
248 case rofl::openflow10::OFPR_ACTION: {
249 os <<
indent(4) <<
"<reason: ACTION >" << std::endl;
252 os <<
indent(4) <<
"<reason:" << (int)msg.get_reason() <<
" >" << std::endl;
257 case openflow12::OFP_VERSION: {
258 os <<
indent(4) <<
"<buffer-id:" << (int)msg.get_buffer_id() <<
" >" << std::endl;
259 os <<
indent(4) <<
"<total-len:" << (int)msg.get_total_len() <<
" >" << std::endl;
260 switch (msg.get_reason()) {
261 case rofl::openflow12::OFPR_NO_MATCH: {
262 os <<
indent(4) <<
"<reason: NO-MATCH >" << std::endl;
264 case rofl::openflow12::OFPR_ACTION: {
265 os <<
indent(4) <<
"<reason: ACTION >" << std::endl;
267 case rofl::openflow12::OFPR_INVALID_TTL: {
268 os <<
indent(4) <<
"<reason: INVALID-TTL >" << std::endl;
271 os <<
indent(4) <<
"<reason:" << (int)msg.get_reason() <<
" >" << std::endl;
274 os <<
indent(4) <<
"<table-id:" << (int)msg.get_table_id() <<
" >" << std::endl;
277 case openflow13::OFP_VERSION: {
278 os <<
indent(4) <<
"<buffer-id:" << (int)msg.get_buffer_id() <<
" >" << std::endl;
279 os <<
indent(4) <<
"<total-len:" << (int)msg.get_total_len() <<
" >" << std::endl;
280 switch (msg.get_reason()) {
281 case rofl::openflow13::OFPR_NO_MATCH: {
282 os <<
indent(4) <<
"<reason: NO-MATCH >" << std::endl;
284 case rofl::openflow13::OFPR_ACTION: {
285 os <<
indent(4) <<
"<reason: ACTION >" << std::endl;
287 case rofl::openflow13::OFPR_INVALID_TTL: {
288 os <<
indent(4) <<
"<reason: INVALID-TTL >" << std::endl;
291 os <<
indent(4) <<
"<reason:" << (int)msg.get_reason() <<
" >" << std::endl;
294 os <<
indent(4) <<
"<table-id: " << (int)msg.get_table_id() <<
" >" << std::endl;
295 os <<
indent(4) <<
"<cookie: 0x" << std::hex << (
unsigned long long)msg.
get_cookie() << std::dec <<
" >" << std::endl;
299 os <<
"<unsupported OF version: " << (int)msg.get_version() <<
" >" << std::endl;
302 os <<
indent(2) << msg.match;
303 os <<
indent(2) << msg.packet;
uint16_t get_in_port() const
Definition: cofmsg_packet_in.cc:455
virtual void pack(uint8_t *buf=(uint8_t *) 0, size_t buflen=0)
Definition: cofmsg_packet_in.cc:151
virtual void unpack(uint8_t *buf, size_t buflen)
Definition: cofmsg_packet_in.cc:194
Definition: openflow13.h:1678
virtual void validate()
Definition: cofmsg_packet_in.cc:204
Definition: cofmsg_packet_in.h:21
virtual size_t length() const
Definition: cofmsg_packet_in.cc:129
virtual void reset()
Definition: cofmsg_packet_in.cc:111
Definition: cofmatch.h:35
void set_cookie(uint64_t cookie)
Definition: cofmsg_packet_in.cc:499
uint64_t get_cookie() const
Definition: cofmsg_packet_in.cc:484
Definition: openflow10.h:325
C++ abstraction for malloc'ed memory areas.
Definition: cmemory.h:44
Definition: openflow12.h:591
void set_in_port(uint16_t port_no)
Definition: cofmsg_packet_in.cc:470
cofmsg_packet_in(uint8_t of_version=0, uint32_t xid=0, uint32_t buffer_id=0, uint16_t total_len=0, uint8_t reason=0, uint8_t table_id=0, uint64_t of13_cookie=0, uint16_t of10_in_port=0, cofmatch const &match=cofmatch(), uint8_t *data=(uint8_t *) 0, size_t datalen=0)
Definition: cofmsg_packet_in.cc:5
virtual ~cofmsg_packet_in()
Definition: cofmsg_packet_in.cc:103