]>
Commit | Line | Data |
---|---|---|
ad02a0eb SH |
1 | /***************************************************************************** |
2 | Copyright (c) 2006 EMC Corporation. | |
3 | ||
4 | This program is free software; you can redistribute it and/or modify it | |
5 | under the terms of the GNU General Public License as published by the Free | |
6 | Software Foundation; either version 2 of the License, or (at your option) | |
7 | any later version. | |
8 | ||
9 | This program is distributed in the hope that it will be useful, but WITHOUT | |
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
12 | more details. | |
13 | ||
14 | You should have received a copy of the GNU General Public License along with | |
15 | this program; if not, write to the Free Software Foundation, Inc., 59 | |
16 | Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
17 | ||
18 | The full GNU General Public License is included in this distribution in the | |
19 | file called LICENSE. | |
20 | ||
21 | Authors: Srinivas Aji <Aji_Srinivas@emc.com> | |
22 | ||
23 | ******************************************************************************/ | |
24 | ||
25 | #include "ctl_functions.h" | |
26 | #include "ctl_socket.h" | |
27 | #include "ctl_socket_client.h" | |
28 | #include "log.h" | |
29 | ||
30 | CLIENT_SIDE_FUNCTION(enable_bridge_rstp) | |
11904a35 SH |
31 | CLIENT_SIDE_FUNCTION(get_bridge_state) |
32 | CLIENT_SIDE_FUNCTION(set_bridge_config) | |
33 | CLIENT_SIDE_FUNCTION(get_port_state) | |
34 | CLIENT_SIDE_FUNCTION(set_port_config) | |
35 | CLIENT_SIDE_FUNCTION(set_debug_level) | |
ad02a0eb | 36 | #include <base.h> |
11904a35 | 37 | const char *CTL_error_explanation(int err_no) |
ad02a0eb SH |
38 | { |
39 | #define CHOOSE(a) #a | |
11904a35 SH |
40 | static const char *rstp_error_names[] = RSTP_ERRORS; |
41 | static const char *ctl_error_names[] = { CTL_ERRORS }; | |
42 | ||
ad02a0eb | 43 | #undef CHOOSE |
11904a35 SH |
44 | if (err_no < 0) |
45 | return "Error doing ctl command"; | |
46 | else if (err_no >= STP_OK && err_no < STP_LAST_DUMMY) | |
47 | return rstp_error_names[err_no]; | |
48 | else if (err_no > Err_Dummy_Start && err_no < Err_Dummy_End) | |
49 | return ctl_error_names[err_no - Err_Dummy_Start - 1]; | |
ad02a0eb | 50 | |
11904a35 SH |
51 | static char buf[32]; |
52 | sprintf(buf, "Unknown error code %d", err_no); | |
53 | return buf; | |
ad02a0eb SH |
54 | } |
55 | ||
11904a35 | 56 | void Dprintf(int level, const char *fmt, ...) |
ad02a0eb | 57 | { |
11904a35 SH |
58 | char logbuf[256]; |
59 | logbuf[sizeof(logbuf) - 1] = 0; | |
60 | va_list ap; | |
61 | va_start(ap, fmt); | |
62 | vsnprintf(logbuf, sizeof(logbuf) - 1, fmt, ap); | |
63 | va_end(ap); | |
64 | printf("%s\n", logbuf); | |
ad02a0eb | 65 | } |