libipq not supported in Ubuntu 12.04 - c

I have the requirement of altering packets as a part of my University's research project and came across two libraries. which are libnetfilter_queue and libipq which is the deprecated version. libnetfilter_queue documentation is next to zero on packet alteration and the only good documentation I came across is done via libipq.
Thus, when I run my code I get the error passer: Unable to create netlink socket: Protocol not supported which I found out that is due to the fact that libipq is not supported in the new linux kernels.
My query is, is there a work around to make libipq work with Ubuntu 12.04 LTS or any reference to documentation or tutorials that would help implement packet alteration via libnetfilter_queue.
I was at this for some days and could not find solution. you help will be very much appreciated. :)
Thank you very much :)
P.S: the question is also posted over here ( https://askubuntu.com/questions/430234/libipq-not-supported-in-ubuntu-12-04-lts )

Once the ip_queue module is gone, then you can't use libipq, as it leverages that module directly; so no, there's no workaround unless you install an older kernel that still has the ip_queue module.
That said, you've mentioned absolutely nothing about what you've actually tried. If you start from a basic libnetfilter_queue example, when you're setting the verdict, you should be using nfq_set_verdict, passing in the data_len and buf parameters containing the swizzled packet data.

Related

Compile RAID controller device driver (linux kernel module)

I have an adaptec 6805e RAID controller and I'm looking to compile the linux driver for ubuntu 20.04 (kernel=v5.4) but there have been a vast number of changes between kernel ~4x => 5x and I'm not a kernel developer.
OS:
Ubuntu LTS 20.04
Kernel:
v5.4
Adaptec 6805e:
https://storage.microsemi.com/en-us/support/raid/sas_raid/sas-6805e/
Any obvious major hurdles, or advice is appreciated, but right now the issue I'm having is trying to find a replacement for the 'pci_set_dma_max_seg_size' function. I have found the 'dma_set_max_seg_size' but that function accepts a generic device structure (struct device), whereas the adaptec code is using the (struct pci_dev) structure that seems to be specific for PCI devices.
aacraid-1.2.1-52011/linit.c:3992:10: error: implicit declaration of function ‘pci_set_dma_max_seg_size’; did you mean ‘dma_set_max_seg_size’? [-Werror=implicit-function-declaration]
3992 | error = pci_set_dma_max_seg_size(pdev,
Like I said any help is appreciated and if this seems like the wrong way to resolve this problem I'm open to ideas -- I'd like to be able to utilize the benefits of more recent linux developments with a slightly older adaptec chipset.
Thanks
Reference materials:
https://elixir.bootlin.com/linux/v5.4.128/source/include/linux
I believe since Linux v4.x you fell victim to (or benefitted from, depending on your perspective) an effort to overhaul the DMA unmapping support. That patchset, and particularly the specific patch linked to here, show what PCI driver maintainers who were obliged to accommodate this rework were expected to do:
[3/3] PCI: remove pci_set_dma_max_seg_size
Fortunately for you, they gave specific examples of how existing drivers got patched and it's not bad. It should be pretty straightforward for you to figure out at least roughly the Linux version this change corresponds to around the 2018-19 date of the patch's acceptance upstream, code a new stanza in the Adaptec driver source to update it accordingly (e.g.
#if ((LINUX_VERSION_CODE > KERNEL_VERSION(5,1,0))
<patch Adaptec's code to use dma_set_max_seg_size() here>
#else
compile the driver and be on your way. Note that the README does not explicitly mention support for the Adaptec 6805e RAID controller yet, so if you manage to make it work and post your patch you should at least add a comment to the effect that you believe this supports the controller now.

C Programming - Accessing USB Data / Driver Specifics

I am writing some simple test automation to access the USB port in Ubuntu, and determine driver specific details, devices that are connected, and operating mode (USB 2 , 3 , etc ...).
I have not done any development in this area, and was looking for advice on libraries / recommendations to accomplish this.
Thank you for you help!
Dan.
I've done this using libusb. You can get get started here. http://libusb.sourceforge.net/api-1.0/ If you're just looking at seeing various usb devices, it's pretty easy. Here are some examples that you can get up and running pretty quickly: http://www.dreamincode.net/forums/topic/148707-introduction-to-using-libusb-10/
I found the sourceforge info useful, but could not get the install to work in Ubuntu.
After some searching, I found Libusb and how to use its packages in Ubuntu
This appears to resolve my issue; plus interesting point about using usb.h instead of libusb.h to compile.
Thanks for all the input!
Dan

FreeBSD POSIX C Oracle API

I have trouble finding Oracle Call Interface for FreeBSD. I maybe missing something simple but I searched net for several days and finally ended up here with question.
My task is fairly simple: write a program in posix C that connects to an Oracle database and works on a FreeBSD machine. In worst case scenario I will drop the POSIX and FreeBSD part and make it work on Linux but so far my goal is to do this on BSD. Here is what I found so far:
ftp://ftp.atnet.ru/pub/OS/FreeBSD/oracle/otl/otl.htm
A GNU library which I have not tested yet, if anybody knows anything about it please do tell so:
http://sourceforge.net/projects/orclib/files/OCILIB%20Sources/3.12.1/
If you have any kind of suggestion of how this could be done better please do tell. Or even better if you have experience in this situation.
Oracle themselves do not support FreeBSD. There are ports of their Linux client-libraries, however, that are made to work on the OS:
databases/oracle8-client
databases/oracle7-client
Unfortunately, the above two are currently only working on i386, but you may be able to use the same technique as the port's author to massage the x86_64 Linux binaries to work under FreeBSD/amd64.
And then there is a port of the open-source ODBC driver in:
databases/oracle_odbc_driver
This one requires oracle8-client and is thus also i386-only at this time.
There is oracle instance client for Mac OS X. AFAIK Mac OS somehow related to FreeBSD codebase. So, perhaps, adaptation of Mac OS client would be easier then Linux one. (I didn't try it however).

ZeroMQ Request/Reply does not reply in one direction

I use ZeroMQ's C interface to distribute computation among several machines. Locally, everything works as expected with tcp://localhost:5555. However, when running client and server on two machines A and B, the request and reply only works when the server is running on A and client is running on B. If it's the other way around, only the request is received on B and the client on A never receives the reply.
To verify, that I setup everything correctly, I compiled the first example from the ZeroMQ guide but there is the same problem.
What could be the cause of this behaviour?
The problem is most likely caused by two incompatible versions of 0MQ.
This is a known problem with 0MQ v3.0.x, 3.1.x, 3.2.0, 3.2.1. These versions all used an undocumented, incompatible version of the protocol (with no version number, so very hard to get interoperating), which was finally fixed in 3.2.2 stable. If you're running the older version, and this may have come with the language binding you're using, upgrade it. If there are serious reasons why you cannot upgrade, e.g. you have clients in the wild who are using the older versions, ask on the zeromq-dev list, someone may be able to help. For what it's worth, the protocol now has version numbers, and is backwards compatible with previous stable releases (2.2 and 2.1).

libudev advice needed

I am embarking on a programming project that will need to confirm device identity of removable media (e.g. usb thumb drives) before it will go on to do a bunch of other cool stuff.
Some friends of mine pointed me towards using the Serial Number, and preliminary testing using the udevadm command indicates that this should work. I did some additional checking and it appears that if I can get the software working with libudev then it should (minimally) compile on ubuntu, slackware and gentoo, which would be a really nice benefit.
So I used bing to find a tutorial and got the Signal 11 site (http://www.signal11.us/oss/udev/) it's a very well-written tutorial. It actually seems to have everything I need. I download the code. Fix a couple of platform-specific bugs and then compile. BOOM! Gcc compiles without errors. So far so good.
But when I try to run it, it kicks up a couple of bugs, and I realize that I need to read some more tutorials so that I can understand libudev well enough to fix the bugs, and to turn out working software. Problem is that there really ISN'T any other tutorials (that I can find) and the kernel.org site that is the (only known?) site of the library documentation is down after a recent server compromise.
I considered just issuing udevadm directives to system() and then parsing results, but that's a really hackish way to put software together, and I am planning on releasing this to the community when I'm finished writing.
So how best for me to learn libudev??
libudev is quite simple library. After reading library you've mentioned and using API documentation (site should be soon up) I was able to get what I wanted. udevadm is great help, after issuing # udevadm info --query=all --name=/path/to/dev you'll get all information that udev has about this device and what's more important, these are parameters used in property functions (e.g. udev_device_get_property_value(device, "ID_VENDOR")). So best way to learn libudev is to start using it with help of signal11 tutorial, API documentation and udevadm informations.
EDIT: libudev is currently part of systemd - documentation is available as manual pages - https://www.freedesktop.org/software/systemd/man/libudev.html#
For those looking in 2023...
As Maciej pointed out, libudev is now a part of systemd.
According to:
https://www.freedesktop.org/software/systemd/man/libudev.html#
...this library is supported, but should not be used in new projects.
Please see sd-device(3) for an equivalent replacement with a more
modern API.
Documentation for sd-device:
https://www.freedesktop.org/software/systemd/man/sd-device.html#

Resources