I am very new to using the Net-SNMP libraries. Further complicating the
problem, I have not used C code for a long while (still coming back up
to speed).

I need to prototype a stand-alone C application that uses the Net-SNMP
library functions to send a SNMPv1 trap (e.g. coldStart). I have had
very little success and I am looking for help. I am writing this
application on a RedHat Linux platform.

So far, I have a makefile and a source file called 'send_trap.c'. The
makefile is largely based off of the makefile provided in the Net-SNMP
tutorial, but modified to work on my platform. Here are the contents of
the makefile:

-----> BEGIN CODE: makefile <-----
TARGETS=send_trap agent

CFLAGS=-I. 'net-snmp-config --cflags`
BUILDLIBS=`net-snmp-config --libs`
BUILDAGENTLIBS=`net-snmp-config --agent-libs`

# shared library flags (assumes gcc)
DLFLAGS=-fPIC -shared

send_trap: $(TOBJ)
$(CC) -o send_trap $(TOBJ) $(BUILDLIBS)

-----> END CODE <-----

When I execute this makefile, the following is the output:

-----> BEGIN OUTPUT: make send_trap <-----
gcc -I. `net-snmp-config --cflags` -c -o send_trap.o send_trap.c
gcc -o send_trap send_trap.o `net-snmp-config --libs`
/usr/bin/ld: skipping incompatible libnetsnmp.so when searching for
/usr/bin/ld: skipping incompatible libnetsnmp.a when searching for
-----> END OUTPUT: make send_trap <-----

This creates the send_trap executable, but I am not entirely sure about
the meaning of these warnings and whether they are affecting my program
or not.

My 'send_trap.c' program is extremely sparse. I want to send a coldStart
trap and I would like each part (Enterprise, generic, specific, agent
address, destination, varbinds, etc) of the SNMPv1 trap to be variable,
such that I can change 1 or more pieces to make my application send a
different trap. I have read elsewhere that doing each of the following
in succession should result in a trap being sent: init_snmp(),
snmp_open(), snmp_pdu_create(), snmp_add_var(), snmp_send(). Is that
correct? Any suggestions on where specifically to look in the Net-SNMP
documentation to determine how to send a trap from a stand-alone C
application or what needs to be done to accomplish this would be greatly

I apologize for the long post. I look forward to any and all suggestions
or comments. Thank you in advance.


Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
Net-snmp-coders mailing list