Last active
October 29, 2015 22:06
-
-
Save garthk/a00adef7cd73fabe9a8f to your computer and use it in GitHub Desktop.
Rockspec for luasnmp 1.0.6-2 and Lua 5.1; works with LuaJIT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package = "luasnmp" | |
version = "1.0.6-2" | |
source = { | |
url = "https://github.com/hleuwer/luasnmp/archive/1.0.6-2.zip", | |
dir = "luasnmp-1.0.6-2" | |
} | |
description = { | |
summary = "LuaSNMP is a binding to the netsnmp library.", | |
detailed = [[ | |
Herbert Leuwer's 2006/2009 netsnmp bindings, patched for NetSNMP-5.4 | |
but not for Lua 5.2. Perfect for LuaJIT. | |
]], | |
homepage = "http://...", -- We don't have one yet | |
license = "CLOSED" -- or whatever you like | |
} | |
external_dependencies = { | |
NETSNMP = { | |
library = 'netsnmp' | |
}, | |
CRYPTO = { | |
library = 'crypto' | |
} | |
} | |
build = { | |
type = 'builtin', | |
modules = { | |
snmp = 'snmp.lua', | |
['snmp.core'] = { | |
defines = { | |
'LUA_COMPAT_ALL', | |
'SYSTEM=UNKNOWN', | |
'USE_SNMPTRAPD=0', | |
'VERSION=1.0-7', | |
}, | |
libraries = { | |
'crypto', | |
'netsnmp', | |
}, | |
sources = { | |
'src/except.c', | |
'src/nm_c64.c', | |
'src/nm_mib.c', | |
'src/nm_snmp.c', | |
'src/nm_trap.c', | |
'src/nm_util.c', | |
'src/compat-5.1r5/compat-5.1.c', | |
}, | |
incdirs = { | |
'src/compat-5.1r5/', | |
} | |
} | |
}, | |
patches = { | |
-- please excuse the limited context; -U3 broke the luarocks patch.lua | |
['MSG-not-PDU.diff'] = [[ | |
--- a/src/nm_snmp.c | |
+++ b/src/nm_snmp.c | |
@@ -1351,5 +1351,5 @@ | |
if (nm_session->cmu_session->version == SNMP_VERSION_1) | |
- pdu = snmp_pdu_create(SNMP_PDU_GETNEXT); | |
+ pdu = snmp_pdu_create(SNMP_MSG_GETNEXT); | |
else { | |
- pdu = snmp_pdu_create(SNMP_PDU_GETBULK); | |
+ pdu = snmp_pdu_create(SNMP_MSG_GETBULK); | |
pdu->non_repeaters = (int) lua_tonumber(L, lnr); | |
@@ -1360,5 +1360,5 @@ | |
if (req_type == NM_SNMP_GET_REQ) | |
- pdu = snmp_pdu_create(SNMP_PDU_GET) ; | |
+ pdu = snmp_pdu_create(SNMP_MSG_GET) ; | |
else | |
- pdu = snmp_pdu_create(SNMP_PDU_GETNEXT) ; | |
+ pdu = snmp_pdu_create(SNMP_MSG_GETNEXT) ; | |
} | |
@@ -1556,3 +1556,3 @@ | |
- pdu = snmp_pdu_create(SNMP_PDU_INFORM); | |
+ pdu = snmp_pdu_create(SNMP_MSG_INFORM); | |
if ((varlist = f_create_infovl((char *)lua_tostring(L, trapOID))) == NULL) { | |
@@ -1566,3 +1566,3 @@ | |
} else { | |
- pdu = snmp_pdu_create(SNMP_PDU_SET); | |
+ pdu = snmp_pdu_create(SNMP_MSG_SET); | |
} | |
@@ -1917,3 +1917,3 @@ | |
#if 0 | |
- if (pdu->command == SNMP_PDU_INFORM) | |
+ if (pdu->command == SNMP_MSG_INFORM) | |
netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DEFAULT_PORT, | |
@@ -2056,3 +2056,3 @@ | |
if ((op == RECEIVED_MESSAGE) && (pdu != NULL) && | |
- (pdu->command == SNMP_PDU_RESPONSE || pdu->command == SNMP_PDU_REPORT)) | |
+ (pdu->command == SNMP_MSG_RESPONSE || pdu->command == SNMP_MSG_REPORT)) | |
op_status = STAT_SUCCESS; | |
@@ -2226,4 +2226,4 @@ | |
if ((retval = snmp_parse(NULL, nm_session->cmu_session, pdu, packet, pktLen)) || | |
- ((pdu->command != TRP_REQ_MSG) &&(pdu->command != SNMP_PDU_V2TRAP) | |
- && (pdu->command != SNMP_PDU_INFORM))) { | |
+ ((pdu->command != TRP_REQ_MSG) &&(pdu->command != SNMP_MSG_V2TRAP) | |
+ && (pdu->command != SNMP_MSG_INFORM))) { | |
fprintf(stderr,"luasnmp: invalid trap packet %d %d\n", retval, pdu->command); | |
@@ -2250,3 +2250,3 @@ | |
- if (pdu->command == SNMP_PDU_INFORM) { | |
+ if (pdu->command == SNMP_MSG_INFORM) { | |
if (nm_session->infocb == -1) | |
@@ -2286,3 +2286,3 @@ | |
if (info_session != NULL) { | |
- pdu->command = SNMP_PDU_RESPONSE; | |
+ pdu->command = SNMP_MSG_RESPONSE; | |
pdu->errstat = 0; | |
]], | |
['fix-mib-init.diff'] = [[ | |
--- a/src/nm_mib.c | |
+++ b/src/nm_mib.c | |
@@ -712,5 +712,5 @@ | |
static int nm_mib_init(lua_State *L) { | |
- init_mib(); | |
+ netsnmp_init_mib(); | |
return 0; | |
} | |
]], | |
['netsnmp-headers.diff'] = [[ | |
--- a/src/nm_c64.h | |
+++ b/src/nm_c64.h | |
@@ -4,6 +4,7 @@ | |
#ifndef WIN32 | |
#include <sys/types.h> | |
#endif | |
+#include <net-snmp/net-snmp-config.h> | |
#include <net-snmp/library/asn1.h> | |
#include "lua.h" | |
#include "lauxlib.h" | |
--- a/src/nm_util.c | |
+++ b/src/nm_util.c | |
@@ -7,9 +7,22 @@ | |
#include <net-snmp/net-snmp-config.h> | |
#include <net-snmp/mib_api.h> | |
-#include <net-snmp/library/cmu_compat.h> | |
#include <net-snmp/library/asn1.h> | |
+#include <net-snmp/definitions.h> | |
+#define OBJID ASN_OBJECT_ID | |
+#define SMI_INTEGER ASN_INTEGER | |
+#define SMI_STRING ASN_OCTET_STR | |
+#define SMI_OBJID ASN_OBJECT_ID | |
+#define SMI_NULLOBJ ASN_NULL | |
+#define SMI_IPADDRESS ASN_IPADDRESS | |
+#define SMI_COUNTER32 ASN_COUNTER | |
+#define SMI_GAUGE32 ASN_GAUGE | |
+#define SMI_UNSIGNED32 SMI_GAUGE32 | |
+#define SMI_TIMETICKS ASN_TIMETICKS | |
+#define SMI_OPAQUE ASN_OPAQUE | |
+#define SMI_COUNTER64 ASN_COUNTER64 | |
+ | |
#ifndef WIN32 | |
#include <sys/param.h> | |
#endif | |
]], | |
['stdlib-not-malloc.diff'] = [[ | |
--- a/src/nm_snmp.c | |
+++ b/src/nm_snmp.c | |
@@ -16,7 +16,7 @@ | |
#include <string.h> | |
#include <stdio.h> | |
-#include <malloc.h> | |
+#include <stdlib.h> | |
#include <errno.h> | |
#include "lua.h" | |
]], | |
['stringify-defines.diff'] = [[ | |
--- a/src/nm_snmp.c | |
+++ b/src/nm_snmp.c | |
@@ -28,9 +28,12 @@ | |
#include "except.h" | |
#include "nm_c64.h" | |
+#define STR_EXPAND(tok) #tok | |
+#define STR(tok) STR_EXPAND(tok) | |
+ | |
#define MYNAME "snmp" | |
-#define MYVERSION VERSION | |
-#define MYSYSTEM SYSTEM | |
+#define MYVERSION STR(VERSION) | |
+#define MYSYSTEM STR(SYSTEM) | |
#define USM_OID_LEN 12 | |
#define DH_USM_OID_LEN 11 | |
]], | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment