SDK  23.9.2
For IoT System Software Development
Classes | Functions | Variables
UDP

UDP (User Datagram Protocol) More...

Classes

class  UDPDatagramListener
 UDP datagram listener. More...
 
class  UDP
 UDP. More...
 
struct  UDP::Header_t
 

Functions

virtual void UDPDatagramListener::handleDatagram (IPv6Interface &input, const IPv6Address *src_addr, const IPv6Address *dst_addr, uint16_t src_port, uint16_t dst_port, const uint8_t *msg, uint16_t len)=0
 수신된 UDP datagram을 처리합니다.
 
error_t UDP::sendto (IPv6Interface *output, const IPv6Address *src_addr, uint16_t src_port, const IPv6Address *dst_addr, uint16_t dst_port, const void *user_data, uint16_t len)
 
error_t UDP::listen (uint16_t port, void(*func)(IPv6Interface &input, const IPv6Address *src_addr, const IPv6Address *dst_addr, uint16_t src_port, uint16_t dst_port, const uint8_t *msg, uint16_t len))
 
error_t UDP::listen (uint16_t port, UDPDatagramListener *listener)
 UDP 포트를 열고, 수신되는 UDP datagram들을 객체로 전달합니다. More...
 
error_t UDP::stopListening (uint16_t port)
 UDP 포트를 닫습니다. More...
 
uint16_t UDP::getUnusedRandomPort ()
 Get a random port number that is not listening.
 
static void UDP::receive (IPv6Interface &input, IPv6PacketBuffer *head, IPv6PacketBuffer *ippkt, IPv6PacketBuffer *udppkt)
 

Variables

uint16_t UDP::Header_t::src_port
 
uint16_t UDP::Header_t::dst_port
 
uint16_t UDP::Header_t::length
 
uint16_t UDP::Header_t::checksum
 
UDP Udp
 

Detailed Description

UDP (User Datagram Protocol)

Function Documentation

◆ listen() [1/2]

error_t UDP::listen ( uint16_t  port,
UDPDatagramListener listener 
)

UDP 포트를 열고, 수신되는 UDP datagram들을 객체로 전달합니다.

Parameters
[in]portPort number
[in]listenerUDP datagram을 처리 가능한 객체의 포인터.

◆ listen() [2/2]

error_t UDP::listen ( uint16_t  port,
void(*)(IPv6Interface &input, const IPv6Address *src_addr, const IPv6Address *dst_addr, uint16_t src_port, uint16_t dst_port, const uint8_t *msg, uint16_t len)  func 
)

Open an UDP port to listen incoming UDP datagrams.

Parameters
[in]portPort number
[in]funcCallback function to be called on receipt of UDP datagrams
Returns
  • ERROR_SUCCESS: Opening the UDP port is successful.
  • ERROR_BUSY: There is already opened port with number of port. Or opening the port is denied by the system due to out of resource.
  • ERROR_NOT_ENOUGH_MEMORY: Opening the port is failed due to out of memory.
  • ERROR_INVALID_ARGS: func is NULL.

◆ sendto()

error_t UDP::sendto ( IPv6Interface output,
const IPv6Address src_addr,
uint16_t  src_port,
const IPv6Address dst_addr,
uint16_t  dst_port,
const void *  user_data,
uint16_t  len 
)

Send a user datagram.

Parameters
[in]out_infOutput interface ID (only for link-local send)
[in]src_addrSource IPv6 address. If it is NULL, most preferred address is selected.
[in]src_portSource port address.
[in]dst_addrDestination IPv6 address.
[in]dst_portDestination port address.
[in]bufThe User datagram to be sent.
[in]lenThe Length of buf.
Returns
An error code.

◆ stopListening()

error_t UDP::stopListening ( uint16_t  port)

UDP 포트를 닫습니다.

Parameters
[in]portPort number
Returns
  • ERROR_SUCCESS: 성공
  • ERROR_FAIL: port 가 현재 수신 대기 중이 아니므로 실패