Ethernet

Overview

Declarations of test API for Ethernet TAD. More…

// typedefs

typedef void (*tapi_eth_frame_callback)(
    const asn_value *packet,
    int layer,
    const ndn_eth_header_plain *header,
    const uint8_t *payload,
    uint16_t plen,
    void *user_data
    );

// global functions

te_errno tapi_eth_add_csap_layer(asn_value** csap_spec, const char* device, unsigned int recv_mode, const uint8_t* remote_addr, const uint8_t* local_addr, const uint16_t* ether_type, te_bool3 tagged, te_bool3 llc);
te_errno tapi_eth_add_pdu(asn_value** tmpl_or_ptrn, asn_value** pdu, bool is_pattern, const uint8_t* dst_addr, const uint8_t* src_addr, const uint16_t* ether_type, te_bool3 tagged, te_bool3 llc);
te_errno tapi_eth_pdu_length_type(asn_value* pdu, const uint16_t len_type);
te_errno tapi_eth_pdu_tag_header(asn_value* pdu, const uint8_t* priority, const uint16_t* vlan_id);
te_errno tapi_eth_pdu_llc_snap(asn_value* pdu);
te_errno tapi_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* len_type, csap_handle_t* eth_csap);
te_errno tapi_eth_gen_traffic_sniff_pattern(const char* ta_name, int sid, const char* if_name, asn_value* template, send_transform* transform, asn_value** pattern_out);
tapi_tad_trrecv_cb_data* tapi_eth_trrecv_cb_data(tapi_eth_frame_callback callback, void* user_data);
te_errno tapi_eth_set_csap_layer(asn_value* csap_spec, const char* device, unsigned int recv_mode, const uint8_t* remote_addr, const uint8_t* local_addr, const uint16_t* len_type);
te_errno tapi_eth_based_csap_create_by_tmpl(const char* ta_name, int sid, const char* device, unsigned int recv_mode, const asn_value* tmpl, csap_handle_t* eth_csap);

Detailed Documentation

Declarations of test API for Ethernet TAD.

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

Typedefs

typedef void (*tapi_eth_frame_callback)(
    const asn_value *packet,
    int layer,
    const ndn_eth_header_plain *header,
    const uint8_t *payload,
    uint16_t plen,
    void *user_data
    )

Callback function for the tapi_eth_pkt_handler_data callback parameter, it is called for each packet received by CSAP.

Parameters:

packet

Packet in ASN.1 representation.

layer

Index of the Ethernet layer in packet.

header

Structure with Ethernet header of the frame.

payload

Payload of the frame.

plen

Length of the frame payload.

user_data

Pointer to user data, specified in user_data field of tapi_eth_pkt_handler_data.

Global Functions

te_errno tapi_eth_add_csap_layer(asn_value** csap_spec, const char* device, unsigned int recv_mode, const uint8_t* remote_addr, const uint8_t* local_addr, const uint16_t* ether_type, te_bool3 tagged, te_bool3 llc)

Add Ethernet layer 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 it is the bottom layer)

recv_mode

Receive mode (bit scale defined by elements of ‘enum tad_eth_recv_mode’ in tad_common.h). Use TAD_ETH_RECV_DEF by default.

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.

ether_type

Pointer to default EtherType. See description in IEEE 802.3.

tagged

Whether frames should be VLAN tagged, any or untagged.

llc

Whether frames should be 802.2 LLC, any or Ethernet2.

Status

code.

See also:

tapi_eth_add_csap_layer_tagged

te_errno tapi_eth_add_pdu(asn_value** tmpl_or_ptrn, asn_value** pdu, bool is_pattern, const uint8_t* dst_addr, const uint8_t* src_addr, const uint16_t* ether_type, te_bool3 tagged, te_bool3 llc)

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

dst_addr

Pointer to destination address or NULL. If NULL, default value is specified during CSAP creation (as remove address for sending, as local address for receiving).

src_addr

Pointer to source address or NULL. If NULL, default value is specified during CSAP creation (as local address for sending, as remote address for receiving).

ether_type

Pointer to EtherType or NULL. If NULL, default value is specified during CSAP creation (otherwise, match any on receive).

tagged

Whether frames should be VLAN tagged, any or untagged.

llc

Whether frames should be 802.2 LLC, any or Ethernet2.

Returns:

Status code.

te_errno tapi_eth_pdu_length_type(asn_value* pdu, const uint16_t len_type)

Add exact specification of the Length/Type field of the IEEE 802.3 frame.

Parameters:

pdu

ANS.1 PDU to add tag header

len_type

Length/Type value

Returns:

Status code.

te_errno tapi_eth_pdu_tag_header(asn_value* pdu, const uint8_t* priority, const uint16_t* vlan_id)

Add IEEE Std 802.1Q tag header.

CFI is not specified here, since it affects E-RIF presence. By default, CFI is zero on send and match any on receive.

Parameters:

pdu

ANS.1 PDU to add tag header

priority

Pointer to priority or NULL. If NULL, default value is specified during CSAP creation. Otherwise, match any on receive and use 0 on send.

vlan_id

Pointer to VLAN identifier or NULL. If NULL, default value is specified during CSAP creation. Otherwise, match any on receive and use 0 on send.

Returns:

Status code.

te_errno tapi_eth_pdu_llc_snap(asn_value* pdu)

Add IEEE Std 802.2 LLC and 802 SNAP sublayer headers.

Parameters:

pdu

ANS.1 PDU to add sublayer headers

Returns:

Status code.

te_errno tapi_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* len_type, csap_handle_t* eth_csap)

Create common Ethernet CSAP.

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 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). If NULL, CSAP will have remote address unconfigured and will require it in traffic template.

len_type

Default Ethernet Length/Type field. See description in IEEE Std 802.3. If NULL, CSAP will have Length/Type unconfigured and will require it in traffic template.

eth_csap

Identifier of created CSAP (OUT)

Returns:

Status code.

te_errno tapi_eth_gen_traffic_sniff_pattern(const char* ta_name, int sid, const char* if_name, asn_value* template, send_transform* transform, asn_value** pattern_out)

Generate traffic by the given template, sniff the packets sent and produce a pattern by means of the packets sent taking into account possible transformations

Parameters:

ta_name

Test Agent name

sid

RCF session ID

if_name

Interface name on TA host

template

ASN.1 traffic template

transform

A set of parameters describing some trasformations which are expected to affect the outgoing packets

pattern_out

Location for the pattern which is to be produced or NULL

Returns:

Status code

tapi_tad_trrecv_cb_data* tapi_eth_trrecv_cb_data(tapi_eth_frame_callback callback, void* user_data)

Prepare Ethernet layer callback data for tapi_tad_trrecv_get(), tapi_tad_trrecv_stop() or tapi_tad_trrecv_wait() routines.

Parameters:

callback

User callback to be called for each received packet

user_data

Opaque user data to be passed to callback

Returns:

Allocated structure to be passed to tapi_tad_trrecv_get(), tapi_tad_trrecv_stop() or tapi_tad_trrecv_wait() as cb_data.

te_errno tapi_eth_set_csap_layer(asn_value* csap_spec, const char* device, unsigned int recv_mode, const uint8_t* remote_addr, const uint8_t* local_addr, const uint16_t* len_type)

Set parameters of Ethernet layer in CSAP specification.

Parameters:

csap_spec

CSAP specification pointer.

device

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

recv_mode

Receive mode (bit scale defined by elements of ‘enum tad_eth_recv_mode’ in tad_common.h). Use TAD_ETH_RECV_DEF by default.

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.

len_type

Pointer to default EtherType. See description in IEEE 802.3.

Returns:

Status code.

te_errno tapi_eth_based_csap_create_by_tmpl(const char* ta_name, int sid, const char* device, unsigned int recv_mode, const asn_value* tmpl, csap_handle_t* eth_csap)

Create Ethernet-based CSAP by traffic template and interface

Parameters:

ta_name

Test Agent name

sid

RCF session

device

Interface name on TA host

recv_mode

Receive mode for Ethernet CSAP on the Interface

tmpl

Location of ASN.1 value with traffic template

eth_csap

Identifier of created CSAP (OUT)

Returns:

Status code.