Retro Rocket Kernel BASIC-Powered Operating System

Data Structures | Typedefs | Functions | Variables
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)

Copyright
  Copyright (c) 2012-2023

## 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

  packet | packet 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

  ip | Encapsulating IP packet
  packet | raw UDP packet
  length | UDP 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_port | destination 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.
  handler | handler 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_ip | destination IP address
  src_port | source port number
  dst_port | destination port number
  data | raw packet data
  len | raw 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