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 | ||
// ETH | ||
// IP | ||
//TCP | ||
struct ethhdr *ethh; |
}
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>
EXAMPLES
http://mos.kaist.edu/guide/programmer/05_api_example.html#monitoring-packet-metadata-and-payload
http://mos.kaist.edu/guide/programmer/05_api_example.html#generating-and-sending-a-packet
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/.