UDP

Overview

Copyright (C) 2004-2022 OKTET Labs Ltd. More…

// typedefs

typedef struct udp4_datagram udp4_datagram;

typedef void (*udp4_callback)(
    const udp4_datagram *pkt,
    void *userdata
    );

// structs

struct udp4_datagram;

// global functions

te_errno tapi_udp_add_csap_layer(asn_value** csap_spec, int local_port, int remote_port);
te_errno tapi_udp_add_pdu(asn_value** tmpl_or_ptrn, asn_value** pdu, te_bool is_pattern, int src_port, int dst_port);
te_errno tapi_udp_ip4_eth_csap_create(const char* ta_name, int sid, const char* eth_dev, unsigned int receive_mode, const uint8_t* loc_mac, const uint8_t* rem_mac, in_addr_t loc_addr, in_addr_t rem_addr, int loc_port, int rem_port, csap_handle_t* udp_csap);
te_errno tapi_udp_ip4_csap_create(const char* ta_name, int sid, const char* ifname, in_addr_t loc_addr, in_addr_t rem_addr, int loc_port, int rem_port, csap_handle_t* udp_csap);
int ndn_udp4_dgram_to_plain(asn_value* pkt, struct udp4_datagram** udp_dgram);
tapi_tad_trrecv_cb_data* tapi_udp_ip4_eth_trrecv_cb_data(udp4_callback callback, void* user_data);
int tapi_udp_ip4_eth_recv_start(const char* ta_name, int sid, csap_handle_t csap, rcf_trrecv_mode mode);
te_errno tapi_udp_ip6_eth_csap_create(const char* ta_name, int sid, const char* eth_dev, unsigned int receive_mode, const uint8_t* loc_mac, const uint8_t* rem_mac, const uint8_t* loc_addr, const uint8_t* rem_addr, int loc_port, int rem_port, csap_handle_t* udp_csap);
te_errno tapi_udp_ip_eth_csap_create(const char* ta_name, int sid, const char* eth_dev, unsigned int receive_mode, const uint8_t* loc_mac, const uint8_t* rem_mac, int ip_family, const void* loc_addr, const void* rem_addr, int loc_port, int rem_port, csap_handle_t* udp_csap);

Detailed Documentation

Copyright (C) 2004-2022 OKTET Labs Ltd. All rights reserved.

Typedefs

typedef struct udp4_datagram udp4_datagram

Structure of UDP/IPv4 datagram

typedef void (*udp4_callback)(
    const udp4_datagram *pkt,
    void *userdata
    )

Callback function for the receiving UDP datagrams.

Parameters:

pkt

Received UDP datagram. After return from this callback memory block under this datagram will be freed.

userdata

Parameter, provided by the caller of tapi_snmp_walk().

Global Functions

te_errno tapi_udp_add_csap_layer(asn_value** csap_spec, int local_port, int remote_port)

Add UDP layer in CSAP specification.

Parameters:

csap_spec

Location of CSAP specification pointer.

local_port

Default local port in network byte order or -1 to keep unspecified

remote_port

Default remote port in network byte order or -1 to keep unspecified

Status

code.

te_errno tapi_udp_add_pdu(asn_value** tmpl_or_ptrn, asn_value** pdu, te_bool is_pattern, int src_port, int dst_port)

Add UDP PDU as the last PDU to the last unit of the traffic template or pattern.

Parameters:

tmpl_or_ptrn

Location of ASN.1 value with traffic template or pattern

pdu

Location for ASN.1 value pointer with added PDU

is_pattern

Is the first argument template or pattern

src_port

Source port in network byte order or -1. If -1, default value is specified during CSAP creation (as local port for sending, as remote port for receiving).

dst_addr

Destination port in network byte order or -1. If -1, default value is specified during CSAP creation (as remote port for sending, as local port for receiving).

Returns:

Status code.

te_errno tapi_udp_ip4_eth_csap_create(const char* ta_name, int sid, const char* eth_dev, unsigned int receive_mode, const uint8_t* loc_mac, const uint8_t* rem_mac, in_addr_t loc_addr, in_addr_t rem_addr, int loc_port, int rem_port, csap_handle_t* udp_csap)

Create ‘udp.ip4.eth’ CSAP on the specified Agent

Parameters:

ta_name

Test Agent name

sid

RCF SID

eth_dev

Name of Ethernet interface

receive_mode

Bitmask with receive mode, see ‘enum tad_eth_recv_mode’ in tad_common.h. Use TAD_ETH_RECV_DEF by default.

loc_mac

Local MAC address (or NULL)

rem_mac

Remote MAC address (or NULL)

loc_addr

Local IP address in network byte order (or NULL)

rem_addr

Remote IP address in network byte order (or NULL)

loc_port

Local UDP port in network byte order or -1

rem_port

Remote UDP port in network byte order or -1

udp_csap

Location for the CSAP handle (OUT)

Returns:

Zero on success or error code

te_errno tapi_udp_ip4_csap_create(const char* ta_name, int sid, const char* ifname, in_addr_t loc_addr, in_addr_t rem_addr, int loc_port, int rem_port, csap_handle_t* udp_csap)

Create ‘udp.ip4’ CSAP on the specified Agent

Parameters:

ta_name

Test Agent name

loc_addr

Local IP address in network byte order (or NULL)

rem_addr

Remote IP address in network byte order (or NULL)

loc_port

Local UDP port in network byte order or -1

rem_port

Remote UDP port in network byte order or -1

udp_csap

Location for the CSAP handle (OUT)

Returns:

Zero on success or error code

int ndn_udp4_dgram_to_plain(asn_value* pkt, struct udp4_datagram** udp_dgram)

Convert UDP.IPv4 datagram ASN.1 value to plain C structure.

Function allocates memory under dhcp_message data structure, which should be freed with dhcpv4_message_destroy

Parameters:

pkt

ASN.1 value of type Raw-Packet.

udp_dgram

converted structure (OUT).

Returns:

zero on success or error code.

tapi_tad_trrecv_cb_data* tapi_udp_ip4_eth_trrecv_cb_data(udp4_callback callback, void* user_data)

Prepare callback data to be passed in tapi_tad_trrecv_{wait,stop,get} to process received UDP packet.

Parameters:

callback

Callback for UDP packets handling

user_data

User-supplied data to be passed to callback

Returns:

Pointer to allocated callback data or NULL.

int tapi_udp_ip4_eth_recv_start(const char* ta_name, int sid, csap_handle_t csap, rcf_trrecv_mode mode)

Start receiving of UDP datagrams via ‘udp.ip4.eth’ CSAP, non-block method.

Parameters:

ta_name

Test Agent name

sid

RCF SID

csap

Identifier of CSAP

mode

Count received packets only or store packets to get to the test side later

Returns:

Zero on success or error code.

te_errno tapi_udp_ip6_eth_csap_create(const char* ta_name, int sid, const char* eth_dev, unsigned int receive_mode, const uint8_t* loc_mac, const uint8_t* rem_mac, const uint8_t* loc_addr, const uint8_t* rem_addr, int loc_port, int rem_port, csap_handle_t* udp_csap)

Create ‘udp.ip6.eth’ CSAP on the specified Agent

Parameters:

ta_name

Test Agent name

sid

RCF SID

eth_dev

Name of Ethernet interface

receive_mode

Bitmask with receive mode, see ‘enum tad_eth_recv_mode’ in tad_common.h. Use TAD_ETH_RECV_DEF by default.

loc_mac

Local MAC address (or NULL)

rem_mac

Remote MAC address (or NULL)

loc_addr

Local IP address in network byte order (or NULL)

rem_addr

Remote IP address in network byte order (or NULL)

loc_port

Local UDP port in network byte order or -1

rem_port

Remote UDP port in network byte order or -1

udp_csap

Location for the CSAP handle (OUT)

Returns:

Zero on success or error code

te_errno tapi_udp_ip_eth_csap_create(const char* ta_name, int sid, const char* eth_dev, unsigned int receive_mode, const uint8_t* loc_mac, const uint8_t* rem_mac, int ip_family, const void* loc_addr, const void* rem_addr, int loc_port, int rem_port, csap_handle_t* udp_csap)

Create UDP CSAP for IPv4 or IPv6 on Ethernet.

Parameters:

ta_name

Test Agent name

sid

RCF SID

eth_dev

Name of Ethernet interface

receive_mode

Bitmask with receive mode, see ‘enum tad_eth_recv_mode’ in tad_common.h

loc_mac

Local MAC address (or NULL)

rem_mac

Remote MAC address (or NULL)

ip_family

Address family

loc_addr

Local IP address in network byte order (or NULL)

rem_addr

Remote IP address in network byte order (or NULL)

loc_port

Local UDP port in network byte order or -1

rem_port

Remote UDP port in network byte order or -1

udp_csap

Location for the CSAP handle (OUT)

Returns:

Zero on success or error code