Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reduce size by using search.h for hashtable. #15

Closed
nihilus opened this issue Aug 11, 2016 · 8 comments
Closed

reduce size by using search.h for hashtable. #15

nihilus opened this issue Aug 11, 2016 · 8 comments

Comments

@nihilus
Copy link

nihilus commented Aug 11, 2016

For embedded Linux where space is a constraint it would be good if the hashtable used standard <search.h> hashtable functions.

@nihilus
Copy link
Author

nihilus commented Aug 11, 2016

Also by commenting out the usage I was able to reduce the binary by 20 KB!

@nihilus
Copy link
Author

nihilus commented Aug 11, 2016

Something like this: https://gist.github.com/cirocosta/e61e52cc6afe2633500b

@nihilus
Copy link
Author

nihilus commented Aug 12, 2016

I did fix some stuff over at https://github.com/nihilus/arp-scan

@nihilus nihilus closed this as completed Aug 12, 2016
@nihilus nihilus reopened this Aug 14, 2016
@nihilus
Copy link
Author

nihilus commented Aug 14, 2016

You can easily look at the changes related to the hashmap. However I am not sur how this handles dupes.

@royhills
Copy link
Owner

I'll look at using the hcreate(), hsearch() and hdestroy() posix functions instead of the hash table implementation that I borrowed from gas. The main thing I need to check is that these functions are available on all platforms that arp-scan is used on. That is basically the various flavours of Linux and BSD, as Solaris is not used as much as it used to be.

I'm interested in the reasons behind the changes you've made. I see that you've slimmed things down a lot - is this to reduce the memory footprint of the resulting executable?

@nihilus
Copy link
Author

nihilus commented Aug 14, 2016

@royhills yeah, a footprint of 350kb (MIPS32r2 ISA) when statically linked aginst plain libpcap is undesirable on an embedded Linux system so I figured out I better forked it off and tailored it after my needs.

Contrary to the reentrant hashmap functions (e.g. hsearch_r()) my changes were made to work on OS X.

@royhills
Copy link
Owner

I've implemented your suggestion, and it seems to work fine: it builds and passes checks on Linux (Debian Jessie), FreeBSD 10.2 and Solaris 10 u11, all on x86_64 architecture. I'll check out the other popular systems when I get time.

If you know you'll always be running on Linux, and never BSD or Solaris, you could reduce your footprint a bit by removing link-bpf and link-dlpi and just keeping link-packet-socket. You could also remove the configure.ac logic that chooses between the various link layer implementations to obtain the MAC address.

@royhills
Copy link
Owner

The new version also works on FreeBSD 9.3, NetBSD 6.0.1 and NetBSD 7.0.1. So I suspect it's pretty portable. I'm closing this issue now, as I believe it is resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants