summaryrefslogtreecommitdiff
path: root/lib/smux.h
diff options
context:
space:
mode:
authorVincent Bernat <bernat@luffy.cx>2012-05-23 00:52:46 +0200
committerVincent Bernat <bernat@luffy.cx>2012-06-25 19:03:23 +0200
commit3a4c96885ec878ae4631b0fb7bb7839578725976 (patch)
tree0b0334f9b6b7fce2bc2ebe2fac0c51350c1838de /lib/smux.h
parent08d7f6533ecc0f935a76918c462982004534864d (diff)
smux: isolate SMUX implementation from SNMP implementation
lib/snmp.c gets OID related helper functions that can be used with another SNMP interface. smux.h is cleaned of SMUX specific bits to only expose functions that may be used by an alternative implementation. We also do not redefine functions already present in NetSNMP. Just use the appropriate headers.
Diffstat (limited to 'lib/smux.h')
-rw-r--r--lib/smux.h81
1 files changed, 4 insertions, 77 deletions
diff --git a/lib/smux.h b/lib/smux.h
index f5754ed9..83ae56ce 100644
--- a/lib/smux.h
+++ b/lib/smux.h
@@ -22,24 +22,8 @@
#ifndef _ZEBRA_SNMP_H
#define _ZEBRA_SNMP_H
-#define SMUX_PORT_DEFAULT 199
-
-#define SMUXMAXPKTSIZE 1500
-#define SMUXMAXSTRLEN 256
-
-#define SMUX_OPEN (ASN_APPLICATION | ASN_CONSTRUCTOR | 0)
-#define SMUX_CLOSE (ASN_APPLICATION | ASN_PRIMITIVE | 1)
-#define SMUX_RREQ (ASN_APPLICATION | ASN_CONSTRUCTOR | 2)
-#define SMUX_RRSP (ASN_APPLICATION | ASN_PRIMITIVE | 3)
-#define SMUX_SOUT (ASN_APPLICATION | ASN_PRIMITIVE | 4)
-
-#define SMUX_GET (ASN_CONTEXT | ASN_CONSTRUCTOR | 0)
-#define SMUX_GETNEXT (ASN_CONTEXT | ASN_CONSTRUCTOR | 1)
-#define SMUX_GETRSP (ASN_CONTEXT | ASN_CONSTRUCTOR | 2)
-#define SMUX_SET (ASN_CONTEXT | ASN_CONSTRUCTOR | 3)
-#define SMUX_TRAP (ASN_CONTEXT | ASN_CONSTRUCTOR | 4)
-
-#define SMUX_MAX_FAILURE 3
+#include <net-snmp/agent/net-snmp-agent-includes.h>
+#include <net-snmp/agent/snmp_vars.h>
/* Structures here are mostly compatible with UCD SNMP 4.1.1 */
#define MATCH_FAILED (-1)
@@ -55,69 +39,12 @@
#define IN_ADDR_SIZE sizeof(struct in_addr)
-struct variable;
-
+#undef REGISTER_MIB
#define REGISTER_MIB(descr, var, vartype, theoid) \
smux_register_mib(descr, (struct variable *)var, sizeof(struct vartype), \
sizeof(var)/sizeof(struct vartype), \
theoid, sizeof(theoid)/sizeof(oid))
-typedef int (WriteMethod)(int action,
- u_char *var_val,
- u_char var_val_type,
- size_t var_val_len,
- u_char *statP,
- oid *name,
- size_t length,
- struct variable *v);
-
-typedef u_char *(FindVarMethod)(struct variable *v,
- oid *name,
- size_t *length,
- int exact,
- size_t *var_len,
- WriteMethod **write_method);
-
-/* SNMP variable */
-struct variable
-{
- /* Index of the MIB.*/
- u_char magic;
-
- /* Type of variable. */
- char type;
-
- /* Access control list. */
- u_short acl;
-
- /* Callback function. */
- FindVarMethod *findVar;
-
- /* Suffix of the MIB. */
- int namelen;
- oid name[MAX_OID_LEN];
-};
-
-/* SNMP tree. */
-struct subtree
-{
- /* Tree's oid. */
- oid name[MAX_OID_LEN];
- u_char name_len;
-
- /* List of the variables. */
- struct variable *variables;
-
- /* Length of the variables list. */
- int variables_num;
-
- /* Width of the variables list. */
- int variables_width;
-
- /* Registered flag. */
- int registered;
-};
-
struct trap_object
{
FindVarMethod *findVar;
@@ -145,7 +72,6 @@ struct trap_object
)
extern void smux_init (struct thread_master *tm);
-extern void smux_start (void);
extern void smux_register_mib(const char *, struct variable *,
size_t, int, oid [], size_t);
extern int smux_header_generic (struct variable *, oid [], size_t *,
@@ -153,6 +79,7 @@ extern int smux_header_generic (struct variable *, oid [], size_t *,
extern int smux_trap (const oid *, size_t, const oid *, size_t,
const struct trap_object *,
size_t, unsigned int, u_char);
+
extern int oid_compare (oid *, int, oid *, int);
extern void oid2in_addr (oid [], int, struct in_addr *);
extern void *oid_copy (void *, const void *, size_t);