darp – how to write your own arp command

For certain reasons, I need to refer to the source files of arp cmd. However, been searching on the net for long time and ended up with no luck. Actually, there is a SRPM mirror for Fedora 18, where you are supposed to find all the source RPMs for all the cmds included in Fedora 18 (but still, no arp). The good thing is I find sth useful from BusyBox, which is an open-source and lightweighted implementation for embedded Linux. Based on that, darp is written. May it help.

1. SRPMs for Fedora 18 (UO mirror)

http://mirror.uoregon.edu/fedora/linux/releases/18/Fedora/source/SRPMS/

2. BusyBox

http://busybox.net/

3. darp

The behavior of darp and arp is similar. Eventually, that was the intention!
darp -a: read “/proce/net/arp” and print the info to the stdout
darp -d: ioctl(SIOCDARP) to delete an entry within the ARP cache
darp -g: ioctl(SIOCGARP) to get an entry within the ARP cache
darp -s: ioctl(SIOCSARP) to set/add an entry into the ARP cache

[daveti@daveti darp]$ ./darp -h
darp -a:
display all the entries within the ARP cache
darp -v:
enable/disable verbose mode
darp -i <interface>:
change the default name of network interface
darp -d <IP>:
remove the entry with this IP address
darp -g <IP>:
get the entry with this IP address
darp -s <IP> <MAC>:
add an entry into the ARP cache with this IP and MAC addresses
darp -h:
display the usage menu
[daveti@daveti darp]$

[root@daveti darp]# ./darp -a
vl-198-gw.uoregon.edu (184.171.60.1) at 00:00:5e:00:01:01 [ether] on em1
dyn-184-171-61-38.uoregon.edu (184.171.61.38) at ec:1a:59:8a:57:96 [ether] on em1
vl-198.uonet3-gw.uoregon.edu (184.171.60.2) at 00:d0:01:7a:28:00 [ether] on em1
[root@daveti darp]# ./darp -g 184.171.61.38
MAC: ec:1a:59:8a:57:96
[root@daveti darp]# ./darp -s 255.255.255.255 00:ff:00:ff:00:ff
[root@daveti darp]# ./darp -a
vl-198-gw.uoregon.edu (184.171.60.1) at 00:00:5e:00:01:01 [ether] on em1
dyn-184-171-61-38.uoregon.edu (184.171.61.38) at ec:1a:59:8a:57:96 [ether] on em1
vl-198.uonet3-gw.uoregon.edu (184.171.60.2) at 00:d0:01:7a:28:00 [ether] on em1
255.255.255.255 (255.255.255.255) at 00:ff:00:ff:00:ff [ether] on em1
[root@daveti darp]# ./darp -d 255.255.255.255
[root@daveti darp]# ./darp -a
vl-198-gw.uoregon.edu (184.171.60.1) at 00:00:5e:00:01:01 [ether] on em1
dyn-184-171-61-38.uoregon.edu (184.171.61.38) at ec:1a:59:8a:57:96 [ether] on em1
vl-198.uonet3-gw.uoregon.edu (184.171.60.2) at 00:d0:01:7a:28:00 [ether] on em1
255.255.255.255 (255.255.255.255) at <incomplete> on em1
[root@daveti darp]# arp -a
vl-198-gw.uoregon.edu (184.171.60.1) at 00:00:5e:00:01:01 [ether] on em1
dyn-184-171-61-38.uoregon.edu (184.171.61.38) at ec:1a:59:8a:57:96 [ether] on em1
vl-198.uonet3-gw.uoregon.edu (184.171.60.2) at 00:d0:01:7a:28:00 [ether] on em1
? (255.255.255.255) at <incomplete> on em1
[root@daveti darp]#

Project Name: darp
Destination: Dave’s ARP command
Language: C
IDE: Vim
Library:
Project Web: https://github.com/daveti/darp
Git Read Only: https://github.com/daveti/darp.git

About daveti

Interested in kernel hacking, compilers, machine learning and guitars.
This entry was posted in Dave's Tools and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s