source: MondoRescue/branches/stable/mindi-busybox/networking/udhcp/options.c@ 1770

Last change on this file since 1770 was 1770, checked in by Bruno Cornec, 16 years ago
  • Better output for mindi-busybox revision
  • Remove dummy file created on NFS - report from Arnaud Tiger <arnaud.tiger_at_hp.com>
  • strace useful for debug
  • fix new versions for pb (2.0.0 for mindi and 1.7.2 for mindi-busybox)
  • fix build process for mindi-busybox + options used in that version (dd for label-partitions-as-necessary)
  • fix typo in label-partitions-as-necessary which doesn't seem to work
  • Update to busybox 1.7.2
  • perl is now required at restore time to support uuid swap partitions (and will be used for many other thigs

in the future for sure)

  • next mindi version will be 2.0.0 due to all the changes made in it (udev may break working distros)
  • small optimization in mindi on keyboard handling (one single find instead of multiple)
  • better interaction for USB device when launching mindi manually
  • attempt to automatically guess block disk size for ramdisk
  • fix typos in bkphw
  • Fix the remaining problem with UUID support for swap partitions
  • Updates mondoarchive man page for USB support
  • Adds preliminary Hardware support to mindi (Proliant SSSTK)
  • Tries to add udev support also for rhel4
  • Fix UUID support which was still broken.
  • Be conservative in test for the start-nfs script
  • Update config file for mindi-busybox for 1.7.2 migration
  • Try to run around a busybox bug (1.2.2 pb on inexistant links)
  • Add build content for mindi-busybox in pb
  • Remove distributions content for mindi-busybox
  • Fix a warning on inexistant raidtab
  • Solve problem on tmpfs in restore init (Problem of inexistant symlink and busybox)
  • Create MONDO_CACHE and use it everywhere + creation at start
  • Really never try to eject a USB device
  • Fix a issue with &> usage (replaced with 1> and 2>)
  • Adds magic file to depllist in order to have file working + ldd which helps for debugging issues
  • tty modes correct to avoid sh error messages
  • Use ext3 normally and not ext2 instead
  • USB device should be corrected after reading (take 1st part)
  • Adds a mount_USB_here function derived from mount_CDROM_here
  • usb detection place before /dev detection in device name at restore time
  • Fix when restoring from USB: media is asked in interactive mode
  • Adds USB support for mondorestore
  • mount_cdrom => mount_media
  • elilo.efi is now searched throughout /boot/efi and not in a fixed place as there is no standard
  • untar-and-softlink => untar (+ interface change)
  • suppress useless softlinks creation/removal in boot process
  • avoids udevd messages on groups
  • Increase # of disks to 99 as in mindi at restore time (should be a conf file parameter)
  • skip existing big file creation
  • seems to work correctly for USB mindi boot
  • Adds group and tty link to udev conf
  • Always load usb-torage (even 2.6) to initiate USB bus discovery
  • Better printing of messages
  • Attempt to fix a bug in supporting OpenSusE 10.3 kernel for initramfs (mindi may now use multiple regex for kernel initrd detection)
  • Links were not correctly done as non relative for modules in mindi
  • exclusion of modules denied now works
  • Also create modules in their ordinary place, so that classical modprobe works + copy modules.dep
  • Fix bugs for DENY_MODS handling
  • Add device /dev/console for udev
  • ide-generic should now really be excluded
  • Fix a bug in major number for tty
  • If udev then adds modprobe/insmod to rootfs
  • tty0 is also cretaed with udev
  • ide-generic put rather in DENY_MODS
  • udevd remove from deplist s handled in mindi directly
  • better default for mindi when using --usb
  • Handles dynamically linked busybox (in case we want to use it soon ;-)
  • Adds fixed devices to create for udev
  • ide-generic should not be part of the initrd when using libata v2
  • support a dynamically linked udev (case on Ubuntu 7.10 and Mandriva 2008.0 so should be quite generic) This will give incitation to move to dyn. linked binaries in the initrd which will help for other tasks (ia6 4)
  • Improvement in udev support (do not use cl options not available in busybox)
  • Udev in mindi
    • auto creation of the right links at boot time with udev-links.conf(from Mandriva 2008.0)
    • rework startup of udev as current makes kernel crash (from Mandriva 2008.0)
    • add support for 64 bits udev
  • Try to render MyInsmod silent at boot time
  • Adds udev support (mandatory for newest distributions to avoid remapping of devices in a different way as on the original system)
  • We also need vaft format support for USB boot
  • Adds libusual support (Ubuntu 7.10 needs it for USB)
  • Improve Ubuntu/Debian keyboard detection and support
  • pbinit adapted to new pb (0.8.10). Filtering of docs done in it
  • Suppress some mondo warnings and errors on USB again
  • Tries to fix lack of files in deb mindi package
  • Verify should now work for USB devices
  • More log/mesages improvement for USB support
  • - Supress g_erase_tmpdir_and_scratchdir
  • Improve some log messages for USB support
  • Try to improve install in mindi to avoid issues with isolinux.cfg not installed vene if in the pkg :-(
  • Improve mindi-busybox build
  • In conformity with pb 0.8.9
  • Add support for Ubuntu 7.10 in build process
  • Add USB Key button to Menu UI (CD streamer removed)
  • Attempt to fix error messages on tmp/scratch files at the end by removing those dir at the latest possible.
  • Fix a bug linked to the size of the -E param which could be used (Arnaud Tiger/René Ribaud).
  • Integrate ~/.pbrc content into mondorescue.pb (required project-builder >= 0.8.7)
  • Put mondorescue in conformity with new pb filtering rules
  • Add USB support at restore time (no test done yet). New start-usb script PB varibale added where useful
  • Unmounting USB device before removal of temporary scratchdir
  • Stil refining USB copy back to mondo (one command was not executed)
  • No need to have the image subdor in the csratchdir when USB.
  • umount the USB partition before attempting to use it
  • Remove useless copy from mindi to mondo at end of USB handling

(risky merge, we are raising the limits of 2 diverging branches. The status of stable is not completely sure as such. Will need lots of tests, but it's not yet done :-()
(merge -r1692:1769 $SVN_M/branches/2.2.5)

File size: 5.6 KB
Line 
1/* vi: set sw=4 ts=4: */
2/*
3 * options.c -- DHCP server option packet tools
4 * Rewrite by Russ Dill <Russ.Dill@asu.edu> July 2001
5 */
6
7#include "common.h"
8#include "dhcpd.h"
9#include "options.h"
10
11
12/* supported options are easily added here */
13const struct dhcp_option dhcp_options[] = {
14 /* name[12] flags code */
15 {"subnet", OPTION_IP | OPTION_REQ, 0x01},
16 {"timezone", OPTION_S32, 0x02},
17 {"router", OPTION_IP | OPTION_LIST | OPTION_REQ, 0x03},
18 {"timesvr", OPTION_IP | OPTION_LIST, 0x04},
19 {"namesvr", OPTION_IP | OPTION_LIST, 0x05},
20 {"dns", OPTION_IP | OPTION_LIST | OPTION_REQ, 0x06},
21 {"logsvr", OPTION_IP | OPTION_LIST, 0x07},
22 {"cookiesvr", OPTION_IP | OPTION_LIST, 0x08},
23 {"lprsvr", OPTION_IP | OPTION_LIST, 0x09},
24 {"hostname", OPTION_STRING | OPTION_REQ, 0x0c},
25 {"bootsize", OPTION_U16, 0x0d},
26 {"domain", OPTION_STRING | OPTION_LIST | OPTION_REQ, 0x0f},
27 {"swapsvr", OPTION_IP, 0x10},
28 {"rootpath", OPTION_STRING, 0x11},
29 {"ipttl", OPTION_U8, 0x17},
30 {"mtu", OPTION_U16, 0x1a},
31 {"broadcast", OPTION_IP | OPTION_REQ, 0x1c},
32 {"nisdomain", OPTION_STRING | OPTION_REQ, 0x28},
33 {"nissrv", OPTION_IP | OPTION_LIST | OPTION_REQ, 0x29},
34 {"ntpsrv", OPTION_IP | OPTION_LIST | OPTION_REQ, 0x2a},
35 {"wins", OPTION_IP | OPTION_LIST, 0x2c},
36 {"requestip", OPTION_IP, 0x32},
37 {"lease", OPTION_U32, 0x33},
38 {"dhcptype", OPTION_U8, 0x35},
39 {"serverid", OPTION_IP, 0x36},
40 {"message", OPTION_STRING, 0x38},
41 {"vendorclass", OPTION_STRING, 0x3C},
42 {"clientid", OPTION_STRING, 0x3D},
43 {"tftp", OPTION_STRING, 0x42},
44 {"bootfile", OPTION_STRING, 0x43},
45 {"userclass", OPTION_STRING, 0x4D},
46#if ENABLE_FEATURE_RFC3397
47 {"search", OPTION_STR1035 | OPTION_LIST | OPTION_REQ, 0x77},
48#endif
49 /* MSIE's "Web Proxy Autodiscovery Protocol" support */
50 {"wpad", OPTION_STRING, 0xfc},
51 {"", 0x00, 0x00}
52};
53
54/* Lengths of the different option types */
55const unsigned char option_lengths[] ALIGN1 = {
56 [OPTION_IP] = 4,
57 [OPTION_IP_PAIR] = 8,
58 [OPTION_BOOLEAN] = 1,
59 [OPTION_STRING] = 1,
60#if ENABLE_FEATURE_RFC3397
61 [OPTION_STR1035] = 1,
62#endif
63 [OPTION_U8] = 1,
64 [OPTION_U16] = 2,
65 [OPTION_S16] = 2,
66 [OPTION_U32] = 4,
67 [OPTION_S32] = 4
68};
69
70
71/* get an option with bounds checking (warning, not aligned). */
72uint8_t *get_option(struct dhcpMessage *packet, int code)
73{
74 int i, length;
75 uint8_t *optionptr;
76 int over = 0, done = 0, curr = OPTION_FIELD;
77
78 optionptr = packet->options;
79 i = 0;
80 length = 308;
81 while (!done) {
82 if (i >= length) {
83 bb_error_msg("bogus packet, option fields too long");
84 return NULL;
85 }
86 if (optionptr[i + OPT_CODE] == code) {
87 if (i + 1 + optionptr[i + OPT_LEN] >= length) {
88 bb_error_msg("bogus packet, option fields too long");
89 return NULL;
90 }
91 return optionptr + i + 2;
92 }
93 switch (optionptr[i + OPT_CODE]) {
94 case DHCP_PADDING:
95 i++;
96 break;
97 case DHCP_OPTION_OVER:
98 if (i + 1 + optionptr[i + OPT_LEN] >= length) {
99 bb_error_msg("bogus packet, option fields too long");
100 return NULL;
101 }
102 over = optionptr[i + 3];
103 i += optionptr[OPT_LEN] + 2;
104 break;
105 case DHCP_END:
106 if (curr == OPTION_FIELD && over & FILE_FIELD) {
107 optionptr = packet->file;
108 i = 0;
109 length = 128;
110 curr = FILE_FIELD;
111 } else if (curr == FILE_FIELD && over & SNAME_FIELD) {
112 optionptr = packet->sname;
113 i = 0;
114 length = 64;
115 curr = SNAME_FIELD;
116 } else done = 1;
117 break;
118 default:
119 i += optionptr[OPT_LEN + i] + 2;
120 }
121 }
122 return NULL;
123}
124
125
126/* return the position of the 'end' option (no bounds checking) */
127int end_option(uint8_t *optionptr)
128{
129 int i = 0;
130
131 while (optionptr[i] != DHCP_END) {
132 if (optionptr[i] == DHCP_PADDING) i++;
133 else i += optionptr[i + OPT_LEN] + 2;
134 }
135 return i;
136}
137
138
139/* add an option string to the options (an option string contains an option code,
140 * length, then data) */
141int add_option_string(uint8_t *optionptr, uint8_t *string)
142{
143 int end = end_option(optionptr);
144
145 /* end position + string length + option code/length + end option */
146 if (end + string[OPT_LEN] + 2 + 1 >= 308) {
147 bb_error_msg("option 0x%02x did not fit into the packet",
148 string[OPT_CODE]);
149 return 0;
150 }
151 DEBUG("adding option 0x%02x", string[OPT_CODE]);
152 memcpy(optionptr + end, string, string[OPT_LEN] + 2);
153 optionptr[end + string[OPT_LEN] + 2] = DHCP_END;
154 return string[OPT_LEN] + 2;
155}
156
157
158/* add a one to four byte option to a packet */
159int add_simple_option(uint8_t *optionptr, uint8_t code, uint32_t data)
160{
161 const struct dhcp_option *dh;
162
163 for (dh = dhcp_options; dh->code; dh++) {
164 if (dh->code == code) {
165 uint8_t option[6], len;
166
167 option[OPT_CODE] = code;
168 len = option_lengths[dh->flags & TYPE_MASK];
169 option[OPT_LEN] = len;
170 if (BB_BIG_ENDIAN) data <<= 8 * (4 - len);
171 /* This memcpy is for broken processors which can't
172 * handle a simple unaligned 32-bit assignment */
173 memcpy(&option[OPT_DATA], &data, 4);
174 return add_option_string(optionptr, option);
175 }
176 }
177
178 bb_error_msg("cannot add option 0x%02x", code);
179 return 0;
180}
Note: See TracBrowser for help on using the repository browser.