summaryrefslogtreecommitdiffstats
path: root/lib/smux.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/smux.c')
-rw-r--r--lib/smux.c53
1 files changed, 30 insertions, 23 deletions
diff --git a/lib/smux.c b/lib/smux.c
index fd0c89c2..9f3c3922 100644
--- a/lib/smux.c
+++ b/lib/smux.c
@@ -73,7 +73,7 @@ int debug_smux = 0;
int fail = 0;
/* SMUX node. */
-struct cmd_node smux_node =
+static struct cmd_node smux_node =
{
SMUX_NODE,
"" /* SMUX has no interface. */
@@ -83,7 +83,7 @@ struct cmd_node smux_node =
static struct thread_master *master;
void *
-oid_copy (void *dest, void *src, size_t size)
+oid_copy (void *dest, const void *src, size_t size)
{
return memcpy (dest, src, size * sizeof (oid));
}
@@ -157,7 +157,7 @@ oid_compare_part (oid *o1, int o1_len, oid *o2, int o2_len)
}
static void
-smux_oid_dump (const char *prefix, oid *oid, size_t oid_len)
+smux_oid_dump (const char *prefix, const oid *oid, size_t oid_len)
{
unsigned int i;
int first = 1;
@@ -174,7 +174,7 @@ smux_oid_dump (const char *prefix, oid *oid, size_t oid_len)
}
static int
-smux_socket ()
+smux_socket (void)
{
int ret;
#ifdef HAVE_IPV6
@@ -228,7 +228,8 @@ smux_socket ()
}
freeaddrinfo(res0);
if (sock < 0)
- zlog_warn ("Can't connect to SNMP agent with SMUX");
+ if (debug_smux)
+ zlog_debug ("Can't connect to SNMP agent with SMUX");
#else
sock = socket (AF_INET, SOCK_STREAM, 0);
if (sock < 0)
@@ -259,7 +260,8 @@ smux_socket ()
{
close (sock);
smux_sock = -1;
- zlog_warn ("Can't connect to SNMP agent with SMUX");
+ if (debug_smux)
+ zlog_debug ("Can't connect to SNMP agent with SMUX");
return -1;
}
#endif
@@ -348,7 +350,7 @@ smux_var (u_char *ptr, size_t len, oid objid[], size_t *objid_len,
if (debug_smux)
{
- zlog_debug ("SMUX var parse: type %d len %zd", type, len);
+ zlog_debug ("SMUX var parse: type %u len %zd", type, len);
zlog_debug ("SMUX var parse: type must be %d",
(ASN_SEQUENCE | ASN_CONSTRUCTOR));
}
@@ -945,8 +947,8 @@ smux_open (int sock)
u_char buf[BUFSIZ];
u_char *ptr;
size_t len;
- long version;
- u_char progname[] = QUAGGA_PROGNAME "-" QUAGGA_VERSION;
+ u_long version;
+ char progname[] = QUAGGA_PROGNAME "-" QUAGGA_VERSION;
if (debug_smux)
{
@@ -965,7 +967,7 @@ smux_open (int sock)
version = 0;
ptr = asn_build_int (ptr, &len,
(u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),
- &version, sizeof (version));
+ (long *)&version, sizeof (version));
/* SMUX connection oid. */
ptr = asn_build_objid (ptr, &len,
@@ -977,7 +979,7 @@ smux_open (int sock)
ptr = asn_build_string (ptr, &len,
(u_char)
(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR),
- progname, strlen (progname));
+ (u_char *) progname, strlen (progname));
/* SMUX connection password. */
ptr = asn_build_string (ptr, &len,
@@ -993,9 +995,9 @@ smux_open (int sock)
}
int
-smux_trap (oid *name, size_t namelen,
- oid *iname, size_t inamelen,
- struct trap_object *trapobj, size_t trapobjlen,
+smux_trap (const oid *name, size_t namelen,
+ const oid *iname, size_t inamelen,
+ const struct trap_object *trapobj, size_t trapobjlen,
unsigned int tick, u_char sptrap)
{
unsigned int i;
@@ -1181,7 +1183,10 @@ smux_connect (struct thread *t)
int ret;
if (debug_smux)
- zlog_debug ("SMUX connect try %d", fail + 1);
+ {
+ fail = fail + 1;
+ zlog_debug ("SMUX connect try %d", fail);
+ }
/* Clear thread poner of myself. */
smux_connect_thread = NULL;
@@ -1190,8 +1195,10 @@ smux_connect (struct thread *t)
smux_sock = smux_socket ();
if (smux_sock < 0)
{
- if (++fail < SMUX_MAX_FAILURE)
- smux_event (SMUX_CONNECT, 0);
+ if (debug_smux)
+ zlog_debug ("SMUX socket/connection creation error");
+ // if (++fail < SMUX_MAX_FAILURE)
+ smux_event (SMUX_CONNECT, 0);
return 0;
}
@@ -1202,8 +1209,8 @@ smux_connect (struct thread *t)
zlog_warn ("SMUX open message send failed: %s", safe_strerror (errno));
close (smux_sock);
smux_sock = -1;
- if (++fail < SMUX_MAX_FAILURE)
- smux_event (SMUX_CONNECT, 0);
+ // if (++fail < SMUX_MAX_FAILURE)
+ smux_event (SMUX_CONNECT, 0);
return -1;
}
@@ -1214,8 +1221,8 @@ smux_connect (struct thread *t)
zlog_warn ("SMUX register message send failed: %s", safe_strerror (errno));
close (smux_sock);
smux_sock = -1;
- if (++fail < SMUX_MAX_FAILURE)
- smux_event (SMUX_CONNECT, 0);
+ // if (++fail < SMUX_MAX_FAILURE)
+ smux_event (SMUX_CONNECT, 0);
return -1;
}
@@ -1227,7 +1234,7 @@ smux_connect (struct thread *t)
/* Clear all SMUX related resources. */
static void
-smux_stop ()
+smux_stop (void)
{
if (smux_read_thread)
{
@@ -1388,7 +1395,7 @@ smux_header_generic (struct variable *v, oid *name, size_t *length, int exact,
}
static int
-smux_peer_default ()
+smux_peer_default (void)
{
if (smux_oid)
{