Commit Graph

30 Commits

Author SHA1 Message Date
Roy Marples
601fb3d500 Add (c) to Copyright 2009-05-01 13:57:45 +00:00
Roy Marples
eab2229cfa Enforce NetBSD KNF style more 2009-02-11 17:56:22 +00:00
Roy Marples
765fbf7db0 Remove logger and exclusively uses syslog instead. This saves almost 2K on NetBSD/amd64 from before changing strerror to %m. 2008-09-05 18:24:34 +00:00
Roy Marples
b8b4be9a39 Remove #ifdefs to disable specific bits of code. We now build everything - we're small enough :) 2008-07-23 17:06:42 +00:00
Roy Marples
c4d4ee1358 fd -> raw_fd 2008-07-16 08:10:41 +00:00
Roy Marples
dca5f15979 Fix sending of ARP packets. 2008-07-10 15:32:03 +00:00
Roy Marples
217e8e835e Cleaner fix for working with PCC. 2008-07-03 17:07:24 +00:00
Roy Marples
1d49ff6f18 Work around PCC not supporting the __packed__ attribute on structures. dhcpcd now works fully with PCC on NetBSD-4.99.67. 2008-07-03 00:12:57 +00:00
Roy Marples
79d4dc8869 Cleaner code when ARP is disabled. 2008-06-30 16:14:56 +00:00
Roy Marples
eb942e0abc Remove the signal array stack as our pipe handling should be secure enough now. Also, move the normalize close_on_exec and setting non block. 2008-06-10 22:23:57 +00:00
Roy Marples
785fb9f2b2 Fix compile. 2008-06-09 08:21:28 +00:00
Roy Marples
5fb580a771 Re-write the client state engine around a simple timer instead of complex loops. Use the re-transmission times as per RFC 2131. Integrate the ARP handling code in the new engine so we are able to defend our IPV4LL address whilst negotiating a DHCP lease. This also means we're able to bind the address and fork BEFORE waiting to send announcements which makes us appear faster on the commandline. 2008-06-08 20:07:54 +00:00
Roy Marples
29cdf2857e Put my code at the top and UNCONST filters in bpf.c 2008-05-22 18:16:22 +00:00
Roy Marples
f3053f4759 No need for this check with our non blocking sockets. 2008-05-15 14:20:01 +00:00
Roy Marples
57220ee062 get_packet 0 means no more buffer, so loops don't need to know the bpf/socket buffering. 2008-05-15 13:34:31 +00:00
Roy Marples
fe965fea17 Fix bpf for the correct position on new buffers. 2008-05-15 12:32:27 +00:00
Roy Marples
811d4272b5 Only alloc a buffer if size is different. 2008-05-15 12:15:06 +00:00
Roy Marples
3581b92aa4 Fix some valgrind errors, and work on Linux again. 2008-05-15 11:12:44 +00:00
Roy Marples
b1009e62b2 Improve get_packet API and memcpy to structure instead of using union pointers. 2008-05-15 10:10:39 +00:00
Roy Marples
a1613b91fd Prettify code a little. 2008-05-14 12:05:04 +00:00
Roy Marples
45e1c85466 BIOCIMMEDIATE isn't always available 2008-05-14 11:53:58 +00:00
Roy Marples
f409012f02 Repair whitespace damage. 2008-04-26 07:39:23 +00:00
Roy Marples
35ff0dbb35 We should send packets to a specific IP over the udp socket so we don't broadcast on layer 2 and unicast on layer 3, #64. 2008-04-20 19:02:19 +00:00
Roy Marples
574011fc89 If _PATH_BPF is set, open that instead of searching for a free BPF device. 2008-04-17 09:47:11 +00:00
Roy Marples
1a60d14fa2 Normally I hate massive code drops, but heh.
The code has been drastically re-arranged.
Instead of populating a custom structure while parsing dhcp messages, we now pluck what we need right out of the message itself. We have custom functions and a lookup table to make this really easy.
This makes us more like dhclient and udhcpc, and will enable us to easily add (and remove!) more dhcp options without having to actually change the code (much).
We now store the real dhcp message we got in /var/db/dhcpcd-$iface.lease, the mtime of the file being used as when we got the lease. This file is read in when re-using an old lease instead of parsing the .info file.
The benefit of all of this means that we're actually ~15k smaller when compiled with the same features.
This has been tested for quite some time, and I'm pretty sure most bugs with the 3.2 branch have been fixed whilst making this. Right now, we are 99% command line compatible with the 3.2 branch.
2008-04-11 16:14:55 +00:00
Roy Marples
211da07349 read(2) works on ssize_t so we should use this rather than size_t for our buffers. A DHCP or ARP packet still easily fits into this. 2008-03-31 10:23:59 +00:00
Roy Marples
0a204e3b98 Pointless looping in bpf.packet, as pointed out by D. Young. 2008-03-30 08:26:34 +00:00
Roy Marples
453072ef8f Rework our error handling code a little to save ~5k on x86_64 2008-03-29 08:40:55 +00:00
Roy Marples
5c7da81448 Fix compile on BSD. 2008-03-24 01:45:37 +00:00
Roy Marples
a9819bfb1f Split interface and socket out into OS bpf, if-bsd and if-linux. 2008-03-24 01:29:33 +00:00