I’m going to implement a firewall on the traffic control classifier(man 8 tc-bpf). The firewall is to filter outgoing traffic. But, there is one point which makes the task really hard. My userspace agent must know, is that filter(classifier) loaded and passing all outgoing traffic through itself or not. Please tell me: How to protect loaded filter from unloading(tc filter
Tag: c++
Setting both read() and send() timeouts for the same C socket on linux
I managed to set a read timeout for a C socket with: Now, I want to make this same socket timeouts for send operations. I have found in setsockopt that the proper way to set a timeout for send is quite similar, just replacing SO_RCVTIMEO by SO_SNDTIMEO: My question is if does a successive call of setsockopt overrides the previous
C close() : Invalid argument
Sorry per advance for my english, i’m not english native and be indulgent i’m also a student. I’m trying to recreate the pipe function in C, but i have a problem when i try to close pipe fd before the dup2(), the function close() return me an error Ïnvalid argument, i have already check if my fd is valid and
A c program file on linux became green and now I cannot edit it
Hi I have a c file in program which is called helloQV.c I ran the command gcc -Wall -ansi -std=c99 helloQV.c -o helloQV.c but now I cannot edit the file helloQV.c, when I open the file in vim it turns out to be just a bunch of random symbols. I realized I should have named the -o HelloQV.c to something
Makefile: “No rule to make … needed by ‘all'” despite all files being there
I’m having this weird problem with this makefile. Despite having all the required .c files, the compiling process stops at the first instruction, with this error. make: *** No rule to make target ‘printerTest.umps’, needed by ‘all’. Stop. This exact code with the same exact files works in Debian Linux, though in Manjaro Arch Linux it return the error shown
Stringizing / stringify name mangling
I load a path name with cmake and want to use as a string in my C++ program to load some data. For this the stringification operator # is really handy – I use the macro provided in this answer which is the same as here. Now when I have “linux” or “unix” in my path, this goes horribly wrong
OpenMP Matrix Multiplication Issues
I am trying to multiple the values of a matrix. I have both a parallel and sync version. But the parallel version is longer than the sync version. Current the sync takes around 90 seconds and the parallel over 100. Which makes no sense to me. My logic was to split the matrix into 4 parts from the first 4
Changing the file’s creation timestamp in Linux programmatically in C/C++
The statx() system call was added to Linux kernel and now it is possible to get the creation (birth) time of the file from statx.stx_btime stucture field on supported filesystems. But I can’t find any support in utimensat() of similar system calls. Is it possible to change file’s creation timestamp in C/C++ and how? Answer statx.stx_btime is filesystem-specific. Linux has
How can I take average of second column for degenerate values of first column in c++/python or using any other linux command?
I have a collection of data in a text file arranged in two columns. What I want is to calculate the average value for repeating numbers in the first column. e.g. for the first three rows take one average of the second column and so on. I will be grateful for any help you can provide. 0.628319 0.123401 0.628319 0.23044
How would I reproduce the functionality of the Windows winusb driver on Linux? Do I even need to?
I need to implement an application on Linux that drives a USB connected device (a medical instrument). The application will be written in C++ (2011 standard). The current application is written for Windows 10 in C# and uses the standard Winusb driver enumerated for the device. I have a complete protocol specification for the commands and the events/interrupts coming back.