85 udp =
zalloc (
sizeof ( *udp ) );
88 DBGC ( udp,
"UDP %p allocated\n", udp );
101 DBGC ( udp,
"UDP %p could not bind: %s\n",
106 DBGC ( udp,
"UDP %p bound to port %d\n",
163 DBGC ( udp,
"UDP %p closed\n", udp );
197 udphdr =
iob_push ( iobuf,
sizeof ( *udphdr ) );
200 udphdr->
src =
src->st_port;
206 DBGC2 ( udp,
"UDP %p TX %d->%d len %d\n", udp,
212 &udphdr->
chksum ) ) != 0 ) {
213 DBGC ( udp,
"UDP %p could not transmit packet: %s\n",
237 sizeof ( udp->
local.
pad ) ) == 0 ) ||
239 sizeof ( udp->
local.
pad ) ) == 0 ) ) ) {
268 if (
iob_len ( iobuf ) <
sizeof ( *udphdr ) ) {
269 DBG (
"UDP packet too short at %zd bytes (min %zd bytes)\n",
270 iob_len ( iobuf ),
sizeof ( *udphdr ) );
276 if ( ulen <
sizeof ( *udphdr ) ) {
277 DBG (
"UDP length too short at %zd bytes " 278 "(header is %zd bytes)\n", ulen,
sizeof ( *udphdr ) );
282 if ( ulen >
iob_len ( iobuf ) ) {
283 DBG (
"UDP length too long at %zd bytes (packet is %zd " 284 "bytes)\n", ulen,
iob_len ( iobuf ) );
291 DBG (
"UDP checksum incorrect (is %04x including " 292 "checksum field, should be 0000)\n", csum );
303 iob_pull ( iobuf,
sizeof ( *udphdr ) );
306 DBGC2 ( udp,
"UDP %p RX %d<-%d len %zd\n", udp,
311 DBG (
"No UDP connection listening on port %d\n",
355 DBGC ( udp,
"UDP %p cannot allocate buffer of length %zd\n",
#define iob_pull(iobuf, len)
#define EINVAL
Invalid argument.
An object interface operation.
#define TCPIP_NEGATIVE_ZERO_CSUM
Negative zero checksum value.
struct interface xfer
Data transfer interface.
struct arbelprm_rc_send_wqe rc
void intf_close(struct interface *intf, int rc)
Close an object interface.
void intf_shutdown(struct interface *intf, int rc)
Shut down an object interface.
char pad[sizeof(struct sockaddr) -(sizeof(sa_family_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t))]
Padding.
static void udp_close(struct udp_connection *udp, int rc)
Close a UDP connection.
static int udp_port_available(int port)
Check if local UDP port is available.
#define list_add(new, head)
Add a new entry to the head of a list.
#define ref_init(refcnt, free)
Initialise a reference counter.
#define iob_push(iobuf, len)
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
sa_family_t st_family
Socket address family (part of struct sockaddr)
#define EADDRINUSE
Address already in use.
static struct interface_descriptor udp_xfer_desc
UDP data transfer interface descriptor.
void intf_plug_plug(struct interface *a, struct interface *b)
Plug two object interfaces together.
struct io_buffer * xfer_alloc_iob(struct interface *intf, size_t len)
Allocate I/O buffer.
struct refcnt refcnt
Reference counter.
Uniform Resource Identifiers.
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
int semantics
Communication semantics (e.g.
static LIST_HEAD(udp_conns)
List of registered UDP connections.
struct list_head list
List of UDP connections.
int tcpip_bind(struct sockaddr_tcpip *st_local, int(*available)(int port))
Bind to local TCP/IP port.
A doubly-linked list entry (or list head)
Data transfer interfaces.
#define list_del(list)
Delete an entry from a list.
#define ENOMEM
Not enough space.
#define iob_disown(iobuf)
Disown an I/O buffer.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define MAX_LL_NET_HEADER_LEN
Maximum combined length of a link-layer and network-layer header.
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
#define __unused
Declare a variable or data structure as unused.
struct tcpip_protocol udp_protocol __tcpip_protocol
ICMPv4 TCP/IP protocol.
static struct net_device * netdev
const char * scheme
URI protocol name.
Transport-network layer interface.
static int udp_rx(struct io_buffer *iobuf, struct net_device *netdev __unused, struct sockaddr_tcpip *st_src, struct sockaddr_tcpip *st_dest, uint16_t pshdr_csum)
Process a received packet.
static struct interface_operation udp_xfer_operations[]
UDP data transfer interface operations.
int udp_open_promisc(struct interface *xfer)
Open a promiscuous UDP connection.
#define ENOTCONN
The socket is not connected.
uint16_t st_port
TCP/IP port.
const char * name
Protocol name.
Generalized socket address structure.
An object interface descriptor.
#define iob_unput(iobuf, len)
char * strerror(int errno)
Retrieve string representation of error number.
void * zalloc(size_t size)
Allocate cleared memory.
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
#define INTF_OP(op_type, object_type, op_func)
Define an object interface operation.
static struct udp_connection * udp_demux(struct sockaddr_tcpip *local)
Identify UDP connection by local address.
int xfer_deliver(struct interface *intf, struct io_buffer *iobuf, struct xfer_metadata *meta)
Deliver datagram.
Data transfer interface opening.
const char * host
Host name.
static int udp_tx(struct udp_connection *udp, struct io_buffer *iobuf, struct sockaddr_tcpip *src, struct sockaddr_tcpip *dest, struct net_device *netdev)
Transmit data via a UDP connection to a specified address.
int udp_sock_dgram
Linkage hack.
static int udp_xfer_deliver(struct udp_connection *udp, struct io_buffer *iobuf, struct xfer_metadata *meta)
Deliver datagram as I/O buffer.
A transport-layer protocol of the TCP/IP stack (eg.
Network device management.
#define iob_reserve(iobuf, len)
#define INTF_DESC(object_type, intf, operations)
Define an object interface descriptor.
struct socket_opener udp_socket_opener __socket_opener
UDP socket opener.
int udp_open(struct interface *xfer, struct sockaddr *peer, struct sockaddr *local)
Open a UDP connection.
struct sockaddr_tcpip local
Local socket address.
void * data
Start of data.
static int udp_open_common(struct interface *xfer, struct sockaddr *peer, struct sockaddr *local, int promisc)
Open a UDP connection.
unsigned int uri_port(const struct uri *uri, unsigned int default_port)
Get port from URI.
if(len >=6 *4) __asm__ __volatile__("movsl" if(len >=5 *4) __asm__ __volatile__("movsl" if(len >=4 *4) __asm__ __volatile__("movsl" if(len >=3 *4) __asm__ __volatile__("movsl" if(len >=2 *4) __asm__ __volatile__("movsl" if(len >=1 *4) __asm__ __volatile__("movsl" if((len % 4) >=2) __asm__ __volatile__("movsw" if((len % 2) >=1) __asm__ __volatile__("movsb" return dest
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
struct sockaddr_tcpip peer
Remote socket address.
A Uniform Resource Identifier.
struct mschapv2_challenge peer
Peer challenge.
#define DBG(...)
Print a debugging message.
static void intf_init(struct interface *intf, struct interface_descriptor *desc, struct refcnt *refcnt)
Initialise an object interface.
int tcpip_tx(struct io_buffer *iobuf, struct tcpip_protocol *tcpip_protocol, struct sockaddr_tcpip *st_src, struct sockaddr_tcpip *st_dest, struct net_device *netdev, uint16_t *trans_csum)
Transmit a TCP/IP packet.
int iob_ensure_headroom(struct io_buffer *iobuf, size_t len)
Ensure I/O buffer has sufficient headroom.
uint16_t tcpip_chksum(const void *data, size_t len)
Calculate TCP/IP checkum.
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
#define NULL
NULL pointer (VOID *)
struct bofm_section_header done
uint16_t tcpip_continue_chksum(uint16_t partial, const void *data, size_t len)
Calculate continued TCP/IP checkum.
int xfer_open_named_socket(struct interface *xfer, int semantics, struct sockaddr *peer, const char *name, struct sockaddr *local)
Open named socket.
struct uri_opener udp_uri_opener __uri_opener
UDP URI opener.
#define ref_put(refcnt)
Drop reference to object.
static struct io_buffer * udp_xfer_alloc_iob(struct udp_connection *udp, size_t len)
Allocate I/O buffer for UDP.
static int udp_open_uri(struct interface *xfer, struct uri *uri)
Open UDP URI.
void * memset(void *dest, int character, size_t len) __nonnull