Is there any way to retrieve the mac-address for the given ip-address from the ARP table without providing the Interface name ??
I do know the procedure of retrieving the mac address using ioctl call but in that case I should provide the interface name .. :(
One Crude Solution: Read /proc/net/arp file ... :( .. other than that .. any system call or anything else where i can retrieve the mac-address without the need of interface name ??
NOTE: Simple C based solution not interested in scripting libraries.
NOTE: I am expecting a *NUX based solution rather than WINDOWS based one.
I do know the procedure of retrieving
the mac address using ioctl call but
in that case I should provide the
interface name
So all you need is a way to find the interface name associated with a given IP. The ioctl SIOCGIFCONF will give you that.
Related
I would like to programmatically set a CAN device through C.
I can do this using IP Link through the terminal with:
ip link set can0 up type can bitrate 500000
How can I achieve this using C
I've looked around the iplink code on GitHub but I can't seem to work it out.
Could you please send me in the right direction or even provide an example? I am far from fluent in C
I'm trying to find out the best way to acquire the unique D-Bus address of an object in the D-Bus system bus using the GDBus library on Linux.
Here are version numbers of the libraries I am using:
# ls /usr/lib |grep -e dbus -e glib -e gio
libdbus-1.so
libdbus-1.so.3
libdbus-1.so.3.14.11
libdbus-glib-1.so
libdbus-glib-1.so.2
libdbus-glib-1.so.2.3.3
libgio-2.0.so
libgio-2.0.so.0
libgio-2.0.so.0.5000.3
libglib-2.0.so
libglib-2.0.so.0
libglib-2.0.so.0.5000.3
Basically, I want to know the unique name/address of the object /org/bluez/hci0 located on the system bus using gdbus library. Does anyone have an example of how I would do this using the C library?
Right now I can use the command
# dbus-monitor --system
To figure out that the address I need is :1.22. I'm almost certain that there's a better way to find the address then parsing the text output of that command.
Thanks!
Why not use the well-known name of the service to find it (and if you want to keep track of the current unique owner, use g_bus_watch_name() to get it).
In fact, in the case of bluez I don't think there's ever a reason to search for "/org/bluez/hci0" as you should be using D-Bus ObjectManager API to find the objects/interfaces that the bluez service exports.
To clarify some of the concepts here:
D-Bus address: There is no such thing as an ‘address’ in D-Bus in the way you’re thinking. There are object paths, well-known names and unique names. The term ‘address’ is used to describe the socket path which clients use to connect to the dbus-daemon, but this is unrelated to what you’re asking.
Unique name: Like :1.22, this uniquely identifies a particular connection to the dbus-daemon. Typically, each application has one connection to the daemon, so this typically identifies a single application. (However, applications can have more than one connection to the bus if they want; if so, each connection would have a different unique address). A well-known name is a consistent name for a service’s connection to the dbus-daemon, which is used as an alias for its unique name. For example, org.bluez or org.freedesktop.FileManager1 are both well-known names.
Object address: Like /org/freedesktop/SomeService/blah, this is actually called an object path. Object paths are only unique within the context of a single D-Bus connection, so the path /a/b/c will typically refer to different objects for D-Bus connections :1.1 and :1.2. (Hence the question “how can I find the unique name of the object path /a/b/c?” is ill-formed, because there may be many unique names which export such an object.)
I'am working on an program in C for a web connected touchscreen.
In case internet is down, my boss want me to write in a low secured file the intels about the sales, for memory when internet will be back.
For now, its on a .txt, and I'd like to set the attribute of the file in "hidden".
One of you got a function or an open flag for that case?
The OS I am using is Windows 7.
This is specific to the operation system.
When you create a file you can pass a couple of attributes describing the file.
In case of windows you have : FILE_ATTRIBUTE_HIDDEN.
If you already have a file you can call the SetFileAttributes function.Check this link from msdn :
https://msdn.microsoft.com/en-us/library/windows/desktop/aa365535(v=vs.85).aspx.
In Windows you can use SetFileAttributes() function described here
I already know that I can read the password structure (getpwnam etc.) but how can I alter the specific password. Do I have to lock the master.passwd and modify it directly or better make a copy from master.passwd modify this and make a file move after correct modifications?
At last, I don't want to make a system(usermod ...) because that invokes the shell and should be the last solution!
Thanks in advance
In C for Unix like Solaris or AIX , you can either :
Use PAM API if available. Here are some articles about it on Solaris.
Add a new password with putpwent
Change existing password with getpwent, crypt your new password and finish with endpwent
You'll see here a complete sample program to change a pasword for unix in C using putpwent & getpwent. AIX documentation seems to confirm it should also works on their OS.
I am working under Linux, with two physical ethernet interfaces.
I have grouped the two interfaces to a bonding interface for backup... and it works.
I would like to know if there is any way to know, from my C user program, what is the active interface.
Thanks
Look at /sys/class/net/bond0/bonding/active_slave and read it using a program or code of your choice. (Replace path accordingly if using an interface name different from bond0.)
Another method to know it (tested on Debian) is looking at the file /proc/net/bonding/bondX. Replace bondX with the name of your interface.