PCAP

Overview

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

// typedefs

typedef void (*tapi_pcap_recv_callback)(
    int filter_id,
    const uint8_t *pkt_data,
    uint16_t pkt_len,
    void *user_data
    );

// global functions

int tapi_pcap_add_csap_layer(asn_value** csap_spec, const char* ifname, unsigned int iftype, unsigned int recv_mode);
int tapi_pcap_csap_create(const char* ta_name, int sid, const char* ifname, unsigned int iftype, unsigned int recv_mode, csap_handle_t* pcap_csap);
tapi_tad_trrecv_cb_data* tapi_pcap_trrecv_cb_data(tapi_pcap_recv_callback callback, void* user_data);
int tapi_pcap_pattern_add(const char* filter, const int filter_id, asn_value** pattern);

// macros

#define PCAP_LINKTYPE_DEFAULT
#define PCAP_RECV_MODE_ALL
#define PCAP_RECV_MODE_DEF

Detailed Documentation

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

Typedefs

typedef void (*tapi_pcap_recv_callback)(
    int filter_id,
    const uint8_t *pkt_data,
    uint16_t pkt_len,
    void *user_data
    )

Callback function for the tapi_pcap_pkt_handler() routine, it is called for each packet received for csap.

Parameters:

filter_id

Filter ID that corresponds to received packet.

pkt_data

Received packet in binary form.

pkt_len

Length of the received packet.

user_data

Pointer to user data, passed to tapi_pcap_pkt_handler() in user_param as user_data field of tapi_pcap_pkt_handler_data.

Global Functions

int tapi_pcap_add_csap_layer(asn_value** csap_spec, const char* ifname, unsigned int iftype, unsigned int recv_mode)

Add Ethernet-PCAP CSAP layer.

Parameters:

csap_spec

Location of the CSAP specification

ifname

Interface name on TA host

iftype

Interface datalink type (see man pcap)

recv_mode

Receive mode, bit scale defined by elements of ‘enum pcap_csap_receive_mode’ in ndn_pcap.h.

Returns:

Status code.

int tapi_pcap_csap_create(const char* ta_name, int sid, const char* ifname, unsigned int iftype, unsigned int recv_mode, csap_handle_t* pcap_csap)

Create common Ethernet-PCAP CSAP.

Parameters:

ta_name

Test Agent name

sid

RCF session

ifname

Interface name on TA host

iftype

Interface datalink type (see man pcap)

recv_mode

Receive mode, bit scale defined by elements of ‘enum pcap_csap_receive_mode’ in ndn_pcap.h.

pcap_csap

Identifier of created CSAP (OUT)

Returns:

Status code.

tapi_tad_trrecv_cb_data* tapi_pcap_trrecv_cb_data(tapi_pcap_recv_callback callback, void* user_data)

Prepare PCAP 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.

int tapi_pcap_pattern_add(const char* filter, const int filter_id, asn_value** pattern)

Creates traffic pattern for a single Ethernet-PCAP frame.

Parameters:

filter

Tcpdump-like filtering rule

filter_id

Value that should be responsed when packet match filtering rule

pattern

Placeholder for the pattern (OUT)

Returns:

Status of the operation

Macros

#define PCAP_LINKTYPE_DEFAULT

Default PCAP link type is 10/100 MBit/s ethernet (see ‘man 3 pcap’ for other types)

#define PCAP_RECV_MODE_ALL

Receive all packets mode

#define PCAP_RECV_MODE_DEF

Default recv mode: all except OUTGOING packets.