summaryrefslogtreecommitdiff
path: root/lib/libstand/bootp.c
Commit message (Collapse)AuthorAgeFilesLines
* Move lib/libstand to sys/boot/libsaWarner Losh2017-10-121-791/+0
| | | | | | | | | | Move the sources to sys/boot. Make adjustments related to the move. Kill LIBSTAND_SRC since it's no longer needed. Sponsored by: Netflix Notes: svn path=/head/; revision=324551
* use the same option list for dhcp discovery and requestToomas Soome2017-05-281-28/+31
| | | | | | | | | | | | | The DHCP client is supposed to use the same option request list for both DHCP discovery and request. This will also allow us to fill the list in single function. Reviewed by: bapt Differential Revision: https://reviews.freebsd.org/D10981 Notes: svn path=/head/; revision=319085
* Use the usual FreeBSD spelling for the DHCP user classBaptiste Daroussin2017-05-271-1/+1
| | | | | | | Reported by: lidl Notes: svn path=/head/; revision=318993
* Always issue the pxe requestBaptiste Daroussin2017-05-271-31/+25
| | | | | | | | | | | | | | | | | All the code are now only issueing one single dhcp request at startup of the loader meaning we can always request a the PXE informations from the dhcp server. Previous code lost that information, meaning no option 55 anymore (meaning not working with the kea dhcp server) and no request for rootpath etc, no user class Remove the flags from the bootp function which is not needed anymore Reviewed by: tsoome Differential Revision: https://reviews.freebsd.org/D10952 Notes: svn path=/head/; revision=318989
* add a comment on vendor index 19 and 20 to avoid confusionBaptiste Daroussin2017-05-271-0/+2
| | | | | | | Suggested by: tsoome Notes: svn path=/head/; revision=318986
* Pass a "FREEBSD" user-class in PXE dhcp requestBaptiste Daroussin2017-05-271-10/+14
| | | | | | | | | | | | | | | | | | rfc3004 allows to pass multiple user classes on dhcp requests this is used by dhcp servers to differentiate the caller if needed. As an example with isc dhcp server it will be possible to make options only for the FreeBSD loaders: if exists user-class and option user-class = "FREEBSD" { option root-path "tftp://192.168.42.1/FreeBSD; } Reviewed by: tsoome Differential Revision: https://reviews.freebsd.org/D10951 Notes: svn path=/head/; revision=318982
* loader: network read reworkToomas Soome2017-05-061-39/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current read from network is working from up to down - we have some protocol needing the data from the network, so we build the buffer space for that protocol, add the extra space for headers and pass this buffer down to be filled by nif get call in hope, we have guessed the incoming packet size right. Amazingly enough this approach mostly does work, but not always... So, this update does work from down to up - we allocate buffer (based on MTU or frame size info), fill it up, and pass on for upper layers. The obvious problem is that when we should free the buffer - if at all. In the current implementation the upper layer will free the packet on error or when the packet is no longer needed. While working on the issue, the additional issue did pop up - the bios implementation does not have generic get/put interface but is using pxe udpsend/udpreceive instead. So the udp calls are gone and undi interface is implemented instead. Which in turn means slight other changes as we do not need to have duplicated pxe implementation and can just use dev_net. To align packet content, the actual read from nic is using shifted buffer by ETHER_ALIGN (2). Reviewed by: bapt Differential Revision: https://reviews.freebsd.org/D10232 Notes: svn path=/head/; revision=317887
* distinguish NFS versus TFTP boot by rootpathBaptiste Daroussin2017-05-061-13/+8
| | | | | | | | | | | | | | | | | Don't use DHCP 150 option to decide which protocol use to netboot. When root-path includes ip address - go thru NFS, if ip address not exists in root-path - go thru TFTP from server which ip address is in next-server. But there is one limitation - only one tftp server in network to provide loader and everything else. Does enybody use more than only one? Submitted by: kczekirda Sponsored by: Oktawave MFC after: 3 weeks Relnote: Yes Differential Revision: https://reviews.freebsd.org/D8740 Notes: svn path=/head/; revision=317886
* loader: verify the value from dhcp.interface-mtu and use snprintf to set mtuToomas Soome2017-03-201-3/+22
| | | | | | | | | | | | | | | Since the uset can set dhcp.interface-mtu, we need to try to validate the value. So we verify if the conversion to int is successful and we will not allow to set value greater than max IPv4 packet size. Also use snprintf for safety. Reviewed by: allanjude, bapt Approved by: allanjude (mentor) Differential Revision: https://reviews.freebsd.org/D8492 Notes: svn path=/head/; revision=315653
* Try to extract the RFC1048 data from PXE. If we get enough info we can skipMariusz Zaborski2017-03-091-0/+11
| | | | | | | | | | | | | | the bootp(). It removes unnecessary DHCP request from pxeloader. Submitted by: kczekirda Sponsored by: Oktawave Initiated by: Matthew Dillon Reviewed by: smh, gnn, bapt, oshogbo MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D9847 Notes: svn path=/head/; revision=314948
* Renumber copyright clause 4Warner Losh2017-02-281-1/+1
| | | | | | | | | | | | Renumber cluase 4 to 3, per what everybody else did when BSD granted them permission to remove clause 3. My insistance on keeping the same numbering for legal reasons is too pedantic, so give up on that point. Submitted by: Jan Schaumann <jschauma@stevens.edu> Pull Request: https://github.com/freebsd/freebsd/pull/96 Notes: svn path=/head/; revision=314436
* remove network mask calculation for Classful networkBaptiste Daroussin2017-01-071-23/+10
| | | | | | | | | | | | | Nowadays it's not necessary to compute network mask from the IP address and compare to given by DHCP. Submitted by: kczekirda Reviewed by: glebius, bapt MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D8740 Notes: svn path=/head/; revision=311659
* When issuing a PXE dhcp request, always issue a param request (DHCP option 55)Baptiste Daroussin2016-10-311-1/+11
| | | | | | | | | | | | | | | with all dhcp parameters we might be interested in. Some DHCP server like the new kea (by ISC) expect it. This makes pxeboot functional with ISC kea. Submitted by: Vincent Legout <vincent.legout@gandi.net> MFC after: 1 month Sponsored by: Gandi.net Notes: svn path=/head/; revision=308129
* Netboot: allow both tftpfs and nfs in both pxeboot and loader.efiBaptiste Daroussin2016-08-311-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a new 'netproto' variable which can be set for now to NET_TFTP or NET_NFS (default to NET_NONE) From the dhcp options if one sets the root-path option to: "ip:path", the loader will consider it is booting over NFS (meaning same behaviour as the default current behaviour) if the dhcp option "tftp server address" is set (option 150) the loader will consider it is booting over tftpfs, it will then consider the root-path options with 2 possible case 1. "path" then the IP of the tftp server will be the one passed by the option 150, and the files will be retrieved under "path" on the tftp server 2. "ip:path" then the IP of the tftp server will be the one passed in the option "overwritting the IP from the option 150. We could not "abuse" the rootpath option in the form or tftp://ip:path because this is already used for other purpose by iPXE preventing any chainload from iPXE to the FreeBSD loader. Given at each open(), the loader loops over all available filesystems and keep the "best" error, we needed to prevent tftpfs to fallback on nfs and vice versa. the tftpfs and nfs implementation in libstand now return EINVAL early if 'netproto' for that purpose. Reviewed by: tsoome Relnotes: yes Sponsored by: Gandi.net Differential Revision: https://reviews.freebsd.org/D7628 Notes: svn path=/head/; revision=305125
* If the dhcp server delivers an interface-mtu option, parse it and storeIan Lepore2016-03-211-0/+8
| | | | | | | | | | | the value in a new global intf_mtu for use by the application. These changes were inspired by the patch provided by Robert Blayzor in PR 187094, and will allow loader(8) to propagate the value to the kernel along with the other nfs_diskless parms delivered via environment vars. Notes: svn path=/head/; revision=297150
* Allow dhcp/bootp server-provided values to be overriden from environmentIan Lepore2015-12-221-6/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | variables in loader(8) and other libstand applications. Sometimes a dhcp server provides incorrect information along with the IP address. It would be useful to have a way to override this with locally-supplied information, such as command line parameters passed from a prior-stage bootloader. This change allows pre-existing env vars to take precedence over values delivered by the dhcp or bootp server. The bootp/dhcp code in libstand automatically creates environment variables from the data provided by the server (dhcp.root-path, dhcp.domain-name, etc). It also transcribes the values to some global variables such as 'rootpath' and 'hostname'. This change does two things: When adding dhcp.* vars to the environment, don't replace existing vars/values. When setting the global vars rootpath and hostname, use the dhcp.root-path and dhcp.host-name env var values if they exist. This allows the platform-specific part of loader(8) to obtain override values in some platform-specific way and store them in the environment before opening the network device. The set of values that can be overriden is currently limited to just string options. The values that are delivered as binary data are things that probably shouldn't be overridden (IP, netmask, gateway, etc). The original patch this evolved from was submitted by martymac@ PR: 202098 Differential Revision: https://reviews.freebsd.org/D4559 Notes: svn path=/head/; revision=292583
* Replace index() and rindex() calls with strchr() and strrchr().Ed Schouten2012-01-031-3/+3
| | | | | | | | | | | | | The index() and rindex() functions were marked LEGACY in the 2001 revision of POSIX and were subsequently removed from the 2008 revision. The strchr() and strrchr() functions are part of the C standard. This makes the source code a lot more consistent, as most of these C files also call into other str*() routines. In fact, about a dozen already perform strchr() calls. Notes: svn path=/head/; revision=229403
* Fix minor issues in libstand.Ed Schouten2009-05-311-1/+1
| | | | | | | | | | - Don't call tftp_makereq() with too many arguments. - Don't forget to close one of the comments. Submitted by: Pawel Worach Notes: svn path=/head/; revision=193189
* put a prefix on dhcp options to avoid clobbering, even by mistake,Luigi Rizzo2009-01-051-1/+1
| | | | | | | | | existing environment variables. MFC after: 2 weeks Notes: svn path=/head/; revision=186799
* Some libstand/bootp.c extension (written by Danny Braniss, slightlyLuigi Rizzo2008-12-051-0/+328
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | revised/modified by me) to store dhcp options into kenv variables, so the information is available to the boot loader and can be used to customize the boot process. The change is totally unintrusive, essentially made of a single function to be called while parsing a dhcp response, and a couple of tables to classify options. The values extracted from dhcp options are stored in the kenv environment in one of these forms: + options whose name and type is known are saved as dhcp.name = value (string, or number/ip addresses lists) + unknown options are assumed to be strings and saved as dhcp.option-NNN = "value" + options listed as '__INDIR' and sent on the wire as e.g. option unknown-252 "some.name=the actual value" are saved as some.name = "the actual value" + options listed as '__ILIST' and sent on the wire as e.g. option unknown-249 "a.b=foo bar; c.d= 123; e.f=done" are saved as multiple values a.b="foo bar" c.d="123" e.f="done" As you can see there is quite a bit of flexibility on what can be passed to the loader or the kernel. For the time being the vendor-specific table is mostly disabled, because there is no standard set of options for FreeBSD, and I don't know all the pxe-specific vendor options. Also, applications using libstand may live in memory-constrained environments, so it makes sense to keep these tables as small as possible, especially considering that one can generate arbitrary name=value pairs using site-specific options of type __INDIR or __ILIST (there are 4 __ILIST and 5 __INDIR in the table, numbered 246..249 and 250..254). Actually, considering that probably 75% of the standard dhcp options are totally useless, it might make sense to remove them as well. Submitted by: Danny Braniss MFC after: 4 weeks Notes: svn path=/head/; revision=185643
* Remove California Regent's clause 3, per letterWarner Losh2007-01-091-4/+0
| | | | Notes: svn path=/head/; revision=165906
* Remove 'register' keyword.David E. O'Brien2002-03-211-15/+15
| | | | Notes: svn path=/head/; revision=92913
* Add __FBSDID()s to libstandMatthew Dillon2001-09-301-1/+3
| | | | Notes: svn path=/head/; revision=84221
* IN_CLASS*() macros assume host order and s_addr is network bytePaul Saab2000-09-201-2/+2
| | | | | | | order, so we must convert them to host order. Notes: svn path=/head/; revision=66134
* Add support to send the string 'PXEClient' as the Vendor classPaul Saab2000-08-111-3/+23
| | | | | | | | | identifier to the DHCP server. Now you can check for this string in your dhcp configuration to decide whether you will hand out a lease to the client or not. Notes: svn path=/head/; revision=64527
* This is libstand; a support library for standalone executables (eg. bootstrapMike Smith1998-08-201-0/+396
modules). Obtained from: NetBSD, with some architectural changes and many additions. Notes: svn path=/cvs2svn/branches/MSMITH/; revision=38451