trema 0.3.16 → 0.3.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.rvmrc +52 -0
- data/.travis.yml +3 -0
- data/Gemfile +1 -1
- data/Rakefile +259 -1
- data/Rantfile +79 -216
- data/features/.nav +12 -0
- data/features/dsl/switch_port_specifier.feature +15 -0
- data/features/examples/switch-event/C-add_forward_entry.feature +130 -0
- data/features/examples/switch-event/C-delete_forward_entry.feature +97 -0
- data/features/examples/switch-event/C-dump_forward_entries.feature +80 -0
- data/features/examples/switch-event/C-set_forward_entries.feature +85 -0
- data/features/examples/switch-event/README.md +40 -0
- data/features/examples/switch-event/add_forward_entry.feature +142 -0
- data/features/examples/switch-event/delete_forward_entry.feature +142 -0
- data/features/examples/switch-event/dump_forward_entries.feature +91 -0
- data/features/examples/switch-event/set_forward_entries.feature +90 -0
- data/features/support/hooks.rb +1 -0
- data/ruby/rake/c/dependency.rb +42 -0
- data/ruby/rake/c/library-task.rb +142 -0
- data/ruby/rake/c/shared-library-task.rb +38 -0
- data/ruby/rake/c/static-library-task.rb +32 -0
- data/ruby/trema/path.rb +1 -0
- data/ruby/trema/switch-event.c +647 -0
- data/{src/switch_manager/management_interface.h → ruby/trema/switch-event.h} +7 -21
- data/ruby/trema/trema.c +2 -0
- data/ruby/trema/version.rb +1 -1
- data/spec/spec_helper.rb +26 -2
- data/src/examples/switch_event_config/.gitignore +7 -0
- data/src/examples/switch_event_config/add_forward_entry.c +227 -0
- data/src/examples/switch_event_config/delete_forward_entry.c +226 -0
- data/src/examples/switch_event_config/dump_forward_entries.c +190 -0
- data/src/examples/switch_event_config/set_forward_entries.c +210 -0
- data/src/lib/event_forward_interface.c +783 -0
- data/src/lib/event_forward_interface.h +138 -0
- data/src/lib/trema.h +1 -0
- data/src/lib/utility.c +13 -1
- data/src/lib/utility.h +3 -0
- data/src/switch_manager/event_forward_entry_manipulation.c +120 -0
- data/src/switch_manager/event_forward_entry_manipulation.h +31 -0
- data/src/switch_manager/secure_channel_listener.c +23 -3
- data/src/switch_manager/switch.c +99 -29
- data/src/switch_manager/switch_manager.c +176 -3
- data/src/switch_manager/switch_manager.h +4 -0
- data/src/switch_manager/switch_option.c +30 -0
- data/src/switch_manager/switch_option.h +41 -0
- data/trema.gemspec +2 -1
- data/unittests/lib/event_forward_interface_test.c +1646 -0
- data/unittests/lib/utility_test.c +23 -1
- metadata +48 -10
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* Copyright (C)
|
2
|
+
* Copyright (C) 2013 NEC Corporation
|
3
3
|
*
|
4
4
|
* This program is free software; you can redistribute it and/or modify
|
5
5
|
* it under the terms of the GNU General Public License, version 2, as
|
@@ -15,27 +15,13 @@
|
|
15
15
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
16
16
|
*/
|
17
17
|
|
18
|
+
#ifndef SWITCH_EVENT_H_
|
19
|
+
#define SWITCH_EVENT_H_
|
18
20
|
|
19
|
-
#
|
20
|
-
#define MANAGEMENT_INTERFACE_H
|
21
|
+
#include "ruby.h"
|
21
22
|
|
23
|
+
extern VALUE mSwitchEvent;
|
22
24
|
|
23
|
-
|
25
|
+
void Init_switch_event( void );
|
24
26
|
|
25
|
-
|
26
|
-
enum {
|
27
|
-
DUMP_XID_TABLE = 0,
|
28
|
-
DUMP_COOKIE_TABLE,
|
29
|
-
TOGGLE_COOKIE_AGING,
|
30
|
-
};
|
31
|
-
|
32
|
-
|
33
|
-
#endif // MANAGEMENT_INTERFACE_H
|
34
|
-
|
35
|
-
|
36
|
-
/*
|
37
|
-
* Local variables:
|
38
|
-
* c-basic-offset: 2
|
39
|
-
* indent-tabs-mode: nil
|
40
|
-
* End:
|
41
|
-
*/
|
27
|
+
#endif /* SWITCH_EVENT_H_ */
|
data/ruby/trema/trema.c
CHANGED
@@ -45,6 +45,7 @@
|
|
45
45
|
#include "stats-reply.h"
|
46
46
|
#include "stats-request.h"
|
47
47
|
#include "switch.h"
|
48
|
+
#include "switch-event.h"
|
48
49
|
#include "vendor.h"
|
49
50
|
|
50
51
|
|
@@ -108,6 +109,7 @@ Init_trema() {
|
|
108
109
|
Init_stats_reply();
|
109
110
|
Init_stats_request();
|
110
111
|
Init_switch();
|
112
|
+
Init_switch_event();
|
111
113
|
Init_vendor();
|
112
114
|
|
113
115
|
rb_require( "trema/exact-match" );
|
data/ruby/trema/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -127,14 +127,14 @@ class Network
|
|
127
127
|
@th_controller = Thread.start do
|
128
128
|
controller.run!
|
129
129
|
end
|
130
|
-
|
130
|
+
wait_until_controller_is_up app_name
|
131
131
|
end
|
132
132
|
|
133
133
|
|
134
134
|
def trema_kill
|
135
135
|
cleanup_current_session
|
136
136
|
@th_controller.join if @th_controller
|
137
|
-
|
137
|
+
wait_until_all_pid_files_are_deleted
|
138
138
|
end
|
139
139
|
|
140
140
|
|
@@ -145,6 +145,30 @@ class Network
|
|
145
145
|
ofctl.add_flow switch, :dl_type => "0x0800", :nw_src => each.ip, :priority => 1, :actions => "controller"
|
146
146
|
end
|
147
147
|
end
|
148
|
+
|
149
|
+
|
150
|
+
def wait_until_controller_is_up trema_name, timeout = 10
|
151
|
+
elapsed = 0
|
152
|
+
loop do
|
153
|
+
raise "Timed out waiting for #{ trema_name }." if elapsed > timeout
|
154
|
+
break if FileTest.exists?( File.join( Trema.pid, "#{ trema_name }.pid" ) )
|
155
|
+
sleep 1
|
156
|
+
elapsed += 1
|
157
|
+
end
|
158
|
+
sleep 1
|
159
|
+
end
|
160
|
+
|
161
|
+
|
162
|
+
def wait_until_all_pid_files_are_deleted timeout = 10
|
163
|
+
elapsed = 0
|
164
|
+
loop do
|
165
|
+
raise "Failed to clean up remaining processes." if elapsed > timeout
|
166
|
+
break if Dir.glob( File.join( Trema.pid, "*.pid" ) ).empty?
|
167
|
+
sleep 1
|
168
|
+
elapsed += 1
|
169
|
+
end
|
170
|
+
sleep 1
|
171
|
+
end
|
148
172
|
end
|
149
173
|
|
150
174
|
|
@@ -0,0 +1,227 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (C) 2013 NEC Corporation
|
3
|
+
*
|
4
|
+
* This program is free software; you can redistribute it and/or modify
|
5
|
+
* it under the terms of the GNU General Public License, version 2, as
|
6
|
+
* published by the Free Software Foundation.
|
7
|
+
*
|
8
|
+
* This program is distributed in the hope that it will be useful,
|
9
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
* GNU General Public License for more details.
|
12
|
+
*
|
13
|
+
* You should have received a copy of the GNU General Public License along
|
14
|
+
* with this program; if not, write to the Free Software Foundation, Inc.,
|
15
|
+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
16
|
+
*/
|
17
|
+
|
18
|
+
|
19
|
+
#include <getopt.h>
|
20
|
+
#include "trema.h"
|
21
|
+
|
22
|
+
|
23
|
+
static bool operate_on_all = true;
|
24
|
+
static bool sw_manager = true;
|
25
|
+
static uint64_t dpid;
|
26
|
+
static enum efi_event_type type;
|
27
|
+
static const char *service_name = NULL;
|
28
|
+
|
29
|
+
static struct option long_options[] = {
|
30
|
+
{ "manager", 0, NULL, 'm' },
|
31
|
+
{ "switch", 1, NULL, 's' },
|
32
|
+
{ "type", 1, NULL, 't' },
|
33
|
+
{ NULL, 0, NULL, 0 },
|
34
|
+
};
|
35
|
+
|
36
|
+
static char short_options[] = "ms:t:";
|
37
|
+
|
38
|
+
|
39
|
+
void
|
40
|
+
usage() {
|
41
|
+
printf(
|
42
|
+
"Add OpenFlow Switch Manager/Daemon event forward entry.\n"
|
43
|
+
" Both Switch Mgr/Daemon: %s -t EVENT_TYPE service_name\n"
|
44
|
+
" Only Switch Manager : %s -m -t EVENT_TYPE service_name\n"
|
45
|
+
" Only Switch Daemon : %s -s SWITCH_DPID -t EVENT_TYPE service_name\n"
|
46
|
+
"\n"
|
47
|
+
" EVENT_TYPE:\n"
|
48
|
+
" -t, --type={vendor,packet_in,port_status,state_notify} Specify event type.\n"
|
49
|
+
" TREMA COMMON:\n"
|
50
|
+
" -n, --name=SERVICE_NAME service name\n"
|
51
|
+
" -d, --daemonize run in the background\n"
|
52
|
+
" -l, --logging_level=LEVEL set logging level\n"
|
53
|
+
" -g, --syslog output log messages to syslog\n"
|
54
|
+
" -f, --logging_facility=FACILITY set syslog facility\n"
|
55
|
+
" -h, --help display this help and exit\n"
|
56
|
+
, get_executable_name()
|
57
|
+
, get_executable_name()
|
58
|
+
, get_executable_name()
|
59
|
+
);
|
60
|
+
}
|
61
|
+
|
62
|
+
|
63
|
+
static bool
|
64
|
+
parse_argument( int argc, char *argv[] ) {
|
65
|
+
|
66
|
+
bool type_specified = false;
|
67
|
+
|
68
|
+
int c;
|
69
|
+
while ( ( c = getopt_long( argc, argv, short_options, long_options, NULL ) ) != -1 ) {
|
70
|
+
switch ( c ) {
|
71
|
+
case 'm':
|
72
|
+
sw_manager = true;
|
73
|
+
operate_on_all = false;
|
74
|
+
break;
|
75
|
+
|
76
|
+
case 's':
|
77
|
+
sw_manager = false;
|
78
|
+
operate_on_all = false;
|
79
|
+
if ( !string_to_datapath_id( optarg, &dpid ) ) {
|
80
|
+
error( "Invalid dpid '%s' specified. ", optarg );
|
81
|
+
usage();
|
82
|
+
exit( EXIT_SUCCESS );
|
83
|
+
return false;
|
84
|
+
}
|
85
|
+
break;
|
86
|
+
|
87
|
+
case 't': // add
|
88
|
+
type_specified = true;
|
89
|
+
if ( false ) {
|
90
|
+
}
|
91
|
+
else if ( strcasecmp( "vendor", optarg ) == 0 ) {
|
92
|
+
type = EVENT_FORWARD_TYPE_VENDOR;
|
93
|
+
}
|
94
|
+
else if ( strcasecmp( "packet_in", optarg ) == 0 ) {
|
95
|
+
type = EVENT_FORWARD_TYPE_PACKET_IN;
|
96
|
+
}
|
97
|
+
else if ( strcasecmp( "port_status", optarg ) == 0 ) {
|
98
|
+
type = EVENT_FORWARD_TYPE_PORT_STATUS;
|
99
|
+
}
|
100
|
+
else if ( strcasecmp( "state_notify", optarg ) == 0 ) {
|
101
|
+
type = EVENT_FORWARD_TYPE_STATE_NOTIFY;
|
102
|
+
}
|
103
|
+
else {
|
104
|
+
error( "Invalid type '%s' specified. Must e one of vendor, packet_in, port_status, or state_notify\n", optarg );
|
105
|
+
usage();
|
106
|
+
exit( EXIT_SUCCESS );
|
107
|
+
return false;
|
108
|
+
}
|
109
|
+
break;
|
110
|
+
|
111
|
+
|
112
|
+
default:
|
113
|
+
error( "Encountered unknown option." );
|
114
|
+
usage();
|
115
|
+
exit( EXIT_SUCCESS );
|
116
|
+
return false;
|
117
|
+
break;
|
118
|
+
}
|
119
|
+
}
|
120
|
+
|
121
|
+
if ( !type_specified ) {
|
122
|
+
error( "Event Type was not specified with -t option.\n" );
|
123
|
+
usage();
|
124
|
+
exit( EXIT_SUCCESS );
|
125
|
+
return false;
|
126
|
+
}
|
127
|
+
|
128
|
+
if ( optind >= argc ) {
|
129
|
+
error( "Service name was not specified.\n" );
|
130
|
+
usage();
|
131
|
+
exit( EXIT_FAILURE );
|
132
|
+
return false;
|
133
|
+
}
|
134
|
+
|
135
|
+
service_name = argv[ optind ];
|
136
|
+
|
137
|
+
return true;
|
138
|
+
}
|
139
|
+
|
140
|
+
|
141
|
+
static void
|
142
|
+
timeout( void *user_data ) {
|
143
|
+
UNUSED( user_data );
|
144
|
+
|
145
|
+
error( "Request timed out." );
|
146
|
+
stop_trema();
|
147
|
+
exit( EXIT_FAILURE );
|
148
|
+
}
|
149
|
+
|
150
|
+
|
151
|
+
static void
|
152
|
+
update_result_all_callback( enum efi_result result, void *user_data ) {
|
153
|
+
UNUSED( user_data );
|
154
|
+
if ( result == EFI_OPERATION_SUCCEEDED ) {
|
155
|
+
info( "Operation Succeeded." );
|
156
|
+
stop_trema();
|
157
|
+
}
|
158
|
+
else {
|
159
|
+
error( "Operation Failed." );
|
160
|
+
stop_trema();
|
161
|
+
exit( EXIT_FAILURE );
|
162
|
+
}
|
163
|
+
}
|
164
|
+
|
165
|
+
|
166
|
+
static void
|
167
|
+
update_result_callback( event_forward_operation_result result, void *user_data) {
|
168
|
+
UNUSED( user_data );
|
169
|
+
|
170
|
+
if ( result.result != EFI_OPERATION_SUCCEEDED ) {
|
171
|
+
error( "Operation Failed." );
|
172
|
+
stop_trema();
|
173
|
+
exit( EXIT_FAILURE );
|
174
|
+
}
|
175
|
+
else {
|
176
|
+
if ( result.n_services == 0 ) {
|
177
|
+
info( "Updated service name list is empty.");
|
178
|
+
}
|
179
|
+
else {
|
180
|
+
info( "Updated service name list:" );
|
181
|
+
unsigned i;
|
182
|
+
for ( i = 0; i < result.n_services; ++i ) {
|
183
|
+
info( " %s", result.services[ i ] );
|
184
|
+
}
|
185
|
+
}
|
186
|
+
stop_trema();
|
187
|
+
}
|
188
|
+
}
|
189
|
+
|
190
|
+
|
191
|
+
static void
|
192
|
+
send_efi_request( void ) {
|
193
|
+
info( "Adding '%s'... ", service_name );
|
194
|
+
if ( operate_on_all ) {
|
195
|
+
add_event_forward_entry_to_all_switches( type, service_name,
|
196
|
+
update_result_all_callback, NULL );
|
197
|
+
}
|
198
|
+
else {
|
199
|
+
if ( sw_manager ) {
|
200
|
+
add_switch_manager_event_forward_entry( type, service_name,
|
201
|
+
update_result_callback, NULL );
|
202
|
+
}
|
203
|
+
else {
|
204
|
+
add_switch_event_forward_entry( dpid, type, service_name,
|
205
|
+
update_result_callback, NULL );
|
206
|
+
}
|
207
|
+
}
|
208
|
+
}
|
209
|
+
|
210
|
+
|
211
|
+
int
|
212
|
+
main( int argc, char *argv[] ) {
|
213
|
+
init_trema( &argc, &argv );
|
214
|
+
parse_argument( argc, argv );
|
215
|
+
|
216
|
+
init_event_forward_interface();
|
217
|
+
|
218
|
+
send_efi_request();
|
219
|
+
|
220
|
+
add_periodic_event_callback( 30, timeout, NULL );
|
221
|
+
|
222
|
+
start_trema();
|
223
|
+
|
224
|
+
finalize_event_forward_interface();
|
225
|
+
|
226
|
+
return 0;
|
227
|
+
}
|
@@ -0,0 +1,226 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (C) 2013 NEC Corporation
|
3
|
+
*
|
4
|
+
* This program is free software; you can redistribute it and/or modify
|
5
|
+
* it under the terms of the GNU General Public License, version 2, as
|
6
|
+
* published by the Free Software Foundation.
|
7
|
+
*
|
8
|
+
* This program is distributed in the hope that it will be useful,
|
9
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
* GNU General Public License for more details.
|
12
|
+
*
|
13
|
+
* You should have received a copy of the GNU General Public License along
|
14
|
+
* with this program; if not, write to the Free Software Foundation, Inc.,
|
15
|
+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
16
|
+
*/
|
17
|
+
|
18
|
+
|
19
|
+
#include <getopt.h>
|
20
|
+
#include "trema.h"
|
21
|
+
|
22
|
+
|
23
|
+
static bool operate_on_all = true;
|
24
|
+
static bool sw_manager = true;
|
25
|
+
static uint64_t dpid;
|
26
|
+
static enum efi_event_type type;
|
27
|
+
static const char *service_name = NULL;
|
28
|
+
|
29
|
+
static struct option long_options[] = {
|
30
|
+
{ "manager", 0, NULL, 'm' },
|
31
|
+
{ "switch", 1, NULL, 's' },
|
32
|
+
{ "type", 1, NULL, 't' },
|
33
|
+
{ NULL, 0, NULL, 0 },
|
34
|
+
};
|
35
|
+
|
36
|
+
static char short_options[] = "ms:t:";
|
37
|
+
|
38
|
+
|
39
|
+
void
|
40
|
+
usage() {
|
41
|
+
printf(
|
42
|
+
"Delete OpenFlow Switch Manager/Daemon event forward entry.\n"
|
43
|
+
" Both Switch Mgr/Daemon: %s -t EVENT_TYPE service_name\n"
|
44
|
+
" Only Switch Manager : %s -m -t EVENT_TYPE service_name\n"
|
45
|
+
" Only Switch Daemon : %s -s SWITCH_DPID -t EVENT_TYPE service_name\n"
|
46
|
+
"\n"
|
47
|
+
" EVENT_TYPE:\n"
|
48
|
+
" -t, --type={vendor,packet_in,port_status,state_notify} Specify event type.\n"
|
49
|
+
" TREMA COMMON:\n"
|
50
|
+
" -n, --name=SERVICE_NAME service name\n"
|
51
|
+
" -d, --daemonize run in the background\n"
|
52
|
+
" -l, --logging_level=LEVEL set logging level\n"
|
53
|
+
" -g, --syslog output log messages to syslog\n"
|
54
|
+
" -f, --logging_facility=FACILITY set syslog facility\n"
|
55
|
+
" -h, --help display this help and exit\n"
|
56
|
+
, get_executable_name()
|
57
|
+
, get_executable_name()
|
58
|
+
, get_executable_name()
|
59
|
+
);
|
60
|
+
}
|
61
|
+
|
62
|
+
|
63
|
+
static bool
|
64
|
+
parse_argument( int argc, char *argv[] ) {
|
65
|
+
|
66
|
+
bool type_specified = false;
|
67
|
+
|
68
|
+
int c;
|
69
|
+
while ( ( c = getopt_long( argc, argv, short_options, long_options, NULL ) ) != -1 ) {
|
70
|
+
switch ( c ) {
|
71
|
+
case 'm':
|
72
|
+
sw_manager = true;
|
73
|
+
operate_on_all = false;
|
74
|
+
break;
|
75
|
+
|
76
|
+
case 's':
|
77
|
+
sw_manager = false;
|
78
|
+
operate_on_all = false;
|
79
|
+
if ( !string_to_datapath_id( optarg, &dpid ) ) {
|
80
|
+
error( "Invalid dpid '%s' specified. ", optarg );
|
81
|
+
usage();
|
82
|
+
exit( EXIT_SUCCESS );
|
83
|
+
return false;
|
84
|
+
}
|
85
|
+
break;
|
86
|
+
|
87
|
+
case 't': // add
|
88
|
+
type_specified = true;
|
89
|
+
if ( false ) {
|
90
|
+
}
|
91
|
+
else if ( strcasecmp( "vendor", optarg ) == 0 ) {
|
92
|
+
type = EVENT_FORWARD_TYPE_VENDOR;
|
93
|
+
}
|
94
|
+
else if ( strcasecmp( "packet_in", optarg ) == 0 ) {
|
95
|
+
type = EVENT_FORWARD_TYPE_PACKET_IN;
|
96
|
+
}
|
97
|
+
else if ( strcasecmp( "port_status", optarg ) == 0 ) {
|
98
|
+
type = EVENT_FORWARD_TYPE_PORT_STATUS;
|
99
|
+
}
|
100
|
+
else if ( strcasecmp( "state_notify", optarg ) == 0 ) {
|
101
|
+
type = EVENT_FORWARD_TYPE_STATE_NOTIFY;
|
102
|
+
}
|
103
|
+
else {
|
104
|
+
error( "Invalid type '%s' specified. Must e one of vendor, packet_in, port_status, or state_notify\n", optarg );
|
105
|
+
usage();
|
106
|
+
exit( EXIT_SUCCESS );
|
107
|
+
return false;
|
108
|
+
}
|
109
|
+
break;
|
110
|
+
|
111
|
+
|
112
|
+
default:
|
113
|
+
error( "Encountered unknown option." );
|
114
|
+
usage();
|
115
|
+
exit( EXIT_SUCCESS );
|
116
|
+
return false;
|
117
|
+
break;
|
118
|
+
}
|
119
|
+
}
|
120
|
+
|
121
|
+
if ( !type_specified ) {
|
122
|
+
error( "Event Type was not specified with -t option.\n" );
|
123
|
+
usage();
|
124
|
+
exit( EXIT_SUCCESS );
|
125
|
+
return false;
|
126
|
+
}
|
127
|
+
|
128
|
+
if ( optind >= argc ) {
|
129
|
+
error( "Service name was not specified.\n" );
|
130
|
+
usage();
|
131
|
+
exit( EXIT_FAILURE );
|
132
|
+
return false;
|
133
|
+
}
|
134
|
+
|
135
|
+
service_name = argv[ optind ];
|
136
|
+
|
137
|
+
return true;
|
138
|
+
}
|
139
|
+
|
140
|
+
|
141
|
+
static void
|
142
|
+
timeout( void *user_data ) {
|
143
|
+
UNUSED( user_data );
|
144
|
+
|
145
|
+
error( "Request timed out." );
|
146
|
+
stop_trema();
|
147
|
+
exit( EXIT_FAILURE );
|
148
|
+
}
|
149
|
+
|
150
|
+
|
151
|
+
static void
|
152
|
+
update_result_all_callback( enum efi_result result, void *user_data ) {
|
153
|
+
UNUSED( user_data );
|
154
|
+
if ( result == EFI_OPERATION_SUCCEEDED ) {
|
155
|
+
info( "Operation Succeeded." );
|
156
|
+
stop_trema();
|
157
|
+
}
|
158
|
+
else {
|
159
|
+
error( "Operation Failed." );
|
160
|
+
stop_trema();
|
161
|
+
exit( EXIT_FAILURE );
|
162
|
+
}
|
163
|
+
}
|
164
|
+
|
165
|
+
|
166
|
+
static void
|
167
|
+
update_result_callback( event_forward_operation_result result, void *user_data) {
|
168
|
+
UNUSED( user_data );
|
169
|
+
|
170
|
+
if ( result.result != EFI_OPERATION_SUCCEEDED ) {
|
171
|
+
error( "Operation Failed." );
|
172
|
+
stop_trema();
|
173
|
+
exit( EXIT_FAILURE );
|
174
|
+
}
|
175
|
+
else {
|
176
|
+
if ( result.n_services == 0 ) {
|
177
|
+
info( "Updated service name list is empty.");
|
178
|
+
}
|
179
|
+
else {
|
180
|
+
info( "Updated service name list:" );
|
181
|
+
unsigned i;
|
182
|
+
for ( i = 0; i < result.n_services; ++i ) {
|
183
|
+
info( " %s", result.services[ i ] );
|
184
|
+
}
|
185
|
+
}
|
186
|
+
stop_trema();
|
187
|
+
}
|
188
|
+
}
|
189
|
+
|
190
|
+
|
191
|
+
static void
|
192
|
+
send_efi_request( void ) {
|
193
|
+
info( "Deleting '%s'... ", service_name );
|
194
|
+
if ( operate_on_all ) {
|
195
|
+
delete_event_forward_entry_to_all_switches( type, service_name,
|
196
|
+
update_result_all_callback, NULL );
|
197
|
+
}
|
198
|
+
else {
|
199
|
+
if ( sw_manager ) {
|
200
|
+
delete_switch_manager_event_forward_entry( type, service_name,
|
201
|
+
update_result_callback, NULL );
|
202
|
+
} else {
|
203
|
+
delete_switch_event_forward_entry( dpid, type, service_name,
|
204
|
+
update_result_callback, NULL );
|
205
|
+
}
|
206
|
+
}
|
207
|
+
}
|
208
|
+
|
209
|
+
|
210
|
+
int
|
211
|
+
main( int argc, char *argv[] ) {
|
212
|
+
init_trema( &argc, &argv );
|
213
|
+
parse_argument( argc, argv );
|
214
|
+
|
215
|
+
init_event_forward_interface();
|
216
|
+
|
217
|
+
send_efi_request();
|
218
|
+
|
219
|
+
add_periodic_event_callback( 30, timeout, NULL );
|
220
|
+
|
221
|
+
start_trema();
|
222
|
+
|
223
|
+
finalize_event_forward_interface();
|
224
|
+
|
225
|
+
return 0;
|
226
|
+
}
|