summaryrefslogtreecommitdiffstats
path: root/src/include/ipxe/tcpip.h
diff options
context:
space:
mode:
authorMichael Brown2013-08-06 16:56:54 +0200
committerMichael Brown2013-08-06 16:56:54 +0200
commit252d28f098bfd12df59fe147d7e8354be61a6da8 (patch)
tree234bc573f3c7a27730d04016c809dc6ae5ba8c24 /src/include/ipxe/tcpip.h
parent[ipv6] Rename sin_{family,port} to sin6_{family,port} in struct sockaddr_in6 (diff)
downloadipxe-252d28f098bfd12df59fe147d7e8354be61a6da8.tar.gz
ipxe-252d28f098bfd12df59fe147d7e8354be61a6da8.tar.xz
ipxe-252d28f098bfd12df59fe147d7e8354be61a6da8.zip
[tcpip] Allow binding to unspecified privileged ports (below 1024)
Originally-implemented-by: Marin Hannache <git@mareo.fr> Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include/ipxe/tcpip.h')
-rw-r--r--src/include/ipxe/tcpip.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/include/ipxe/tcpip.h b/src/include/ipxe/tcpip.h
index 34d7f88f..0cc688a9 100644
--- a/src/include/ipxe/tcpip.h
+++ b/src/include/ipxe/tcpip.h
@@ -24,6 +24,16 @@ struct net_device;
*/
#define TCPIP_EMPTY_CSUM 0xffff
+/** TCP/IP address flags */
+enum tcpip_st_flags {
+ /** Bind to a privileged port (less than 1024)
+ *
+ * This value is chosen as 1024 to optimise the calculations
+ * in tcpip_bind().
+ */
+ TCPIP_BIND_PRIVILEGED = 0x0400,
+};
+
/**
* TCP/IP socket address
*
@@ -33,6 +43,8 @@ struct net_device;
struct sockaddr_tcpip {
/** Socket address family (part of struct @c sockaddr) */
sa_family_t st_family;
+ /** Flags */
+ uint16_t st_flags;
/** TCP/IP port */
uint16_t st_port;
/** Padding
@@ -42,7 +54,9 @@ struct sockaddr_tcpip {
* family.
*/
char pad[ sizeof ( struct sockaddr ) -
- ( sizeof ( sa_family_t ) + sizeof ( uint16_t ) ) ];
+ ( sizeof ( sa_family_t ) /* st_family */ +
+ sizeof ( uint16_t ) /* st_flags */ +
+ sizeof ( uint16_t ) /* st_port */ ) ];
} __attribute__ (( may_alias ));
/**
@@ -125,6 +139,8 @@ extern int tcpip_tx ( struct io_buffer *iobuf, struct tcpip_protocol *tcpip,
extern uint16_t generic_tcpip_continue_chksum ( uint16_t partial,
const void *data, size_t len );
extern uint16_t tcpip_chksum ( const void *data, size_t len );
+extern int tcpip_bind ( struct sockaddr_tcpip *st_local,
+ int ( * available ) ( int port ) );
/* Use generic_tcpip_continue_chksum() if no architecture-specific
* version is available