-
Notifications
You must be signed in to change notification settings - Fork 26
/
ctl_cli_wrap.c
65 lines (54 loc) · 2.15 KB
/
ctl_cli_wrap.c
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
/*****************************************************************************
Copyright (c) 2006 EMC Corporation.
This program 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 2 of the License, or (at your option)
any later version.
This program 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
this program; if not, write to the Free Software Foundation, Inc., 59
Temple Place - Suite 330, Boston, MA 02111-1307, USA.
The full GNU General Public License is included in this distribution in the
file called LICENSE.
Authors: Srinivas Aji <[email protected]>
******************************************************************************/
#include "ctl_functions.h"
#include "ctl_socket.h"
#include "ctl_socket_client.h"
#include "log.h"
CLIENT_SIDE_FUNCTION(enable_bridge_rstp)
CLIENT_SIDE_FUNCTION(get_bridge_state)
CLIENT_SIDE_FUNCTION(set_bridge_config)
CLIENT_SIDE_FUNCTION(get_port_state)
CLIENT_SIDE_FUNCTION(set_port_config)
CLIENT_SIDE_FUNCTION(set_debug_level)
#include <base.h>
const char *CTL_error_explanation(int err_no)
{
#define CHOOSE(a) #a
static const char *rstp_error_names[] = RSTP_ERRORS;
static const char *ctl_error_names[] = { CTL_ERRORS };
#undef CHOOSE
if (err_no < 0)
return "Error doing ctl command";
else if (err_no >= STP_OK && err_no < STP_LAST_DUMMY)
return rstp_error_names[err_no];
else if (err_no > Err_Dummy_Start && err_no < Err_Dummy_End)
return ctl_error_names[err_no - Err_Dummy_Start - 1];
static char buf[32];
sprintf(buf, "Unknown error code %d", err_no);
return buf;
}
void Dprintf(int level, const char *fmt, ...)
{
char logbuf[256];
logbuf[sizeof(logbuf) - 1] = 0;
va_list ap;
va_start(ap, fmt);
vsnprintf(logbuf, sizeof(logbuf) - 1, fmt, ap);
va_end(ap);
printf("%s\n", logbuf);
}