/
context.i
131 lines (103 loc) · 4.56 KB
/
context.i
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/* Copyright 2008 (C) Nicira, Inc.
*
* This file is part of NOX.
*
* NOX is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NOX is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NOX. If not, see <http://www.gnu.org/licenses/>.
*/
%{
#include <string>
#include "pycontext.cc"
using namespace std;
using namespace vigil;
using namespace vigil::applications;
%}
%include "utf8_string.i"
// Let SWIG know that post will manage the destruction of the pyevent
%delobject PyContext::post;
%include "buffer.i"
/* For the ofp_ types */
%import "openflow.i"
/* For ethernetaddr */
%import "netinet/netinet.i"
/* To signal an unset buffer_id */
#define UINT32_MAX 4294967295U
namespace vigil {
namespace applications {
class PyContext {
%rename(send_openflow_buffer_port) send_openflow_buffer(
uint64_t datapath_id, uint32_t buffer_id,
uint16_t out_port, uint16_t in_port);
%rename(send_openflow_buffer_acts) send_openflow_buffer(
uint64_t datapath_id, uint32_t buffer_id,
const Nonowning_buffer& actions, uint16_t in_port);
%rename(send_openflow_packet_port) send_openflow_packet(
uint64_t datapath_id, const Nonowning_buffer&,
uint16_t out_port, uint16_t in_port);
%rename(send_openflow_packet_acts) send_openflow_packet(
uint64_t datapath_id, const Nonowning_buffer&,
const Nonowning_buffer& actions, uint16_t in_port);
public:
/*
* Resolves a component interface description into a component
* instance.
*/
PyObject* resolve(PyObject*);
Kernel* get_kernel();
const char* get_version();
void post(Event*);
void register_event(const Event_name&);
void register_python_event(const Event_name&);
void register_handler(const Event_name&, PyObject* callable);
uint32_t register_handler_on_match(PyObject* callable,
uint32_t priority,
const Packet_expr&);
bool unregister_handler(uint32_t rule_id);
void send_openflow_packet(uint64_t datapath_id, const Nonowning_buffer&,
uint16_t out_port, uint16_t in_port);
void send_openflow_packet(uint64_t datapath_id, const Nonowning_buffer&,
const Nonowning_buffer& actions, uint16_t in_port);
void send_openflow_buffer(uint64_t datapath_id, uint32_t buffer_id,
uint16_t out_port, uint16_t in_port);
void send_openflow_buffer(uint64_t datapath_id, uint32_t buffer_id,
const Nonowning_buffer& actions,
uint16_t in_port);
void send_flow_command(uint64_t datapath_id, ofp_flow_mod_command,
const ofp_match&, uint16_t idle_timeout,
uint16_t hard_timeout, const Nonowning_buffer& actions,
uint32_t buffer_id, uint16_t priority);
int close_openflow_connection(uint64_t datapathid);
int send_switch_command(uint64_t, const std::string, const std::string);
int switch_reset(uint64_t datapathid);
int switch_update(uint64_t datapathid);
int send_add_snat(uint64_t dpid, uint16_t port,
uint32_t ip_addr_start, uint32_t ip_addr_end,
uint16_t tcp_start, uint16_t tcp_end,
uint16_t udp_start, uint16_t udp_end,
ethernetaddr mac_addr,
uint16_t mac_timeout=0);
int send_del_snat(uint64_t dpid, uint16_t port);
uint32_t get_switch_controller_ip(uint64_t dpid);
uint32_t get_switch_ip(uint64_t dpid);
void send_table_stats_request(uint64_t datapath_id);
void send_port_stats_request(uint64_t datapath_id, uint16_t port);
void send_desc_stats_request(uint64_t datapath_id);
int send_port_mod(uint64_t datapath_id, uint16_t port_no,
ethernetaddr addr, uint32_t mask, uint32_t config);
void send_aggregate_stats_request(uint64_t datapath_ids, const
struct ofp_match& match, uint8_t table_id);
private:
PyContext();
};
} // namespace applications
} // namespace vigil