Get a pointer to the structure through a pointer to a member.

Posted on February 9, 2016, 3:19 pm By
No comments yet Categories: C
Define your own custom conversion specifiers for printf.

In this example we define two specifiers: %P, %W.
%P -> prints IPv4 address from struct in_addr.
%W -> prints IPv6 address from struct in6_addr.

Example code: ( The GNU C Library only. )

Check that network interface is in Promiscuous mode

ifconfig or ip link does not show actual interface promisc status, but we can use this:

if 0 -> not
if 1 -> interface is in promisc mode

Apply user patches in portage ( Gentoo Linux )

In this example we will modify rxvt tabs like this:
rxvt-tab
First, download the patch from here
Then, create directory /etc/portage/patches/x11-terms/rxvt-unicode/ and put patch file there.
Create file /etc/portage/bashrc with code:

Finally emerge rxvt: emerge rxvt-unicode
user-patch

Get CIDR subnet mask from IPv4 address range.

example: $ ./iprange2mask 10.10.0.1 10.10.0.127
25

 

Previous Page