|
Hi all I 'm going to make agentx with my source file but problem occured
1. agentx.c
=====================================================================================
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include <signal.h>
#include "snmp_agent.h"
#include "snmp_interface.h"
static int keep_running;
RETSIGTYPE
stop_server(int a) {
keep_running = 0;
}
int main (int argc, char **argv) {
int agentx_subagent=1; /* change this if you want to be a SNMP master agent */
int background = "" /* change this if you want to run in the background */
int syslog = 0; /* change this if you want to use syslog */
/* print log errors to syslog or stderr */
if (syslog)
snmp_enable_calllog();
else
snmp_enable_stderrlog();
/* we're an agentx subagent? */
if (agentx_subagent) {
/* make us a agentx client. */
netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_ROLE, 1);
}
/* run in background, if requested */
if (background && netsnmp_daemonize(1, !syslog))
exit(1);
/* initialize tcpip, if necessary */
SOCK_STARTUP;
/* initialize the agent library */
init_agent("agentx");
/* initialize mib code here */
/* mib code: init_nstAgentSubagentObject from nstAgentSubagentObject.C */
init_interface();
/* initialize vacm/usm access control */
if (!agentx_subagent) {
init_vacm_vars();
init_usmUser();
}
/* example-demon will be used to read example-demon.conf files. */
init_snmp("agentx");
/* If we're going to be a snmp master agent, initial the ports */
if (!agentx_subagent)
init_master_agent(); /* open the port to listen on (defaults to udp:161) */
/* In case we recevie a request to stop (kill -TERM or kill -INT) */
keep_running = 1;
signal(SIGTERM, stop_server);
signal(SIGINT, stop_server);
snmp_log(LOG_INFO,"agentx is up and running.\n");
/* your main loop here... */
while(keep_running) {
/* if you use select(), see snmp_select_info() in snmp_api(3) */
/* --- OR --- */
agent_check_and_process(1); /* 0 == don't block */
}
/* at shutdown time */
snmp_shutdown("agentx");
SOCK_CLEANUP;
return 0;
}
=================================================================================================
2. Makefile
=================================================================================================
PROJDIR = /home/psyche/sychoi
INSTDIR = $(PROJDIR)/rootfs/usr/sbin
SNMPINC = /home/psyche/sychoi/install/usr
CC=ppc_82xx-gcc
STRIP=ppc_82xx-strip
OBJS += agentx.o
OBJS += snmp_interface
TARGETS = agentx
LIBS=$(PROJDIR)/lib/libnexcmd/libnexcmd.a -lpthread
CFLAGS = -I. -I$(PROJDIR)/include/libnexcmd -I$(PROJDIR)/include
CFLAGS+= -O2 -Dlinux -I. -I$(SNMPINC)/include
BUILDLIBS = -L$(SNMPINC)/lib -lnetsnmp -lcrypto -lm
BUILDAGENTLIBS = -L$(SNMPINC)/lib -lnetsnmpmibs -lnetsnmpagent -lnetsnmphelpers -lnetsnmp -ldl -lcrypto -lm
# shared library flags (assumes gcc)
DLFLAGS=-fPIC -shared -lpthread
all: $(TARGETS)
agentx: $(OBJS)
$(CC) -o agentx $(OBJS) $(LIBS) $(BUILDLIBS) $(BUILDAGENTLIBS)
$(STRIP) agentx
install:
cp -a agentx $(INSTDIR)
clean:
rm -f $(OBJS) $(TARGETS)
===============================================================================================
3. snmp_interface.c
================================================================================================
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include <semaphore.h>
#include "common.h"
#include "nex_common.h"
#include "snmp_interface.h"
#include "nex_interface.h"
#include "nex_interface.c"
static sem_t if_sem;
/*
* Typical data structure for a row entry
*/
struct interfaceTable_entry {
/*
* Index values
*/
long index;
/*
* Column values
*/
u_long ip;
u_long netmask;
u_long gateway;
/*
* Illustrate using a simple linked list
*/
int valid;
struct interfaceTable_entry *next;
};
struct interfaceTable_entry *interfaceTable_head;
.......................................................
================================================================================================
I run "make agentx", but so many error occur
=================================================================================
[r...@localhost nexlib]# make agentx
ppc_82xx-gcc -I. -I/home/psyche/sychoi/include/libnexcmd -I/home/psyche/sychoi/include -O2 -Dlinux -I. -I/home/psyche/sychoi/install/usr/include -c -o agentx.o agentx.c
ppc_82xx-gcc -I. -I/home/psyche/sychoi/include/libnexcmd -I/home/psyche/sychoi/include -O2 -Dlinux -I. -I/home/psyche/sychoi/install/usr/include snmp_interface.c -o snmp_interface
/opt/eldk-4.0/usr/../ppc_82xx/lib/crt1.o:(.rodata+0x4): undefined reference to `main'
/tmp/ccEpJZwq.o: In function `nexSetInterfaceIp':
snmp_interface.c:(.text+0xbc): undefined reference to `nexGetSystemInfo'
snmp_interface.c:(.text+0xd4): undefined reference to `nexSetSystemInfo'
/tmp/ccEpJZwq.o: In function `nexGetInterfaceIp':
snmp_interface.c:(.text+0x130): undefined reference to `nexGetSystemInfo'
/tmp/ccEpJZwq.o: In function `nexSetInterfaceGw':
snmp_interface.c:(.text+0x1a8): undefined reference to `nexGetSystemInfo'
snmp_interface.c:(.text+0x214): undefined reference to `nexSetSystemInfo'
/tmp/ccEpJZwq.o: In function `nexGetInterfaceGw':
snmp_interface.c:(.text+0x254): undefined reference to `nexGetSystemInfo'
/tmp/ccEpJZwq.o: In function `nexSetInterfaceVid':
snmp_interface.c:(.text+0x294): undefined reference to `nexGetSystemInfo'
snmp_interface.c:(.text+0x2a4): undefined reference to `nexSetSystemInfo'
snmp_interface.c:(.text+0x2b8): undefined reference to `nexSetPortPvid'
/tmp/ccEpJZwq.o: In function `nexGetInterfaceVid':
snmp_interface.c:(.text+0x2f0): undefined reference to `nexGetSystemInfo'
/tmp/ccEpJZwq.o: In function `nexClearInterfaceGw':
snmp_interface.c:(.text+0x4d4): undefined reference to `nexGetFromFile'
snmp_interface.c:(.text+0x514): undefined reference to `nexSetToFile'
/tmp/ccEpJZwq.o: In function `nexMakeConfigInterface':
snmp_interface.c:(.text+0x630): undefined reference to `nexGetFromFile'
snmp_interface.c:(.text+0x670): undefined reference to `nexGetFromFile'
snmp_interface.c:(.text+0x6b4): undefined reference to `nexGetFromFile'
snmp_interface.c:(.text+0x72c): undefined reference to `nexGetFromFile'
/tmp/ccEpJZwq.o: In function `interfaceTable_createEntry':
snmp_interface.c:(.text+0x8c4): undefined reference to `sem_wait'
snmp_interface.c:(.text+0x8dc): undefined reference to `sem_post'
/tmp/ccEpJZwq.o: In function `initialize_table_interfaceTable':
snmp_interface.c:(.text+0x938): undefined reference to `netsnmp_create_handler_registration'
snmp_interface.c:(.text+0x95c): undefined reference to `netsnmp_table_helper_add_indexes'
snmp_interface.c:(.text+0x9a4): undefined reference to `netsnmp_register_table_iterator'
/tmp/ccEpJZwq.o: In function `init_interface':
snmp_interface.c:(.text+0x9f0): undefined reference to `sem_init'
/tmp/ccEpJZwq.o: In function `interfaceTable_removeEntry':
snmp_interface.c:(.text+0xa2c): undefined reference to `sem_wait'
snmp_interface.c:(.text+0xa74): undefined reference to `sem_post'
snmp_interface.c:(.text+0xab0): undefined reference to `sem_post'
/tmp/ccEpJZwq.o: In function `interfaceTable_get_next_data_point':
snmp_interface.c:(.text+0xb18): undefined reference to `sem_wait'
snmp_interface.c:(.text+0xb6c): undefined reference to `sem_post'
snmp_interface.c:(.text+0xba8): undefined reference to `snmp_set_var_value'
snmp_interface.c:(.text+0xbbc): undefined reference to `sem_post'
/tmp/ccEpJZwq.o: In function `interfaceTable_handler':
snmp_interface.c:(.text+0xcb4): undefined reference to `netsnmp_extract_iterator_context'
snmp_interface.c:(.text+0xccc): undefined reference to `netsnmp_set_request_error'
snmp_interface.c:(.text+0xce8): undefined reference to `netsnmp_set_request_error'
snmp_interface.c:(.text+0xcfc): undefined reference to `netsnmp_extract_iterator_context'
snmp_interface.c:(.text+0xd0c): undefined reference to `netsnmp_extract_table_info'
snmp_interface.c:(.text+0xd44): undefined reference to `snmp_set_var_typed_value'
snmp_interface.c:(.text+0xd5c): undefined reference to `snmp_set_var_typed_value'
snmp_interface.c:(.text+0xd74): undefined reference to `snmp_set_var_typed_value'
snmp_interface.c:(.text+0xd8c): undefined reference to `snmp_set_var_typed_value'
collect2: ld returned 1 exit status
make: *** [snmp_interface] ���� 1
================================================================================================
Why does so many error occur about snmp library?
I don't find the reason and answer
The only thing i can do is just add below files,
===============================================================================
#include <net-snmp/agent/table_iterator.h>
#include "/home/psyche/sychoi/net-snmp-5.3.2/agent/helpers/table_iterator.c"
#include <net-snmp/library/snmp_client.h>
#include "/home/psyche/sychoi/net-snmp-5.3.2/snmplib/snmp_client.c"
#include <net-snmp/agent/snmp_agent.h>
#include "/home/psyche/sychoi/net-snmp-5.3.2/agent/snmp_agent.c"
=================================================================================
Then I make agentx again... the result is below
Still error remain...
=========================================================================================== [r...@localhost nexlib]# make agentx ppc_82xx-gcc -I. -I/home/psyche/sychoi/include/libnexcmd -I/home/psyche/sychoi/include -O2 -Dlinux -I. -I/home/psyche/sychoi/install/usr/include -c -o agentx.o agentx.c ppc_82xx-gcc -I. -I/home/psyche/sychoi/include/libnexcmd -I/home/psyche/sychoi/include -O2 -Dlinux -I. -I/home/psyche/sychoi/install/usr/include snmp_interface.c -o snmp_interface In file included from snmp_interface.c:17: /home/psyche/sychoi/net-snmp-5.3.2/agent/snmp_agent.c:1725: error: parse error before '*' token make: *** [snmp_interface] ���� 1 ============================================================================================
This is snmp_agent.c : 1725
===========================================================================================
void netsnmp_free_agent_snmp_session_by_session(netsnmp_session *sess, void (*free_request)(netsnmp_request_list *))
=============================================================================================
I don't know what is the problem..
I find about "netsnmp_free_agent_snmp_session_by_session" in menual, but i don't find the problem about that
What shall i do?!
I think that this is net-snmp problem.. Isn't it?
If there is anyone know about it, please give me some comment..
Thank you..
|
|
|
|
------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev
_______________________________________________ Net-snmp-coders mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
