ARP

Overview

Declarations of test API for ARP TAD. More…

// typedefs

typedef struct tapi_arp_frame tapi_arp_frame_t;

typedef void (*tapi_arp_frame_callback)(
    const tapi_arp_frame_t *header,
    void *userdata
    );

// structs

struct tapi_arp_frame;

// global functions

te_errno tapi_arp_eth_csap_create(const char* ta_name, int sid, const char* device, unsigned int receive_mode, const uint8_t* remote_addr, const uint8_t* local_addr, const uint16_t* hw_type, const uint16_t* proto_type, const uint8_t* hw_size, const uint8_t* proto_size, csap_handle_t* arp_csap);
static te_errno tapi_arp_eth_csap_create_ip4(const char* ta_name, int sid, const char* device, unsigned int receive_mode, const uint8_t* remote_addr, const uint8_t* local_addr, csap_handle_t* arp_csap);
te_errno tapi_arp_add_csap_layer_eth(asn_value** csap_spec, const char* device, unsigned int receive_mode, const uint8_t* remote_addr, const uint8_t* local_addr);
te_errno tapi_arp_add_csap_layer(asn_value** csap_spec, const uint16_t* hw_type, const uint16_t* proto_type, const uint8_t* hw_size, const uint8_t* proto_size);
te_errno tapi_arp_add_csap_layer_eth_ip4(asn_value** csap_spec);
te_errno tapi_arp_add_pdu(asn_value** tmpl_or_ptrn, bool is_pattern, const uint16_t* hw_type, const uint16_t* proto_type, const uint8_t* hw_size, const uint8_t* proto_size, const uint16_t* opcode, size_t hw_addr_len, size_t proto_addr_len, const uint8_t* snd_hw_addr, const uint8_t* snd_proto_addr, const uint8_t* tgt_hw_addr, const uint8_t* tgt_proto_addr);
te_errno tapi_arp_add_pdu_eth_ip4(asn_value** tmpl_or_ptrn, bool is_pattern, const uint16_t* opcode, const uint8_t* snd_hw_addr, const uint8_t* snd_proto_addr, const uint8_t* tgt_hw_addr, const uint8_t* tgt_proto_addr);
te_errno tapi_arp_prepare_template(const tapi_arp_frame_t* frame, asn_value** templ);
tapi_tad_trrecv_cb_data* tapi_arp_trrecv_cb_data(tapi_arp_frame_callback callback, void* user_data);
te_errno tapi_arp_recv(const char* ta_name, int sid, csap_handle_t arp_csap, const asn_value* pattern, unsigned int timeout, tapi_arp_frame_t** frames, unsigned int* num);

// macros

#define TAPI_ARP_FILL_ETH_HDR(arp_frame_, src_mac_, dst_mac_)
#define TAPI_ARP_FILL_HDR(arp_frame_, op_, snd_hw_, snd_proto_, tgt_hw_, tgt_proto_)

Detailed Documentation

Declarations of test API for ARP TAD.

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

Typedefs

typedef struct tapi_arp_frame tapi_arp_frame_t

Structure that represents ARP frame: Ethernet header and ARP header

typedef void (*tapi_arp_frame_callback)(
    const tapi_arp_frame_t *header,
    void *userdata
    )

Callback function for the tapi_arp_recv_start() routine, it is called for each packet received on CSAP.

Parameters:

header

Structure with ARP and Ethernet header of the frame

payload

Payload of the frame

plen

Length of the frame payload

userdata

Pointer to user data, provided by the caller of tapi_arp_recv_start

Global Functions

te_errno tapi_arp_eth_csap_create(const char* ta_name, int sid, const char* device, unsigned int receive_mode, const uint8_t* remote_addr, const uint8_t* local_addr, const uint16_t* hw_type, const uint16_t* proto_type, const uint8_t* hw_size, const uint8_t* proto_size, csap_handle_t* arp_csap)

Create ARP CSAP that runs over Ethernet RFC 894.

Parameters:

ta_name

Test Agent name

sid

RCF session

device

interface name on TA host

receive_mode

Receive mode for Ethernet CSAP on the Interface

remote_addr

default remote MAC address, may be NULL - in this case frames will be sent only if dst is specified in template, and frames from all src’s will be catched. If NULL, CSAP will have remote address unconfigured and will require it in traffic template.

local_addr

default local MAC address. may be NULL - in this case frames will be sent with src specifed in template or native for outgoing device (if not present in template).

hw_type

Pointer to ARP header hardware type or NULL

proto_type

Pointer to ARP header protocol type or NULL

hw_size

Pointer to ARP header hardware address size or NULL

proto_size

Pointer to ARP header protocol address size or NULL

arp_csap

Identifier of created CSAP (OUT)

Returns:

zero on success, otherwise standard or common TE error code.

static te_errno tapi_arp_eth_csap_create_ip4(const char* ta_name, int sid, const char* device, unsigned int receive_mode, const uint8_t* remote_addr, const uint8_t* local_addr, csap_handle_t* arp_csap)

Create ‘arp.eth’ CSAP to deal with IPv4 over Ethernet.

See tapi_arp_eth_csap_create() for details.

te_errno tapi_arp_add_csap_layer_eth(asn_value** csap_spec, const char* device, unsigned int receive_mode, const uint8_t* remote_addr, const uint8_t* local_addr)

Add Ethernet layer for ARP protocol in CSAP specification.

Parameters:

csap_spec

Location of CSAP specification pointer.

device

Interface name on TA host or NULL (have to be not-NULL, if Ethernet is the bottom layer)

receive_mode

Receive mode for Ethernet CSAP on the Interface

remote_addr

Default remote MAC address, may be NULL - in this case frames will be sent only dst is specified in template, and frames from all src’s will be catched.

local_addr

Default local MAC address, may be NULL - in this case frames will be sent with src specifed in template or native for outgoing device (if not present in template), frames to all dst’s will be caugth.

Status

code.

See also:

tapi_eth_add_csap_layer, tapi_eth_add_csap_layer_tagged

te_errno tapi_arp_add_csap_layer(asn_value** csap_spec, const uint16_t* hw_type, const uint16_t* proto_type, const uint8_t* hw_size, const uint8_t* proto_size)

Add ARP layer in CSAP specification.

Parameters:

csap_spec

Location of CSAP specification pointer.

hw_type

Pointer to Hardware Type or NULL. If NULL, it have to be specified in traffic templates and match any, if it is not specified in traffic pattern.

proto_type

Pointer to Protocol Type or NULL. If NULL, it have to be specified in traffic templates and match any, if it is not specified in traffic pattern.

hw_size

Pointer to Hardware Address Length or NULL. If NULL, it have to be specified in traffic templates and match any, if it is not specified in traffic pattern.

proto_size

Pointer to Protocol Address Length or NULL. If NULL, it have to be specified in traffic templates and match any, if it is not specified in traffic pattern.

Status

code.

See also:

tapi_arp_add_csap_layer_eth_ip4

te_errno tapi_arp_add_csap_layer_eth_ip4(asn_value** csap_spec)

Add ARP layer for IPv4 over Ethernet in CSAP specification.

Parameters:

csap_spec

Location of CSAP specification pointer.

Status

code.

See also:

tapi_arp_add_csap_layer

te_errno tapi_arp_add_pdu(asn_value** tmpl_or_ptrn, bool is_pattern, const uint16_t* hw_type, const uint16_t* proto_type, const uint8_t* hw_size, const uint8_t* proto_size, const uint16_t* opcode, size_t hw_addr_len, size_t proto_addr_len, const uint8_t* snd_hw_addr, const uint8_t* snd_proto_addr, const uint8_t* tgt_hw_addr, const uint8_t* tgt_proto_addr)

Add ARP 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

is_pattern

Is the first argument template or pattern

hw_type

Pointer to Hardware Type field value or NULL (default value for template have to be specified during CSAP creation)

proto_type

Pointer to Protocol Type field value or NULL (default value for template have to be specified during CSAP creation)

hw_size

Pointer to Hardware Address Length field value or NULL (default value for template have to be specified during CSAP creation)

proto_size

Pointer to Protocol Address Length field value or NULL (default value for template have to be specified during CSAP creation)

opcode

Pointer to OpCode field value or NULL (cannot be used in the case of template, match any on receive)

hw_addr_len

Sender/Target hardware address real length

proto_addr_len

Sender/Target protocol address real length

snd_hw_addr

Sender hardware address or NULL (cannot be used on transmit, match any on receive)

snd_proto_addr

Sender protocol address or NULL (cannot be used on transmit, match any on receive)

tgt_hw_addr

Target hardware address or NULL (cannot be used on transmit, match any on receive)

tgt_proto_addr

Target protocol address or NULL (cannot be used on transmit, match any on receive)

Returns:

Status code.

See also:

tapi_arp_add_csap_layer, tapi_arp_add_pdu_eth_ip4

te_errno tapi_arp_add_pdu_eth_ip4(asn_value** tmpl_or_ptrn, bool is_pattern, const uint16_t* opcode, const uint8_t* snd_hw_addr, const uint8_t* snd_proto_addr, const uint8_t* tgt_hw_addr, const uint8_t* tgt_proto_addr)

Add ARP PDU for IPv4 over Ethernet as the last PDU to the last unit of the traffic template or pattern.

It is assumed that CSAP is created using tapi_arp_add_csap_layer_eth_ip4() function, length of hardware address is equal to ETHER_ADDR_LEN, length of protocol address is equal to sizeof(in_addr_t).

Parameters:

tmpl_or_ptrn

Location of ASN.1 value with traffic template or pattern

is_pattern

Is the first argument template or pattern

opcode

Pointer to OpCode field value or NULL (cannot be used in the case of template, match any on receive)

snd_hw_addr

Sender hardware address or NULL (cannot be used on transmit, match any on receive)

snd_proto_addr

Sender protocol address or NULL (cannot be used on transmit, match any on receive)

tgt_hw_addr

Target hardware address or NULL (cannot be used on transmit, match any on receive)

tgt_proto_addr

Target protocol address or NULL (cannot be used on transmit, match any on receive)

Returns:

Status code.

See also:

tapi_arp_add_csap_layer_eth_ip4, tapi_arp_add_pdu

te_errno tapi_arp_prepare_template(const tapi_arp_frame_t* frame, asn_value** templ)

Creates traffic template for a single ARP frame.

Parameters:

frame

ARP frame data structure as the source of ARP frame values

templ

Placeholder for ARP template (OUT)

Returns:

Status code.

tapi_tad_trrecv_cb_data* tapi_arp_trrecv_cb_data(tapi_arp_frame_callback callback, void* user_data)

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

Parameters:

callback

Callback for ARP frames handling

user_data

User-supplied data to be passed to callback

Returns:

Pointer to allocated callback data or NULL.

te_errno tapi_arp_recv(const char* ta_name, int sid, csap_handle_t arp_csap, const asn_value* pattern, unsigned int timeout, tapi_arp_frame_t** frames, unsigned int* num)

Receives specified number of ARP frames matched with the pattern. The function blocks the caller until all the frames are received or timeout occurred.

Parameters:

ta_name

Test Agent name

sid

RCF session

arp_csap

CSAP handle

pattern

ASN value with receive pattern

timeout

Timeout for receiving of packets, measured in milliseconds

frames

Pointer to the array of packets (OUT) the function allocates memory under the packets that should be freed with free() function

num

Number of packets caller wants to receive (IN) number of received packets (OUT)

Returns:

zero on success, otherwise standard or common TE error code.

Macros

#define TAPI_ARP_FILL_ETH_HDR(arp_frame_, src_mac_, dst_mac_)

Fills in Ethernet header of ARP frame with 802.3 source and destination MAC addresses.

Parameters:

arp_frame_

ARP frame to be updated

src_mac_

Source MAC address

dst_mac_

Destination MAC address

#define TAPI_ARP_FILL_HDR(arp_frame_, op_, snd_hw_, snd_proto_, tgt_hw_, tgt_proto_)

Fills in ARP frame header

Parameters:

arp_frame_

structure storing arp frame

op_

operation type

snd_hw_

sender hardware address

snd_proto_

sender protocol address

tgt_hw_

target hardware address

tgt_proto_

target protocol address