mtcp_getlastpkt

NAME

mtcp_getlastpkt − Retrieves the last Ethernet frame of a monitoring flow

SYNOPSIS

#include <mos_api.h>

int mtcp_getlastpkt(mctx_t mctx, int sockid, int side, struct pkt_info *pinfo);

DESCRIPTION

mtcp_getlastpkt() fetches a copy of the last Ethernet frame for a given flow observed by the stack. The user can select the socket descriptor using sockid and the side argument (MOS_SIDE_CLI or MOS_SIDE_SVR) to fetch the Ethernet frame of her choosing. pinfo points to an instance of struct pkt_info that should be allocated by the user before calling the function. The structure is defined as:

struct pkt_info {

// pkt recving time
uint32_t cur_ts;

// ETH
uint16_t eth_len;

// IP
uint16_t ip_len;

//TCP
uint64_t offset; // TCP recv buffer offset
uint16_t payloadlen;
uint32_t seq;
uint32_t ack_seq;
uint16_t window;

struct ethhdr *ethh;
struct iphdr *iph;
struct tcphdr *tcph;
uint8_t *payload;

}

A successful call to mtcp_getlastpkt() creates a copy of the last recorded Ethernet frame and appends its meta-data (in host byte order). The last four fields of pinfo (ethh, iph, tcph and payload) point to the copied frame at the appropriate offsets. Please note that the packet buffer that contains the copied frame is reused for future invocations of mtcp_getlastpkt().

An mtcp_getlastpkt() call takes an additional argument named mctx that represents the per-core mTCP context in an application (see mtcp_create_context() for details).

RETURN VALUE

Returns 0 on success; -1 on failure. In case of failure, errno is set appropriately.

ERRORS

EACCES

mctx is invalid.

EPERM

Permission denied.

ENODATA

The last captured Ethernet frame for this flow does not exist. This can occur if mtcp_getlastpkt() is called during e.g. connection initiation.

EBADF

sockid is not a valid socket descriptor for creating a connection.

AUTHORS

mOS development team <mtcp-user@list.ndsl.kaist.edu>

SEE ALSO

mtcp_create_context(), mtcp_setlastpkt(), mtcp_socket(),

COLOPHON

This page is part of mOS release 0.3 docs section. A description of the project, and information about reporting bugs, can be found at http://mos.kaist.edu/.