trema 0.2.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitmodules +3 -0
- data/.travis.yml +13 -0
- data/.yardopts +4 -0
- data/Gemfile +2 -3
- data/README.md +43 -97
- data/Rakefile +60 -4
- data/Rantfile +11 -10
- data/cruise.rb +4 -6
- data/features/example.packetin_filter_config.feature +10 -10
- data/features/example.switch_monitor.feature +14 -2
- data/features/step_definitions/kill_steps.rb +2 -2
- data/features/step_definitions/{off_steps.rb → killall_steps.rb} +2 -2
- data/features/step_definitions/misc_steps.rb +1 -1
- data/features/step_definitions/up_steps.rb +30 -0
- data/features/trema.feature +1 -0
- data/features/trema.run.feature +1 -0
- data/locale/README.ja.md +19 -0
- data/locale/ja/yard.po +3762 -0
- data/locale/yard.pot +3740 -0
- data/ruby/extconf.rb +4 -1
- data/ruby/trema/action-common.c +3 -17
- data/ruby/trema/action-common.h +3 -7
- data/ruby/trema/action.rb +33 -0
- data/ruby/trema/app.rb +1 -1
- data/ruby/trema/barrier-request.c +1 -0
- data/ruby/trema/command/run.rb +13 -9
- data/ruby/trema/command/usage.rb +1 -0
- data/ruby/trema/command/version.rb +1 -1
- data/ruby/trema/controller.c +133 -50
- data/ruby/trema/controller.rb +2 -2
- data/ruby/trema/desc-stats-reply.rb +77 -0
- data/ruby/trema/dsl/configuration.rb +3 -14
- data/ruby/trema/dsl/rswitch.rb +47 -0
- data/ruby/trema/dsl/runner.rb +4 -1
- data/ruby/trema/dsl/syntax.rb +11 -8
- data/ruby/trema/echo-reply.c +59 -45
- data/ruby/trema/echo-reply.h +1 -3
- data/ruby/trema/echo-request.c +49 -71
- data/ruby/trema/echo-request.h +0 -2
- data/ruby/trema/echo.c +99 -0
- data/ruby/trema/{action-enqueue.h → echo.h} +6 -7
- data/ruby/trema/enqueue.rb +87 -0
- data/ruby/trema/error.c +109 -104
- data/ruby/trema/error.h +0 -2
- data/ruby/trema/features-reply.c +89 -35
- data/ruby/trema/features-reply.h +0 -6
- data/ruby/trema/features-request.c +63 -37
- data/ruby/trema/features-request.h +0 -2
- data/ruby/trema/flow-mod.c +149 -0
- data/ruby/trema/{action-output.h → flow-mod.h} +6 -6
- data/ruby/trema/get-config-request.c +1 -0
- data/ruby/trema/hardware-switch.rb +88 -0
- data/ruby/trema/hello.c +55 -31
- data/ruby/trema/hello.h +0 -2
- data/ruby/trema/ip.rb +12 -2
- data/ruby/trema/logger.rb +29 -0
- data/ruby/trema/mac.rb +57 -36
- data/ruby/trema/match.c +7 -9
- data/ruby/trema/monkey-patch/integer/ranges.rb +0 -2
- data/ruby/trema/network-component.rb +1 -1
- data/ruby/trema/open-vswitch.rb +2 -2
- data/ruby/trema/openflow-switch.rb +3 -54
- data/ruby/trema/{packet_in.c → packet-in.c} +262 -175
- data/ruby/trema/{packet_in.h → packet-in.h} +0 -2
- data/ruby/trema/packet-queue.rb +4 -3
- data/ruby/trema/port-mod.c +8 -9
- data/ruby/trema/port-status-add.rb +60 -0
- data/ruby/trema/port-status-delete.rb +60 -0
- data/ruby/trema/port-status-modify.rb +60 -0
- data/ruby/trema/port-status.c +48 -15
- data/ruby/trema/port-status.h +6 -8
- data/ruby/trema/port.c +63 -8
- data/ruby/trema/queue-get-config-request.c +1 -0
- data/ruby/trema/ruby-switch.rb +62 -0
- data/ruby/trema/send-out-port.rb +97 -0
- data/ruby/trema/set-config.c +1 -0
- data/ruby/trema/set-eth-addr.rb +45 -0
- data/ruby/trema/set-eth-dst-addr.rb +54 -0
- data/ruby/trema/set-eth-src-addr.rb +54 -0
- data/ruby/trema/set-ip-addr.rb +47 -0
- data/ruby/trema/set-ip-dst-addr.rb +53 -0
- data/ruby/trema/set-ip-src-addr.rb +52 -0
- data/ruby/trema/set-ip-tos.rb +63 -0
- data/ruby/trema/set-transport-dst-port.rb +53 -0
- data/ruby/trema/set-transport-port.rb +52 -0
- data/ruby/trema/set-transport-src-port.rb +54 -0
- data/ruby/trema/set-vlan-priority.rb +65 -0
- data/ruby/trema/set-vlan-vid.rb +64 -0
- data/ruby/trema/shell/down.rb +1 -1
- data/ruby/trema/shell/link.rb +4 -4
- data/ruby/trema/shell/run.rb +8 -6
- data/ruby/trema/shell/up.rb +3 -3
- data/ruby/trema/stats-reply.c +27 -2
- data/ruby/trema/stats-request.c +64 -23
- data/ruby/trema/strip-vlan-header.rb +41 -0
- data/ruby/trema/switch.c +196 -0
- data/ruby/trema/{action-vendor.h → switch.h} +5 -7
- data/ruby/trema/switch.rb +28 -9
- data/ruby/trema/trema-ruby-utils.c +66 -0
- data/ruby/trema/{action-set-dl-src.h → trema-ruby-utils.h} +9 -11
- data/ruby/trema/trema.c +61 -61
- data/ruby/trema/vendor-action.rb +73 -0
- data/ruby/trema/vendor.c +121 -52
- data/ruby/trema/vendor.h +6 -10
- data/ruby/trema/version.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/support/action.rb +52 -0
- data/spec/support/mandatory-option.rb +56 -0
- data/spec/support/openflow-message.rb +91 -7
- data/spec/support/port-status.rb +38 -0
- data/spec/trema/controller_spec.rb +0 -26
- data/spec/trema/dsl/configuration_spec.rb +3 -3
- data/spec/trema/dsl/runner_spec.rb +12 -32
- data/spec/trema/dsl/syntax_spec.rb +2 -11
- data/spec/trema/echo-reply_spec.rb +49 -14
- data/spec/trema/echo-request_spec.rb +86 -34
- data/spec/trema/enqueue_spec.rb +76 -0
- data/spec/trema/error_spec.rb +43 -58
- data/spec/trema/features-reply_spec.rb +58 -24
- data/spec/trema/features-request_spec.rb +54 -28
- data/spec/trema/flow-mod_spec.rb +99 -0
- data/spec/trema/{openflow-switch_spec.rb → hardware-switch_spec.rb} +3 -3
- data/spec/trema/hello_spec.rb +28 -14
- data/spec/trema/ip_spec.rb +54 -0
- data/spec/trema/mac_spec.rb +49 -64
- data/spec/trema/match_spec.rb +1 -1
- data/spec/trema/open-vswitch_spec.rb +7 -7
- data/spec/trema/packet-in_spec.rb +73 -16
- data/spec/trema/port-status-add_spec.rb +32 -0
- data/spec/trema/port-status-delete_spec.rb +32 -0
- data/spec/trema/port-status-modify_spec.rb +71 -0
- data/spec/trema/port-status_spec.rb +5 -76
- data/spec/trema/{action-output_spec.rb → send-out-port_spec.rb} +20 -47
- data/spec/trema/set-eth-dst-addr_spec.rb +75 -0
- data/spec/trema/set-eth-src-addr_spec.rb +72 -0
- data/spec/trema/set-ip-dst-addr_spec.rb +58 -0
- data/spec/trema/set-ip-src-addr_spec.rb +58 -0
- data/spec/trema/set-ip-tos_spec.rb +65 -0
- data/spec/trema/set-transport-dst-port_spec.rb +65 -0
- data/spec/trema/set-transport-src-port_spec.rb +65 -0
- data/spec/trema/set-vlan-priority_spec.rb +65 -0
- data/spec/trema/set-vlan-vid_spec.rb +65 -0
- data/spec/trema/shell/vhost_spec.rb +4 -1
- data/spec/trema/shell/vswitch_spec.rb +11 -11
- data/spec/trema/stats-reply_spec.rb +59 -13
- data/spec/trema/stats-request_spec.rb +6 -0
- data/spec/trema/{action-strip-vlan_spec.rb → strip-vlan-header_spec.rb} +3 -17
- data/spec/trema/switch-daemon_spec.rb +39 -0
- data/spec/trema/vendor-action_spec.rb +81 -0
- data/spec/trema/vendor_spec.rb +76 -0
- data/spec/trema_spec.rb +56 -0
- data/src/examples/dumper/dumper.c +0 -8
- data/src/examples/dumper/dumper.rb +52 -52
- data/src/examples/hello_trema/hello_trema.c +0 -2
- data/src/examples/learning_switch/learning-switch.rb +3 -3
- data/src/examples/multi_learning_switch/multi-learning-switch.rb +3 -3
- data/src/examples/openflow_message/features-request.rb +3 -3
- data/src/examples/packetin_filter_config/utils.c +4 -4
- data/src/examples/repeater_hub/repeater-hub.rb +3 -3
- data/src/examples/switch_info/switch_info.rb +2 -2
- data/src/examples/switch_monitor/switch_monitor.c +1 -1
- data/src/examples/traffic_monitor/traffic-monitor.rb +3 -3
- data/src/lib/arp.h +4 -1
- data/src/lib/chibach.c +391 -0
- data/src/lib/chibach.h +71 -0
- data/src/lib/chibach_private.c +170 -0
- data/src/lib/chibach_private.h +52 -0
- data/src/lib/ether.c +2 -1
- data/src/lib/ether.h +0 -1
- data/src/lib/ipv4.h +13 -14
- data/{ruby/trema/action-set-nw-src.h → src/lib/ipv6.h} +13 -9
- data/src/lib/log.c +161 -58
- data/src/lib/log.h +11 -16
- data/src/lib/messenger.c +36 -1
- data/src/lib/messenger.h +1 -0
- data/src/lib/openflow_application_interface.c +128 -28
- data/src/lib/openflow_application_interface.h +31 -6
- data/src/lib/openflow_message.c +2 -1
- data/src/lib/openflow_service_interface.h +1 -0
- data/src/lib/openflow_switch_interface.c +1380 -0
- data/src/lib/openflow_switch_interface.h +264 -0
- data/src/lib/packet_info.c +94 -11
- data/src/lib/packet_info.h +22 -3
- data/src/lib/packet_parser.c +38 -2
- data/src/lib/secure_channel.c +498 -0
- data/{ruby/trema/vendor-request.h → src/lib/secure_channel.h} +11 -10
- data/src/lib/tcp.h +0 -3
- data/src/lib/trema.c +38 -5
- data/{ruby/trema/action-set-nw-dst.h → src/lib/trema.hpp} +17 -8
- data/src/lib/trema_wrapper.c +5 -0
- data/src/lib/trema_wrapper.h +4 -0
- data/src/lib/utility.c +93 -4
- data/src/lib/utility.h +1 -0
- data/src/lib/wrapper.c +30 -7
- data/src/lib/wrapper.h +2 -0
- data/src/switch_manager/ofpmsg_recv.c +44 -30
- data/src/switch_manager/ofpmsg_send.c +40 -1
- data/src/switch_manager/ofpmsg_send.h +2 -0
- data/src/switch_manager/switch.c +153 -8
- data/src/switch_manager/switch.h +1 -0
- data/src/switch_manager/switchinfo.h +5 -0
- data/src/tremashark/README +2 -2
- data/src/tremashark/plugin/packet-trema/packet-trema.c +1 -0
- data/trema +1 -1
- data/unittests/lib/log_test.c +158 -34
- data/unittests/lib/openflow_application_interface_test.c +252 -69
- data/unittests/lib/openflow_message_test.c +3 -1
- data/unittests/lib/packet_parser_test.c +60 -15
- data/unittests/lib/test_packets/icmp6_echo_rep.cap +0 -0
- data/unittests/lib/test_packets/icmp6_echo_req.cap +0 -0
- data/unittests/lib/trema_test.c +2 -0
- data/unittests/lib/utility_test.c +65 -2
- data/unittests/lib/wrapper_test.c +29 -0
- data/vendor/{README → README.md} +2 -12
- data/vendor/packet-openflow.diff +13 -0
- metadata +86 -53
- data/GPL2 +0 -339
- data/ruby/trema/action-enqueue.c +0 -161
- data/ruby/trema/action-output.c +0 -169
- data/ruby/trema/action-set-dl-dst.c +0 -131
- data/ruby/trema/action-set-dl-dst.h +0 -44
- data/ruby/trema/action-set-dl-src.c +0 -131
- data/ruby/trema/action-set-nw-dst.c +0 -135
- data/ruby/trema/action-set-nw-src.c +0 -140
- data/ruby/trema/action-set-nw-tos.c +0 -124
- data/ruby/trema/action-set-nw-tos.h +0 -42
- data/ruby/trema/action-set-tp-dst.c +0 -122
- data/ruby/trema/action-set-tp-dst.h +0 -42
- data/ruby/trema/action-set-tp-src.c +0 -124
- data/ruby/trema/action-set-tp-src.h +0 -42
- data/ruby/trema/action-set-vlan-pcp.c +0 -128
- data/ruby/trema/action-set-vlan-pcp.h +0 -42
- data/ruby/trema/action-set-vlan-vid.c +0 -125
- data/ruby/trema/action-set-vlan-vid.h +0 -42
- data/ruby/trema/action-strip-vlan.c +0 -81
- data/ruby/trema/action-strip-vlan.h +0 -42
- data/ruby/trema/action-vendor.c +0 -121
- data/ruby/trema/vendor-request.c +0 -193
- data/spec/trema/action-enqueue_spec.rb +0 -100
- data/spec/trema/action-set-dl-dst_spec.rb +0 -95
- data/spec/trema/action-set-dl-src_spec.rb +0 -92
- data/spec/trema/action-set-nw-dst_spec.rb +0 -96
- data/spec/trema/action-set-nw-src_spec.rb +0 -97
- data/spec/trema/action-set-nw-tos_spec.rb +0 -88
- data/spec/trema/action-set-tp-dst_spec.rb +0 -88
- data/spec/trema/action-set-tp-src_spec.rb +0 -88
- data/spec/trema/action-set-vlan-pcp_spec.rb +0 -91
- data/spec/trema/action-set-vlan-vid_spec.rb +0 -91
- data/spec/trema/action-vendor_spec.rb +0 -90
- data/spec/trema/vendor-request_spec.rb +0 -79
data/src/lib/chibach.h
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Chibach common functions.
|
|
3
|
+
*
|
|
4
|
+
* Author: Yasuhito Takamiya <yasuhito@gmail.com>, Yasunobu Chiba
|
|
5
|
+
*
|
|
6
|
+
* Copyright (C) 2008-2012 NEC Corporation
|
|
7
|
+
*
|
|
8
|
+
* This program is free software; you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU General Public License, version 2, as
|
|
10
|
+
* published by the Free Software Foundation.
|
|
11
|
+
*
|
|
12
|
+
* This program is distributed in the hope that it will be useful,
|
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
* GNU General Public License for more details.
|
|
16
|
+
*
|
|
17
|
+
* You should have received a copy of the GNU General Public License along
|
|
18
|
+
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
19
|
+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
#ifndef CHIBACH_H
|
|
24
|
+
#define CHIBACH_H
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
#include "bool.h"
|
|
28
|
+
#include "buffer.h"
|
|
29
|
+
#include "byteorder.h"
|
|
30
|
+
#include "checks.h"
|
|
31
|
+
#include "doubly_linked_list.h"
|
|
32
|
+
#include "ether.h"
|
|
33
|
+
#include "event_handler.h"
|
|
34
|
+
#include "hash_table.h"
|
|
35
|
+
#include "linked_list.h"
|
|
36
|
+
#include "log.h"
|
|
37
|
+
#include "match.h"
|
|
38
|
+
#include "match_table.h"
|
|
39
|
+
#include "message_queue.h"
|
|
40
|
+
#include "messenger.h"
|
|
41
|
+
#include "openflow_service_interface.h"
|
|
42
|
+
#include "openflow_switch_interface.h"
|
|
43
|
+
#include "openflow_message.h"
|
|
44
|
+
#include "packet_info.h"
|
|
45
|
+
#include "stat.h"
|
|
46
|
+
#include "timer.h"
|
|
47
|
+
#include "utility.h"
|
|
48
|
+
#include "wrapper.h"
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
void init_chibach( int *argc, char ***argv );
|
|
52
|
+
void start_chibach( void );
|
|
53
|
+
void stop_chibach( void );
|
|
54
|
+
void flush( void );
|
|
55
|
+
const char *get_chibach_home( void );
|
|
56
|
+
const char *get_chibach_tmp( void );
|
|
57
|
+
const char *get_chibach_name( void );
|
|
58
|
+
void set_chibach_name( const char *name );
|
|
59
|
+
__attribute__( ( weak ) ) void usage( void );
|
|
60
|
+
uint64_t get_datapath_id( void );
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
#endif // CHIBACH_H
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
/*
|
|
67
|
+
* Local variables:
|
|
68
|
+
* c-basic-offset: 2
|
|
69
|
+
* indent-tabs-mode: nil
|
|
70
|
+
* End:
|
|
71
|
+
*/
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Author: Yasuhito Takamiya <yasuhito@gmail.com>, Yasunobu Chiba
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2008-2012 NEC Corporation
|
|
5
|
+
*
|
|
6
|
+
* This program is free software; you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU General Public License, version 2, as
|
|
8
|
+
* published by the Free Software Foundation.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU General Public License along
|
|
16
|
+
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
17
|
+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
#include <assert.h>
|
|
22
|
+
#include <errno.h>
|
|
23
|
+
#include <limits.h>
|
|
24
|
+
#include <stdint.h>
|
|
25
|
+
#include <stdio.h>
|
|
26
|
+
#include <stdlib.h>
|
|
27
|
+
#include <string.h>
|
|
28
|
+
#include "bool.h"
|
|
29
|
+
#include "chibach_private.h"
|
|
30
|
+
#include "log.h"
|
|
31
|
+
#include "trema_wrapper.h"
|
|
32
|
+
#include "wrapper.h"
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
static const char CHIBACH_HOME[] = "CHIBACH_HOME";
|
|
36
|
+
static const char CHIBACH_TMP[] = "CHIBACH_TMP";
|
|
37
|
+
static char *chibach_home = NULL;
|
|
38
|
+
static char *chibach_tmp = NULL;
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
static bool
|
|
42
|
+
expand( const char *path, char *absolute_path ) {
|
|
43
|
+
assert( path != NULL );
|
|
44
|
+
assert( absolute_path != NULL );
|
|
45
|
+
|
|
46
|
+
char buf[ 256 ];
|
|
47
|
+
char *result = realpath( path, absolute_path );
|
|
48
|
+
if ( result == NULL ) {
|
|
49
|
+
trema_fprintf( stderr, "Could not get the absolute path of %s: %s.\n", path, strerror_r( errno, buf, sizeof( buf ) ) );
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Sets chibach home directory for your chibach session.
|
|
59
|
+
*/
|
|
60
|
+
void
|
|
61
|
+
set_chibach_home( void ) {
|
|
62
|
+
if ( getenv( CHIBACH_HOME ) == NULL ) {
|
|
63
|
+
setenv( CHIBACH_HOME, "/", 1 );
|
|
64
|
+
chibach_home = xstrdup( "/" );
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
char absolute_path[ PATH_MAX ];
|
|
68
|
+
if ( !expand( getenv( CHIBACH_HOME ), absolute_path ) ) {
|
|
69
|
+
trema_fprintf( stderr, "Falling back CHIBACH_HOME to \"/\".\n" );
|
|
70
|
+
strncpy( absolute_path, "/", 2 );
|
|
71
|
+
}
|
|
72
|
+
setenv( CHIBACH_HOME, absolute_path, 1 );
|
|
73
|
+
chibach_home = xstrdup( absolute_path );
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Returns chibach home directory used in your chibach session.
|
|
80
|
+
*/
|
|
81
|
+
const char *
|
|
82
|
+
get_chibach_home( void ) {
|
|
83
|
+
if ( chibach_home == NULL ) {
|
|
84
|
+
set_chibach_home();
|
|
85
|
+
}
|
|
86
|
+
return chibach_home;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Unsets chibach home directory used in your chibach session.
|
|
92
|
+
*/
|
|
93
|
+
void unset_chibach_home( void ) {
|
|
94
|
+
if ( chibach_home != NULL ) {
|
|
95
|
+
xfree( chibach_home );
|
|
96
|
+
chibach_home = NULL;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Sets temporary directory for your Chibach session.
|
|
103
|
+
*/
|
|
104
|
+
void
|
|
105
|
+
set_chibach_tmp( void ) {
|
|
106
|
+
char path[ PATH_MAX ];
|
|
107
|
+
|
|
108
|
+
if ( getenv( CHIBACH_TMP ) == NULL ) {
|
|
109
|
+
const char *chibach_home = get_chibach_home();
|
|
110
|
+
if ( chibach_home[ strlen( chibach_home ) - 1 ] == '/' ) {
|
|
111
|
+
snprintf( path, PATH_MAX, "%stmp", chibach_home );
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
snprintf( path, PATH_MAX, "%s/tmp", chibach_home );
|
|
115
|
+
}
|
|
116
|
+
path[ PATH_MAX - 1 ] = '\0';
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
if ( !expand( getenv( CHIBACH_TMP ), path ) ) {
|
|
120
|
+
trema_fprintf( stderr, "Falling back CHIBACH_TMP to \"/tmp\".\n" );
|
|
121
|
+
strncpy( path, "/tmp", 5 );
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
chibach_tmp = xstrdup( path );
|
|
126
|
+
setenv( CHIBACH_TMP, chibach_tmp, 1 );
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Returns temporary directory used in your Chibach session.
|
|
132
|
+
*/
|
|
133
|
+
const char *
|
|
134
|
+
get_chibach_tmp( void ) {
|
|
135
|
+
if ( chibach_tmp == NULL ) {
|
|
136
|
+
set_chibach_tmp();
|
|
137
|
+
}
|
|
138
|
+
return chibach_tmp;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Unsets temporary directory used in your Chibach session.
|
|
144
|
+
*/
|
|
145
|
+
void unset_chibach_tmp( void ) {
|
|
146
|
+
if ( chibach_tmp != NULL ) {
|
|
147
|
+
xfree( chibach_tmp );
|
|
148
|
+
chibach_tmp = NULL;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
const char *
|
|
154
|
+
_get_chibach_home( void ) {
|
|
155
|
+
return chibach_home;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
const char *
|
|
160
|
+
_get_chibach_tmp( void ) {
|
|
161
|
+
return chibach_tmp;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
/*
|
|
166
|
+
* Local variables:
|
|
167
|
+
* c-basic-offset: 2
|
|
168
|
+
* indent-tabs-mode: nil
|
|
169
|
+
* End:
|
|
170
|
+
*/
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Private functions that are only called from [chibach]/src/lib.
|
|
3
|
+
*
|
|
4
|
+
* Author: Yasuhito Takamiya <yasuhito@gmail.com>
|
|
5
|
+
*
|
|
6
|
+
* Copyright (C) 2008-2012 NEC Corporation
|
|
7
|
+
*
|
|
8
|
+
* This program is free software; you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU General Public License, version 2, as
|
|
10
|
+
* published by the Free Software Foundation.
|
|
11
|
+
*
|
|
12
|
+
* This program is distributed in the hope that it will be useful,
|
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
* GNU General Public License for more details.
|
|
16
|
+
*
|
|
17
|
+
* You should have received a copy of the GNU General Public License along
|
|
18
|
+
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
19
|
+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
#ifndef CHIBACH_PRIVATE_H
|
|
24
|
+
#define CHIBACH_PRIVATE_H
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
#include "bool.h"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
void set_chibach_home( void );
|
|
31
|
+
const char *get_chibach_home( void );
|
|
32
|
+
void unset_chibach_home( void );
|
|
33
|
+
|
|
34
|
+
void set_chibach_tmp( void );
|
|
35
|
+
const char *get_chibach_tmp( void );
|
|
36
|
+
void unset_chibach_tmp( void );
|
|
37
|
+
|
|
38
|
+
const char *get_chibach_name( void );
|
|
39
|
+
|
|
40
|
+
const char *_get_chibach_home( void );
|
|
41
|
+
const char *_get_chibach_tmp( void );
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
#endif // CHIBACH_PRIVATE_H
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
/*
|
|
48
|
+
* Local variables:
|
|
49
|
+
* c-basic-offset: 2
|
|
50
|
+
* indent-tabs-mode: nil
|
|
51
|
+
* End:
|
|
52
|
+
*/
|
data/src/lib/ether.c
CHANGED
|
@@ -34,7 +34,8 @@ fill_ether_padding( buffer *buf ) {
|
|
|
34
34
|
padding_length = ETH_MINIMUM_LENGTH - buf->length - ETH_FCS_LENGTH;
|
|
35
35
|
debug( "Adding %u octets padding ( original frame length = %u ).",
|
|
36
36
|
buf->length, padding_length );
|
|
37
|
-
append_back_buffer( buf, padding_length );
|
|
37
|
+
void *padding = append_back_buffer( buf, padding_length );
|
|
38
|
+
memset( padding, 0, padding_length );
|
|
38
39
|
}
|
|
39
40
|
return ( uint16_t ) padding_length;
|
|
40
41
|
}
|
data/src/lib/ether.h
CHANGED
data/src/lib/ipv4.h
CHANGED
|
@@ -24,27 +24,26 @@
|
|
|
24
24
|
#define IPV4_H
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
#include <netinet/ip.h>
|
|
28
27
|
#include "buffer.h"
|
|
29
28
|
|
|
30
29
|
|
|
31
30
|
typedef struct {
|
|
32
31
|
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
uint8_t ihl:4;
|
|
33
|
+
uint8_t version:4;
|
|
35
34
|
#elif __BYTE_ORDER == __BIG_ENDIAN
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
uint8_t version:4;
|
|
36
|
+
uint8_t ihl:4;
|
|
38
37
|
#endif
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
uint8_t tos;
|
|
39
|
+
uint16_t tot_len;
|
|
40
|
+
uint16_t id;
|
|
41
|
+
uint16_t frag_off;
|
|
42
|
+
uint8_t ttl;
|
|
43
|
+
uint8_t protocol;
|
|
44
|
+
uint16_t csum;
|
|
45
|
+
uint32_t saddr;
|
|
46
|
+
uint32_t daddr;
|
|
48
47
|
} ipv4_header_t;
|
|
49
48
|
|
|
50
49
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
*
|
|
2
|
+
* IPv6 header definitions
|
|
3
3
|
*
|
|
4
4
|
* Copyright (C) 2008-2012 NEC Corporation
|
|
5
5
|
*
|
|
@@ -18,20 +18,24 @@
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
#ifndef
|
|
22
|
-
#define
|
|
21
|
+
#ifndef IPV6_H
|
|
22
|
+
#define IPV6_H
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
#
|
|
25
|
+
#define IPV6_ADDRLEN 16
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
typedef struct {
|
|
29
|
+
uint32_t hdrctl;
|
|
30
|
+
uint16_t plen;
|
|
31
|
+
uint8_t nexthdr;
|
|
32
|
+
uint8_t hoplimit;
|
|
33
|
+
uint8_t saddr[ IPV6_ADDRLEN ];
|
|
34
|
+
uint8_t daddr[ IPV6_ADDRLEN ];
|
|
35
|
+
} ipv6_header_t;
|
|
29
36
|
|
|
30
37
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
#endif // ACTION_SET_NW_SRC_H
|
|
38
|
+
#endif // IPV6_H
|
|
35
39
|
|
|
36
40
|
|
|
37
41
|
/*
|
data/src/lib/log.c
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
#include <stdarg.h>
|
|
26
26
|
#include <stdlib.h>
|
|
27
27
|
#include <string.h>
|
|
28
|
+
#include <syslog.h>
|
|
28
29
|
#include <time.h>
|
|
29
30
|
#include "bool.h"
|
|
30
31
|
#include "log.h"
|
|
@@ -34,32 +35,35 @@
|
|
|
34
35
|
|
|
35
36
|
typedef struct {
|
|
36
37
|
const char *name;
|
|
37
|
-
const
|
|
38
|
+
const int value;
|
|
38
39
|
} priority;
|
|
39
40
|
|
|
40
41
|
|
|
42
|
+
static bool initialized = false;
|
|
41
43
|
static FILE *fd = NULL;
|
|
42
|
-
static
|
|
43
|
-
static
|
|
44
|
+
static int level = -1;
|
|
45
|
+
static char ident_string[ PATH_MAX ];
|
|
46
|
+
static char log_directory[ PATH_MAX ];
|
|
47
|
+
static logging_type output = LOGGING_TYPE_FILE;
|
|
44
48
|
static pthread_mutex_t mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
|
|
45
49
|
|
|
46
50
|
|
|
47
51
|
static priority priorities[][ 3 ] = {
|
|
48
52
|
{
|
|
49
|
-
{ .name = "critical", .value =
|
|
50
|
-
{ .name = "crit", .value =
|
|
53
|
+
{ .name = "critical", .value = LOG_CRIT },
|
|
54
|
+
{ .name = "crit", .value = LOG_CRIT },
|
|
51
55
|
{ .name = NULL },
|
|
52
56
|
},
|
|
53
57
|
|
|
54
58
|
{
|
|
55
|
-
{ .name = "error", .value =
|
|
56
|
-
{ .name = "err", .value =
|
|
59
|
+
{ .name = "error", .value = LOG_ERR },
|
|
60
|
+
{ .name = "err", .value = LOG_ERR },
|
|
57
61
|
{ .name = NULL },
|
|
58
62
|
},
|
|
59
63
|
|
|
60
64
|
{
|
|
61
|
-
{ .name = "warn", .value =
|
|
62
|
-
{ .name = "warning", .value =
|
|
65
|
+
{ .name = "warn", .value = LOG_WARNING },
|
|
66
|
+
{ .name = "warning", .value = LOG_WARNING },
|
|
63
67
|
{ .name = NULL },
|
|
64
68
|
},
|
|
65
69
|
|
|
@@ -83,8 +87,8 @@ static priority priorities[][ 3 ] = {
|
|
|
83
87
|
|
|
84
88
|
|
|
85
89
|
static const char *
|
|
86
|
-
priority_name_from(
|
|
87
|
-
const char *name = priorities[ level ][ 0 ].name;
|
|
90
|
+
priority_name_from( int level ) {
|
|
91
|
+
const char *name = priorities[ level - LOG_CRIT ][ 0 ].name;
|
|
88
92
|
assert( name != NULL );
|
|
89
93
|
return name;
|
|
90
94
|
}
|
|
@@ -93,7 +97,7 @@ priority_name_from( logging_level level ) {
|
|
|
93
97
|
static const size_t max_message_length = 1024;
|
|
94
98
|
|
|
95
99
|
static void
|
|
96
|
-
log_file(
|
|
100
|
+
log_file( int priority, const char *format, va_list ap ) {
|
|
97
101
|
time_t tm = time( NULL );
|
|
98
102
|
char now[ 26 ];
|
|
99
103
|
asctime_r( localtime( &tm ), now );
|
|
@@ -122,13 +126,61 @@ log_stdout( const char *format, va_list ap ) {
|
|
|
122
126
|
}
|
|
123
127
|
|
|
124
128
|
|
|
125
|
-
static
|
|
126
|
-
|
|
129
|
+
static void
|
|
130
|
+
log_syslog( int priority, const char *format, va_list ap ) {
|
|
131
|
+
trema_vsyslog( priority, format, ap );
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
static void
|
|
136
|
+
unset_ident_string() {
|
|
137
|
+
memset( ident_string, '\0', sizeof( ident_string ) );
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
static void
|
|
142
|
+
set_ident_string( const char *ident ) {
|
|
127
143
|
assert( ident != NULL );
|
|
128
|
-
|
|
144
|
+
|
|
145
|
+
unset_ident_string();
|
|
146
|
+
strncpy( ident_string, ident, sizeof( ident_string ) - 1 );
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
static const char *
|
|
151
|
+
get_ident_string() {
|
|
152
|
+
return ident_string;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
static void
|
|
157
|
+
unset_log_directory() {
|
|
158
|
+
memset( log_directory, '\0', sizeof( log_directory ) );
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
static void
|
|
163
|
+
set_log_directory( const char *directory ) {
|
|
164
|
+
assert( directory != NULL );
|
|
165
|
+
|
|
166
|
+
unset_log_directory();
|
|
167
|
+
strncpy( log_directory, directory, sizeof( log_directory ) - 1 );
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
static const char *
|
|
172
|
+
get_log_directory() {
|
|
173
|
+
return log_directory;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
static FILE*
|
|
178
|
+
open_log_file( bool append ) {
|
|
179
|
+
assert( strlen( get_log_directory() ) > 0 );
|
|
180
|
+
assert( strlen( get_ident_string() ) > 0 );
|
|
129
181
|
|
|
130
182
|
char pathname[ PATH_MAX ];
|
|
131
|
-
sprintf( pathname, "%s/%s.log",
|
|
183
|
+
sprintf( pathname, "%s/%s.log", get_log_directory(), get_ident_string() );
|
|
132
184
|
FILE *log = fopen( pathname, append ? "a" : "w" );
|
|
133
185
|
|
|
134
186
|
if ( log == NULL ) {
|
|
@@ -142,27 +194,51 @@ open_log( const char *ident, const char *log_directory, bool append ) {
|
|
|
142
194
|
}
|
|
143
195
|
|
|
144
196
|
|
|
197
|
+
static void
|
|
198
|
+
open_log_syslog() {
|
|
199
|
+
assert( strlen( get_ident_string() ) > 0 );
|
|
200
|
+
|
|
201
|
+
trema_openlog( get_ident_string(), LOG_NDELAY, LOG_USER );
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
|
|
145
205
|
/**
|
|
146
206
|
* Initializes the Logger. This creates a log file to which messages
|
|
147
207
|
* are written.
|
|
148
208
|
*
|
|
149
209
|
* @param ident name of the log file, used as an identifier.
|
|
150
210
|
* @param log_directory the directory in which log file is created.
|
|
151
|
-
* @param
|
|
211
|
+
* @param type log output type.
|
|
152
212
|
* @return true on success; false otherwise.
|
|
153
213
|
*/
|
|
154
214
|
bool
|
|
155
|
-
init_log( const char *ident, const char *
|
|
215
|
+
init_log( const char *ident, const char *directory, logging_type type ) {
|
|
216
|
+
assert( ident != NULL );
|
|
217
|
+
assert( directory != NULL );
|
|
218
|
+
|
|
156
219
|
pthread_mutex_lock( &mutex );
|
|
157
220
|
|
|
158
|
-
|
|
221
|
+
// set_logging_level() may be called before init_log().
|
|
222
|
+
// level = -1 indicates that logging level is not set yet.
|
|
223
|
+
if ( level < 0 || level > LOG_DEBUG ) {
|
|
224
|
+
level = LOG_INFO;
|
|
225
|
+
}
|
|
159
226
|
char *level_string = getenv( "LOGGING_LEVEL" );
|
|
160
227
|
if ( level_string != NULL ) {
|
|
161
228
|
set_logging_level( level_string );
|
|
162
229
|
}
|
|
163
230
|
|
|
164
|
-
|
|
165
|
-
|
|
231
|
+
set_ident_string( ident );
|
|
232
|
+
set_log_directory( directory );
|
|
233
|
+
output = type;
|
|
234
|
+
if ( output & LOGGING_TYPE_FILE ) {
|
|
235
|
+
fd = open_log_file( false );
|
|
236
|
+
}
|
|
237
|
+
if ( output & LOGGING_TYPE_SYSLOG ) {
|
|
238
|
+
open_log_syslog();
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
initialized = true;
|
|
166
242
|
|
|
167
243
|
pthread_mutex_unlock( &mutex );
|
|
168
244
|
|
|
@@ -171,35 +247,51 @@ init_log( const char *ident, const char *log_directory, bool run_as_daemon ) {
|
|
|
171
247
|
|
|
172
248
|
|
|
173
249
|
void
|
|
174
|
-
restart_log( const char *
|
|
250
|
+
restart_log( const char *new_ident ) {
|
|
175
251
|
pthread_mutex_lock( &mutex );
|
|
176
252
|
|
|
177
|
-
if (
|
|
178
|
-
|
|
253
|
+
if ( new_ident != NULL ) {
|
|
254
|
+
set_ident_string( new_ident );
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if ( output & LOGGING_TYPE_FILE ) {
|
|
258
|
+
if ( fd != NULL ) {
|
|
259
|
+
fclose( fd );
|
|
260
|
+
}
|
|
261
|
+
fd = open_log_file( true );
|
|
262
|
+
}
|
|
263
|
+
if ( output & LOGGING_TYPE_SYSLOG ) {
|
|
264
|
+
trema_closelog();
|
|
265
|
+
open_log_syslog();
|
|
179
266
|
}
|
|
180
|
-
fd = open_log( ident, log_directory, true );
|
|
181
267
|
|
|
182
268
|
pthread_mutex_unlock( &mutex );
|
|
183
269
|
}
|
|
184
270
|
|
|
185
271
|
|
|
186
272
|
void
|
|
187
|
-
rename_log( const char *
|
|
188
|
-
assert( directory != NULL );
|
|
189
|
-
assert( old_ident != NULL );
|
|
273
|
+
rename_log( const char *new_ident ) {
|
|
190
274
|
assert( new_ident != NULL );
|
|
191
275
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
276
|
+
if ( output & LOGGING_TYPE_FILE ) {
|
|
277
|
+
char old_path[ PATH_MAX ];
|
|
278
|
+
snprintf( old_path, PATH_MAX, "%s/%s.log", get_log_directory(), get_ident_string() );
|
|
279
|
+
old_path[ PATH_MAX - 1 ] = '\0';
|
|
280
|
+
char new_path[ PATH_MAX ];
|
|
281
|
+
set_ident_string( new_ident );
|
|
282
|
+
snprintf( new_path, PATH_MAX, "%s/%s.log", get_log_directory(), get_ident_string() );
|
|
283
|
+
new_path[ PATH_MAX - 1 ] = '\0';
|
|
284
|
+
|
|
285
|
+
unlink( new_path );
|
|
286
|
+
int ret = rename( old_path, new_path );
|
|
287
|
+
if ( ret < 0 ) {
|
|
288
|
+
die( "Could not rename a log file from %s to %s.", old_path, new_path );
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
if ( output & LOGGING_TYPE_SYSLOG ) {
|
|
292
|
+
trema_closelog();
|
|
293
|
+
set_ident_string( new_ident );
|
|
294
|
+
open_log_syslog();
|
|
203
295
|
}
|
|
204
296
|
}
|
|
205
297
|
|
|
@@ -214,11 +306,22 @@ finalize_log() {
|
|
|
214
306
|
pthread_mutex_lock( &mutex );
|
|
215
307
|
|
|
216
308
|
level = -1;
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
fd
|
|
309
|
+
|
|
310
|
+
if ( output & LOGGING_TYPE_FILE ) {
|
|
311
|
+
if ( fd != NULL ) {
|
|
312
|
+
fclose( fd );
|
|
313
|
+
fd = NULL;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
if ( output & LOGGING_TYPE_SYSLOG ) {
|
|
317
|
+
trema_closelog();
|
|
220
318
|
}
|
|
221
319
|
|
|
320
|
+
unset_ident_string();
|
|
321
|
+
unset_log_directory();
|
|
322
|
+
|
|
323
|
+
initialized = false;
|
|
324
|
+
|
|
222
325
|
pthread_mutex_unlock( &mutex );
|
|
223
326
|
|
|
224
327
|
return true;
|
|
@@ -242,7 +345,7 @@ priority_value_from( const char *name ) {
|
|
|
242
345
|
int level_value = -1;
|
|
243
346
|
char *name_lower = lower( name );
|
|
244
347
|
|
|
245
|
-
for ( int i = 0; i <= LOG_DEBUG; i++ ) {
|
|
348
|
+
for ( int i = 0; i <= ( LOG_DEBUG - LOG_CRIT ); i++ ) {
|
|
246
349
|
for ( priority *p = priorities[ i ]; p->name != NULL; p++ ) {
|
|
247
350
|
if ( strncmp( p->name, name_lower, 20 ) == 0 ) {
|
|
248
351
|
level_value = p->value;
|
|
@@ -257,12 +360,7 @@ priority_value_from( const char *name ) {
|
|
|
257
360
|
|
|
258
361
|
static bool
|
|
259
362
|
started() {
|
|
260
|
-
|
|
261
|
-
return false;
|
|
262
|
-
}
|
|
263
|
-
else {
|
|
264
|
-
return true;
|
|
265
|
-
}
|
|
363
|
+
return initialized;
|
|
266
364
|
}
|
|
267
365
|
|
|
268
366
|
|
|
@@ -288,19 +386,24 @@ set_logging_level( const char *name ) {
|
|
|
288
386
|
}
|
|
289
387
|
|
|
290
388
|
|
|
291
|
-
static
|
|
389
|
+
static int
|
|
292
390
|
_get_logging_level() {
|
|
293
391
|
return level;
|
|
294
392
|
}
|
|
295
|
-
|
|
393
|
+
int ( *get_logging_level )( void ) = _get_logging_level;
|
|
296
394
|
|
|
297
395
|
|
|
298
396
|
static void
|
|
299
|
-
do_log(
|
|
397
|
+
do_log( int priority, const char *format, va_list ap ) {
|
|
300
398
|
assert( started() );
|
|
301
399
|
|
|
302
|
-
|
|
303
|
-
|
|
400
|
+
if ( output & LOGGING_TYPE_FILE ) {
|
|
401
|
+
log_file( priority, format, ap );
|
|
402
|
+
}
|
|
403
|
+
if ( output & LOGGING_TYPE_SYSLOG ) {
|
|
404
|
+
log_syslog( priority, format, ap );
|
|
405
|
+
}
|
|
406
|
+
if ( output & LOGGING_TYPE_STDOUT ) {
|
|
304
407
|
log_stdout( format, ap );
|
|
305
408
|
}
|
|
306
409
|
}
|
|
@@ -311,7 +414,7 @@ do_log( logging_level priority, const char *format, va_list ap ) {
|
|
|
311
414
|
if ( _format == NULL ) { \
|
|
312
415
|
trema_abort(); \
|
|
313
416
|
} \
|
|
314
|
-
if (
|
|
417
|
+
if ( get_logging_level() >= _priority ) { \
|
|
315
418
|
pthread_mutex_lock( &mutex ); \
|
|
316
419
|
va_list _args; \
|
|
317
420
|
va_start( _args, _format ); \
|
|
@@ -324,7 +427,7 @@ do_log( logging_level priority, const char *format, va_list ap ) {
|
|
|
324
427
|
|
|
325
428
|
static void
|
|
326
429
|
_critical( const char *format, ... ) {
|
|
327
|
-
DO_LOG(
|
|
430
|
+
DO_LOG( LOG_CRIT, format );
|
|
328
431
|
}
|
|
329
432
|
/**
|
|
330
433
|
* Logs an critical message.
|
|
@@ -336,7 +439,7 @@ void ( *critical )( const char *format, ... ) = _critical;
|
|
|
336
439
|
|
|
337
440
|
static void
|
|
338
441
|
_error( const char *format, ... ) {
|
|
339
|
-
DO_LOG(
|
|
442
|
+
DO_LOG( LOG_ERR, format );
|
|
340
443
|
}
|
|
341
444
|
/**
|
|
342
445
|
* Logs an error message.
|
|
@@ -348,7 +451,7 @@ void ( *error )( const char *format, ... ) = _error;
|
|
|
348
451
|
|
|
349
452
|
static void
|
|
350
453
|
_warn( const char *format, ... ) {
|
|
351
|
-
DO_LOG(
|
|
454
|
+
DO_LOG( LOG_WARNING, format );
|
|
352
455
|
}
|
|
353
456
|
/**
|
|
354
457
|
* Logs a warning message.
|