mtcp_sendpkt 3 2017-08-27 "Linux" "mOS Library Functions Manual"
NAME
mtcp_sendpkt - Sends a self-constructed TCP packet to network
SYNOPSIS
#include <mos_api.h> "int mtcp_sendpkt(mctx_t " mctx ", int " sockid ", struct pkt_info *" pinfo );
DESCRIPTION
mtcp_sendpkt () sends a self-constructed TCP packet for a given flow to network. The user can select the socket descriptor using "sockid" and the "pinfo" points to an instance of struct pkt_info that is allocated and filled by the user via mtcp_getlastpkt() function. It is the user's responsibility to allocate the "pkt_info" structure before the function call, and free the "pkt_info" after the function call. 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_sendpkt() constructs a TCP packet based on the given packet information "pinfo" and send the packet to the network. An mtcp_sendpkt() 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

15 "EACCES" "mctx" is invalid, or "pinfo" is NULL.

15 "ENODATA" The packet information does not contain a valid IP header or TCP header information. This normally does not occur when we put the result of the "mtcp_sendpkt()" function. Therefore, it means that the user modified the packet information inappropriately. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""".SH CONFORMING TO
""""POSIX.1-2001.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

AUTHORS
mOS development team <[email protected]> """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
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/. """""""""""""""""""""""""""""""""""""""""""""""""""""