Permalink
Browse files

fixed hsrp parse args call

  • Loading branch information...
1 parent 4eff2b6 commit 5d29b8ce3d634d8fbd06ab117633bb63c2aaf5a1 @allfro committed Jul 27, 2011
Showing with 25 additions and 4 deletions.
  1. +4 −2 src/builders.c
  2. +13 −1 src/constants.h
  3. +4 −1 src/context.c
  4. +4 −0 src/parsers.c
View
@@ -2258,6 +2258,7 @@ context_build_sebek (context *self, PyObject *args, PyObject *kwargs)
}
+#if LIBNET_RELEASE >= 4
static PyObject *
context_build_hsrp (context *self, PyObject *args, PyObject *kwargs)
{
@@ -2280,10 +2281,10 @@ context_build_hsrp (context *self, PyObject *args, PyObject *kwargs)
static char *kwlist[] = {"version", "opcode", "state", "hello_time", "hold_time", "priority", "group", "reserved", "authdata", "virtual_ip", "payload", "ptag", NULL};
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|BBBBBBBBt#t#z#i", kwlist, &opcode, &state, &hello_time, &hold_time, &priority, &group, &reserved, &authdata, &authdata_len, &virtual_ip, &virtual_ip_len, &ptag))
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|BBBBBBBBz#t#z#i", kwlist, &version, &opcode, &state, &hello_time, &hold_time, &priority, &group, &reserved, &authdata, &authdata_len, &virtual_ip, &virtual_ip_len, &ptag))
return NULL;
- PYLIBNET_ERRTYPE(authdata, HSRP_AUTHDATA_LENGTH, "HSRP auth data");
+ PYLIBNET_ERRTYPE(authdata, HSRP_AUTHDATA_LENGTH, "string (8 bytes)");
PYLIBNET_ERRIP4(virtual_ip);
ptag = libnet_build_hsrp (version, opcode, state, hello_time, hold_time, priority, group, reserved, authdata, U_INT32_TP(virtual_ip), payload, payload_s, self->l, ptag);
@@ -2293,6 +2294,7 @@ context_build_hsrp (context *self, PyObject *args, PyObject *kwargs)
return Py_BuildValue("i", ptag);
}
+#endif
/*
static PyObject *
View
@@ -356,6 +356,9 @@
#define VRRP_AUTH_NONE LIBNET_VRRP_AUTH_NONE
#define VRRP_AUTH_PASSWD LIBNET_VRRP_AUTH_PASSWD
#define VRRP_AUTH_IPAH LIBNET_VRRP_AUTH_IPAH
+
+#if LIBNET_RELEASE >= 4
+
#define HSRP_H LIBNET_HSRP_H
#define HSRP_VERSION LIBNET_HSRP_VERSION
#define HSRP_TYPE_HELLO LIBNET_HSRP_TYPE_HELLO
@@ -368,6 +371,7 @@
#define HSRP_STATE_STANDBY LIBNET_HSRP_STATE_STANDBY
#define HSRP_STATE_ACTIVE LIBNET_HSRP_STATE_ACTIVE
+#endif
/* Pblock headers */
@@ -434,7 +438,11 @@
#define PBLOCK_IPV6_DESTOPTS_H LIBNET_PBLOCK_IPV6_DESTOPTS_H
#define PBLOCK_IPV6_HBHOPTS_H LIBNET_PBLOCK_IPV6_HBHOPTS_H
#define PBLOCK_SEBEK_H LIBNET_PBLOCK_SEBEK_H
+
+#if LIBNET_RELEASE >= 4
#define PBLOCK_HSRP_H LIBNET_PBLOCK_HSRP_H
+#endif
+
#define PBLOCK_DO_CHECKSUM LIBNET_PBLOCK_DO_CHECKSUM
#ifndef IPPROTO_IP
@@ -864,7 +872,6 @@ static struct {
{"RPC_CALL_H", LIBNET_RPC_CALL_H},
{"RPC_CALL_TCP_H", LIBNET_RPC_CALL_TCP_H},
{"SEBEK_H", LIBNET_SEBEK_H},
- {"HSRP_H", LIBNET_HSRP_H},
{"STP_CONF_H", LIBNET_STP_CONF_H},
{"STP_TCN_H", LIBNET_STP_TCN_H},
{"TOKEN_RING_H", LIBNET_TOKEN_RING_H},
@@ -1276,6 +1283,9 @@ static struct {
{"VRRP_AUTH_NONE", LIBNET_VRRP_AUTH_NONE},
{"VRRP_AUTH_PASSWD", LIBNET_VRRP_AUTH_PASSWD},
{"VRRP_AUTH_IPAH", LIBNET_VRRP_AUTH_IPAH},
+
+#if LIBNET_RELEASE >= 4
+ {"HSRP_H", LIBNET_HSRP_H},
{"HSRP_VERSION", LIBNET_HSRP_VERSION},
{"HSRP_TYPE_HELLO", LIBNET_HSRP_TYPE_HELLO},
{"HSRP_TYPE_COUP", LIBNET_HSRP_TYPE_COUP},
@@ -1286,6 +1296,8 @@ static struct {
{"HSRP_STATE_SPEAK", LIBNET_HSRP_STATE_SPEAK},
{"HSRP_STATE_STANDBY", LIBNET_HSRP_STATE_STANDBY},
{"HSRP_STATE_ACTIVE", LIBNET_HSRP_STATE_ACTIVE},
+#endif
+
{"IPPROTO_IP", IPPROTO_IP},
{"IPPROTO_HOPOPTS", IPPROTO_HOPOPTS},
{"IPPROTO_ICMP", IPPROTO_ICMP},
View
@@ -1289,6 +1289,7 @@ static PyMethodDef context_methods[] = {
"ptag - protocol tag to modify an existing header, 0 to build a new one\n"
"\nReturns: protocol tag value on success, -1 on error"
},
+#if LIBNET_RELEASE >= 4
{
"build_hsrp", (PyCFunction)context_build_hsrp, METH_VARARGS | METH_KEYWORDS,
"Builds a HSRP header. HSRP is a Cisco propietary protocol defined in RFC 2281.\n"
@@ -1306,7 +1307,9 @@ static PyMethodDef context_methods[] = {
"payload - optional payload or None\n"
"ptag - protocol tag to modify an existing header, 0 to build a new one\n"
"Returns: protocol tag value on success, -1 on error\n"
- },/*
+ },
+#endif
+ /*
{
"build_link", (PyCFunction)context_build_link, METH_VARARGS | METH_KEYWORDS,
"Builds a link layer header for an initialized l. The function\n"
View
@@ -939,6 +939,7 @@ pylibnet_parse_sebek_h(u_int8_t *buf, u_int32_t h_len, u_int32_t b_len)
PYLIBNET_KEYPAIR_HL(length));
}
+#if LIBNET_RELEASE >= 4
static PyObject *
pylibnet_parse_hsrp_h(u_int8_t *buf, u_int32_t h_len, u_int32_t b_len)
{
@@ -955,6 +956,7 @@ pylibnet_parse_hsrp_h(u_int8_t *buf, u_int32_t h_len, u_int32_t b_len)
PYLIBNET_KEYPAIR(authdata), HSRP_AUTHDATA_LENGTH,
PYLIBNET_KEYPAIR_INADDR4(virtual_ip));
}
+#endif
typedef PyObject *(*PyLibnetParseFunction)(u_int8_t *, u_int32_t, u_int32_t);
@@ -1026,7 +1028,9 @@ static struct {
{LIBNET_PBLOCK_IPV6_DESTOPTS_H, (PyLibnetParseFunction)pylibnet_parse_ipv6_destopts_h},
{LIBNET_PBLOCK_IPV6_HBHOPTS_H, (PyLibnetParseFunction)pylibnet_parse_ipv6_hbhopts_h},
{LIBNET_PBLOCK_SEBEK_H, (PyLibnetParseFunction)pylibnet_parse_sebek_h},
+#if LIBNET_RELEASE >= 4
{LIBNET_PBLOCK_HSRP_H, (PyLibnetParseFunction)pylibnet_parse_hsrp_h},
+#endif
{0, NULL}
};

0 comments on commit 5d29b8c

Please sign in to comment.