summaryrefslogtreecommitdiffstats
path: root/src/net/udp.c
Commit message (Collapse)AuthorAgeFilesLines
* [tcpip] Avoid generating positive zero for transmitted UDP checksumsMichael Brown2015-09-101-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TCP/IP checksum fields are one's complement values and therefore have two possible representations of zero: positive zero (0x0000) and negative zero (0xffff). In RFC768, UDP over IPv4 exploits this redundancy to repurpose the positive representation of zero (0x0000) to mean "no checksum calculated"; checksums are optional for UDP over IPv4. In RFC2460, checksums are made mandatory for UDP over IPv4. The wording of the RFC is such that the UDP header is mandated to use only the negative representation of zero (0xffff), rather than simply requiring the checksum to be correct but allowing for either representation of zero to be used. In RFC1071, an example algorithm is given for calculating the TCP/IP checksum. This algorithm happens to produce only the positive representation of zero (0x0000); this is an artifact of the way that unsigned arithmetic is used to calculate a signed one's complement sum (and its final negation). A common misconception has developed (exemplified in RFC1624) that this artifact is part of the specification. Many people have assumed that the checksum field should never contain the negative representation of zero (0xffff). A sensible receiver will calculate the checksum over the whole packet and verify that the result is zero (in whichever representation of zero happens to be generated by the receiver's algorithm). Such a receiver will not care which representation of zero happens to be used in the checksum field. However, there are receivers in existence which will verify the received checksum the hard way: by calculating the checksum over the remainder of the packet and comparing the result against the checksum field. If the representation of zero used by the receiver's algorithm does not match the representation of zero used by the transmitter (and so placed in the checksum field), and if the receiver does not explicitly allow for both representations to compare as equal, then the receiver may reject packets with a valid checksum. For UDP, the combined RFCs effectively mandate that we should generate only the negative representation of zero in the checksum field. For IP, TCP and ICMP, the RFCs do not mandate which representation of zero should be used, but the misconceptions which have grown up around RFC1071 and RFC1624 suggest that it would be least surprising to generate only the positive representation of zero in the checksum field. Fix by ensuring that all of our checksum algorithms generate only the positive representation of zero, and explicitly inverting this in the case of transmitted UDP packets. Reported-by: Wissam Shoukair <wissams@mellanox.com> Tested-by: Wissam Shoukair <wissams@mellanox.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [legal] Relicense files under GPL2_OR_LATER_OR_UBDLMichael Brown2015-03-021-1/+1
| | | | | | | | | | These files cannot be automatically relicensed by util/relicense.pl since they either contain unusual but trivial contributions (such as the addition of __nonnull function attributes), or contain lines dating back to the initial git revision (and so require manual knowledge of the code's origin). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [udp] Add AF_INET6 socket openerMichael Brown2013-10-211-2/+9
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [tcpip] Pass through network device to transport layer protocolsMichael Brown2013-09-031-1/+4
| | | | | | | NDP requires knowledge of the network device on which a packet was received. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [tcpip] Allow binding to unspecified privileged ports (below 1024)Michael Brown2013-08-061-35/+18Star
| | | | | Originally-implemented-by: Marin Hannache <git@mareo.fr> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [udp] Move high-frequency debug messages to DBGLVL_EXTRAMichael Brown2013-08-061-5/+5
| | | | | | | | This makes it possible to leave UDP debugging enabled in order to see interesting UDP events, without flooding the console with at least one message per packet. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [udp] Propagate transmission errors to UDP interface usersMichael Brown2012-02-201-4/+3Star
| | | | | Suggested-by: Simon Rowe <simon.rowe@eu.citrix.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [udp] Use MAX_LL_NET_HEADER_LEN instead of defining our own UDP_MAX_HLENMichael Brown2010-11-191-3/+5
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Fix misaligned table entries when using gcc 4.5Piotr Jaroszyński2010-08-201-1/+1
| | | | | | | | | | Declarations without the accompanying __table_entry cause misalignment of the table entries when using gcc 4.5. Fix by adding the appropriate __table_entry macro or (where possible) by removing unnecessary forward declarations. Signed-off-by: Piotr Jaroszyński <p.jaroszynski@gmail.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [interface] Convert all data-xfer interfaces to generic interfacesMichael Brown2010-06-221-43/+25Star
| | | | | | | | | | | | | | Remove data-xfer as an interface type, and replace data-xfer interfaces with generic interfaces supporting the data-xfer methods. Filter interfaces (as used by the TLS layer) are handled using the generic pass-through interface capability. A side-effect of this is that deliver_raw() no longer exists as a data-xfer method. (In practice this doesn't lose any efficiency, since there are no instances within the current codebase where xfer_deliver_raw() is used to pass data to an interface supporting the deliver_raw() method.) Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [refcnt] Add ref_init() wrapper functionMichael Brown2010-06-221-0/+1
| | | | | | | Standardise on using ref_init() to initialise an embedded reference count, to match the coding style used by other embedded objects. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Rename gPXE to iPXEMichael Brown2010-04-201-6/+6
| | | | | | | | | | | Access to the gpxe.org and etherboot.org domains and associated resources has been revoked by the registrant of the domain. Work around this problem by renaming project from gPXE to iPXE, and updating URLs to match. Also update README, LOG and COPYRIGHTS to remove obsolete information. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [legal] Add a selection of FILE_LICENCE declarationsMichael Brown2009-05-181-0/+2
| | | | | Add FILE_LICENCE declarations to almost all files that make up the various standard builds of gPXE.
* [build] Enable building with the Intel C compiler (icc)Michael Brown2009-03-261-1/+1
|
* [xfer] Make consistent assumptions that xfer metadata can never be NULLMichael Brown2009-02-151-12/+3Star
| | | | | | | | | | | | | The documentation in xfer.h and xfer.c does not say that the metadata parameter is optional in calls such as xfer_deliver_iob_meta() and the deliver_iob() method. However, some code in net/ is prepared to accept a NULL pointer, and xfer_deliver_as_iob() passes a NULL pointer directly to the deliver_iob() method. Fix this mess of conflicting assumptions by making everything assume that the metadata parameter is mandatory, and fixing xfer_deliver_as_iob() to pass in a dummy metadata structure (as is already done in xfer_deliver_iob()).
* [iobuf] Add iob_disown() and use it where it simplifies codeMichael Brown2009-02-011-2/+1Star
| | | | | | | | | | | | | | | | | | | | | | | | | There are many functions that take ownership of the I/O buffer they are passed as a parameter. The caller should not retain a pointer to the I/O buffer. Use iob_disown() to automatically nullify the caller's pointer, e.g.: xfer_deliver_iob ( xfer, iob_disown ( iobuf ) ); This will ensure that iobuf is set to NULL for any code after the call to xfer_deliver_iob(). iob_disown() is currently used only in places where it simplifies the code, by avoiding an extra line explicitly setting the I/O buffer pointer to NULL. It should ideally be used with each call to any function that takes ownership of an I/O buffer. (The SSA optimisations will ensure that use of iob_disown() gets optimised away in cases where the caller makes no further use of the I/O buffer pointer anyway.) If gcc ever introduces an __attribute__((free)), indicating that use of a function argument after a function call should generate a warning, then we should use this to identify all applicable function call sites, and add iob_disown() as necessary.
* [tcpip] Allow for transmission to multicast IPv4 addressesMichael Brown2009-01-211-11/+8Star
| | | | | | | | | | | When sending to a multicast address, it may be necessary to specify the source address explicitly, since the multicast destination address does not provide enough information to deduce the source address via the miniroute table. Allow the source address specified via the data-xfer metadata to be passed down through the TCP/IP stack to the IPv4 layer, which can use it as a default source address.
* [x86_64] Fix assorted 64-bit compilation errors and warningsMichael Brown2008-11-191-2/+3
| | | | | | Remove various 32-bit assumptions scattered throughout the codebase. The code is still not necessarily 64-bit clean, but will at least compile.
* [udp] Avoid reusing auto-allocated ports after connection close.Michael Brown2008-07-101-2/+3
| | | | | This duplicates a fix made to tcp.c in commit d5735c631cf26d8e1bcf7b5e635623b52d6b48aa.
* [udp] Verify local socket address (if specified) for UDP socketsMichael Brown2008-06-101-22/+29
| | | | | | UDP sockets can be used for multicast, at which point it becomes plausible that we could receive packets that aren't destined for us but that still match on a port number.
* Make seek information part of the xfer metadata, rather than an entirelyMichael Brown2008-01-081-1/+0Star
| | | | | | | separate xfer method. Add missing .alloc_iob entries to several xfer_interface_operations structures.
* Various warnings fixups for OpenBSD with gcc-3.3.5.Michael Brown2007-12-071-7/+7
|
* udp_open_promisc() calls udp_open_common() with peer==NULL.Michael Brown2007-11-281-2/+3
|
* Separate the "is data ready" function of xfer_seek() into anMichael Brown2007-07-081-0/+1
| | | | | xfer_window() function, which can return a scalar rather than a boolean.
* Kill off unused request() method in data-xfer interface.Michael Brown2007-07-081-1/+0Star
|
* convert to zallocHolger Lubitz2007-07-061-2/+1Star
|
* Mildly ugly hack to force correct linkage.Michael Brown2007-06-281-0/+2
|
* Update DHCP to use data-xfer interface (not yet tested).Michael Brown2007-06-281-5/+6
|
* Kill off hotplug.h and just make net devices normal reference-countedMichael Brown2007-06-271-1/+1
| | | | | | structures. DHCP still broken and #if 0'd out.
* Partial migration of UDP to data-xfer interface. (Will not link atMichael Brown2007-06-201-166/+291
| | | | present; DHCP is broken).
* pkbuff->iobuf changeoverMichael Brown2007-05-191-42/+42
| | | | | | | | Achieved via Perl using: perl -pi -e 's/pk_buff/io_buffer/g; s/Packet buffer/I\/O buffer/ig; ' \ -e 's/pkbuff\.h/iobuf.h/g; s/pkb_/iob_/g; s/_pkb/_iob/g; ' \ -e 's/pkb/iobuf/g; s/PKB/IOB/g;'
* hoffmeis: Fixing situation where absence of a newdata() handler for UDPAnselm Martin Hoffmeister2007-04-091-5/+10
| | | | | connections might break things. Only-sending applications like syslog() do not need a newdata() handler, so added a check if that handler exists.
* When a network device is specified to tcpip_tx() or it's children, treatMichael Brown2007-01-161-1/+1
| | | | | | | it as a fallback network device rather than an explicitly forced network device. Clear routing table entries before re-attempting DHCP.
* Improve debug messagesMichael Brown2007-01-161-2/+21
|
* Allow udp_{send,sendto,sendto_via} to be called outside of theMichael Brown2007-01-101-32/+39
| | | | | udp_senddata() callback. This will simplify any UDP protocols that don't need the temporary buffer.
* Add udp_sendto_via() to allow e.g. DHCP to transmit without first havingMichael Brown2007-01-101-3/+25
| | | | to set up dummy routing entries.
* Allow an explicit network device to be specified for IP-layerMichael Brown2007-01-101-1/+1
| | | | transmissions.
* Rename pkb_available() to pkb_tailroom() for consistency with Linux'sMichael Brown2007-01-091-3/+3
| | | | skb_tailroom(). Add pkb_headroom().
* Allow empty checksums on received packetsMichael Brown2007-01-041-6/+8
|
* Improve consistency between TCP and UDP RX datapathsMichael Brown2007-01-031-46/+56
|
* Verify checksums on the RX datapath.Michael Brown2007-01-031-10/+8Star
| | | | Simplify checksum generation on the TX datapath.
* We don't actually have a stdio.h header file. Our printf() functions areMichael Brown2006-09-271-1/+0Star
| | | | | | | | defined in vsprintf.h. (This may change, since vsprintf.h is a non-standard name, but for now it's the one to use.) There should be no need to include vsprintf.h just for DBG() statements, since include/compiler.h forces it in for a debug build anyway.
* added stdio.h to includes for DBG compilationMarty Connor2006-09-271-0/+1
|
* Remove _PROTOCOL macros for gcc 3.2 compatibilityMarty Connor2006-08-091-3/+1Star
|
* Clarified packet ownership transfer between a few functions.Michael Brown2006-08-091-16/+37
| | | | | | | | | | | | | Added a large number of missing calls to free_pkb(). In the case of UDP, no received packets were ever freed, which lead to memory exhaustion remarkably quickly once pxelinux started up. In general, any function with _rx() in its name which accepts a pk_buff *must* either call free_pkb() or pass the pkb to another _rx() function (e.g. the next layer up the stack). Since the UDP (and TCP) layers don't pass packet buffers up to the higher-layer protocols (the "applications"), they must free the packet buffer after calling the application's newdata() method.
* Convert some trivial functions to static inlines.Michael Brown2006-08-041-28/+0Star
|
* Make the UDP senddata() methods return a status code.Michael Brown2006-08-041-23/+2Star
| | | | | | udp_connect() now follows the standard BSD sockets semantics and simply sets the default address for outgoing packets; it doesn't filter incoming packets.
* Updated PXE UDP implementation to use the new Etherboot UDP API.Michael Brown2006-08-031-0/+12
| | | | | | | Updated PXE API dispatcher to use copy_{to,from}_user, and moved to arch/i386 since the implementation is quite architecture-dependent. (The individual PXE API calls can be largely architecture-independent.)
* Added features that will be required for PXE UDP support.Michael Brown2006-08-021-140/+161
| | | | | | | Introduced struct sockaddr_tcpip, to simplify code that deals with both IPv4 and IPv6 addresses. Reorganised parts of tcpip.c and udp.c.
* Renamed trans_{rx,tx}() to tcpip_{rx,tx}(), since they are specific toMichael Brown2006-08-011-1/+1
| | | | | the TCP/IP protocol suite (rather than being general transport-layer functions).