Library to link for net-snmp mib parsing - net-snmp

I am trying to parse a MIB to my sub agent in Linux environment. However the parser code is not working fine. Do I need to link any static/dynamic library for MIB parsing.
I am referring to code from this link which is meant for windows platform : net-snmp sample code to parse MIB file and extract trap related information from it
Kindly suggest If I am missing some library to get mib parsing work.

Related

Getting known library paths from ldconfig for use with dlopen

I have a program written in C that uses dlopen for loading plug-in modules. When the library is dynamically loaded, it runs constructor code which register pointer to structure with function implementations with the main application by use of exported function. I want to use absolute path for specifying the file to dlopen.
Then I have other part of the program with takes file, determine if it is ELF, then looks into the ELF header for specific ELF section, read this section and extract from it pertinent information. This way it filters only shared libraries which I have previously tagged as a plug-in module.
However, I am solving a problem how to discover them on the fly (in portable Linux way, i.e. it will run on Debian and on Fedora too and so on) from the main program. I have been thinking about using ldconfig for this. (As the modules will be installed by way of distro packaging system, APT for example.) Is there any way how to programmatically get the string list of known libraries from C program other than directly reading the /etc/ld.co.cache file? I was thinking that maybe there is some header library which will give char** when I ask.
Or, maybe is there any better solution to my problem?
(I am proponent of using standard system components that programming one-off solutions which will need support in the future.)

How to install library from source code, without any config nor Makefile?

Sorry for what is likely a simple question -- still getting a handle on Linux.
I've been attempting to install the 'FreeMODBUS' library, however judging from the website, it is somewhat outdated. The download link leads to nowhere, however the source code is still accessible via Sourceforge as a .zip download. In the past I've only dealt with libraries that come via .tar, however the bigger issue is that there seems to be no config, makefile nor README detailing the installation process.
Additionally I tried including all of the source code and header files supplied within my Eclipse project. I was hoping that this would be the lazy man's solution to all of my problems -- or at the very least I could compile the .so file myself -- however I'm still getting 'undefined reference to [Function]' errors. From what I understand this is a linking issue. To the best of my knowledge all inclusions are correctly set up.
Is this library deprecated, or is there a step to the process that I'm overlooking? Thanks!
Some superfluous project information:
I'm using modbus for a C project. The network is ideally going to be setup so that a number of modbus enabled devices are configured on a single daisy chained RS-485 hub -- therein containing all our modbus communications to a single comm port in a rather complex system.
The problem however is that popular open source modbus library, 'libmodbus', doesn't appear to lend itself to this configuration. In order to instantiate a modbus node instance, it requires the comm port to be passed, as opposed to the unit's modbus id.

undefined reference when calling code in downloadable kernel module

Following on from a previous question Using system symbol table from VxWorks RTP.
I am porting an existing vxworks kernel module to an RTP, however, much of the actual functionality is still embedded in other "downloadable" kernel modules. These are loaded using loadModule (as part of the startup process), and so should be in the system symbol table at the point my RTP runs.]
However, I cannot get my RTP to build, getting errors from the linker regarding undefined references.
How can I persuade the linker to ignore references to these functions? I am passing the -Xbind-lazy -non-static options to the linker.
As an example, the kernel module (built as database.out) might contain code such as
void writeDatabaseValue(int , char*);
and my RTP application code calls it in the usual way
void main (int)
{
//do some stuff
writeDatabaseValue(0,"foo"); //Linker error here
taskDelay(100); //but no linker error here
}
I have tried adding database.out to the link line using -l:database.out, which resolves the reference to writeDatabaseValue, however I then get into dependency hell, as the linker then tries to resolve all of database.outs references, including all of the standard vxworks api calls.
EDIT: Just for extra complication, some of the kernel module code I want to call is in the same module that actually spawned my RTP......
You are really trying to shoehorn one environment into a totally different one and are experiencing the pain inherent in this approach. I don't believe you will be able to get the linker to ignore the references.
Might be better to use symbolic links (available from within the Workbench environment) to source files and use those in a RTP project.
Or create dynamic libraries based on the DKMs (again, use symbolic links) and link those against your RTP.
As an example, let's say you have the following Workbench workspace:
DKM1
DKM2
RTP
Based on the question, you are attempting to link DKM1 & 2's object files in the RTP and are experiencing pain.
A better approach is to add a project link to the source files in DKM1 & DKM2 and have them compiled in the RTP. Because it is a link (instead of a copy) then changing the file in the DKM (to fix a bug for example) would also change it in the RTP.
In the RTP project, do a "New > Directory". Select the "advanced" button and check the "link to existing directory" then select the "DKM1" directory.
All the source file in the DKM1 will now be part of the RTP. Do the same with DKM2.
When you compile the RTP project, these new files should also be compiled.

Dynamic ELF patching on BSD with libmonkey

I played a little bit with nice library called libmonkey which gives nice interface for dynamic ELF patching on Linux. However, I'm trying to run it on FreeBSD; compilation passed, but I'm getting core dump in runtime (gdb is pointing header offset calculation code).
I'm not familiar with ELF, but aren't headers should be the same on linux and freebsd?
Anyone have idea what is happening?
Thanks

Missing header files using embedded C test environment

I am currently working on my project wherein I need to program a DSP processor for a modem to do binary FSK modulation. The system was earlier using a QPSK modulation. I have use the same infrastructure, only need to modify the frequency modulation technique. The DSP processor is simulated using a set of C files on a LINUX machine and all the code is tested out on LINUX before moving on to the actual device.
Right now I have just started with the programming and I am just trying to compile my current codeset. I am facing a lot of issues with missing header files.
The device infra files use the header files like:
filter.h,
sysreg.h,
builtins.h
Now I am getting all these headers as "file missing" errors. I was able to fix a couple with
#include <sys/reg.h>
#include <linux/filter.h>
But the builtins.h file is still missing and I am not able to compile the code.
I am using UBUNTU 11.10 and gcc version 4.6.1. Is there some special set of files that I need to update for programming with embedded C. Any help would be much appreciated.
builtins.h is a header that is part of the compiler project and specifies which functions are, literally, built-in to the language, according to the gcc docs.
Your problem is that the compiler you're using cannot find this file.
You have two options:
The first, assuming everything else is set up correctly, is to run find /usr -name "builtins.h" to locate the file and add that directory to the include (-I/path/to/dir) path.
If the system uses some form of cross compiler, make sure you're using that, rather than your host's gcc. If you aren't using the correct toolchain, I suspect you'll have problems linking, too.

Resources