Retro Rocket Kernel
BASIC-Powered Operating System
udp.h File Reference
#include "kernel.h"

Data Structures

struct  udp_packet
 Raw structure for UDP. More...
 

Typedefs

typedef void(* udp_daemon_handler) (uint16_t, void *, uint32_t)
 

Functions

struct udp_packet __attribute__ ((packed)) udp_packet_t
 Raw structure for UDP. More...
 
uint16_t udp_calculate_checksum (udp_packet_t *packet)
 This returns 0 for all checksums as it is optional in ipv4. More...
 
void udp_send_packet (uint8_t *dst_ip, uint16_t src_port, uint16_t dst_port, void *data, uint16_t len)
 Send a UDP packet via the ethernet driver. More...
 
void udp_handle_packet ([[maybe_unused]] ip_packet_t *encap_packet, udp_packet_t *packet, size_t len)
 Handle UDP packet from the IP driver. More...
 
uint16_t udp_register_daemon (uint16_t dst_port, udp_daemon_handler handler)
 Register a daemon function to listen on a udp dest port. More...
 

Variables

uint16_t src_port
 
uint16_t dst_port
 
uint16_t length
 
uint16_t checksum
 
uint8_t data []
 

Detailed Description

Author
Craig Edwards (craig.nosp@m.edwa.nosp@m.rds@b.nosp@m.rain.nosp@m.box.c.nosp@m.c)

Typedef Documentation

◆ udp_daemon_handler

typedef void(* udp_daemon_handler) (uint16_t, void *, uint32_t)

Function Documentation

◆ __attribute__()

struct udp_packet __attribute__ ( (packed)  )

Raw structure for UDP.

◆ udp_calculate_checksum()

uint16_t udp_calculate_checksum ( udp_packet_t *  packet)

This returns 0 for all checksums as it is optional in ipv4.

Parameters
packetpacket data
Returns
uint16_t checksum (always 0)

◆ udp_handle_packet()

void udp_handle_packet ( [[maybe_unused] ] ip_packet_t *  encap_packet,
udp_packet_t *  packet,
size_t  len 
)

Handle UDP packet from the IP driver.

Parameters
ipEncapsulating IP packet
packetraw UDP packet
lengthUDP packet length

◆ udp_register_daemon()

uint16_t udp_register_daemon ( uint16_t  dst_port,
udp_daemon_handler  handler 
)

Register a daemon function to listen on a udp dest port.

Parameters
dst_portdestination port to listen on. If 0 is passed, a random port above or equal to 1024 is allocated for use and will be returned as the return value.
handlerhandler for incoming packets
Returns
port number that was allocated

◆ udp_send_packet()

void udp_send_packet ( uint8_t *  dst_ip,
uint16_t  src_port,
uint16_t  dst_port,
void *  data,
uint16_t  len 
)

Send a UDP packet via the ethernet driver.

Parameters
dst_ipdestination IP address
src_portsource port number
dst_portdestination port number
dataraw packet data
lenraw packet length

Variable Documentation

◆ checksum

uint16_t checksum

◆ data

uint8_t data[]

◆ dst_port

uint16_t dst_port

◆ length

uint16_t length

◆ src_port

uint16_t src_port