mtcp_setlastpkt 3 2017-08-28 "Linux" "mOS Library Functions Manual"
NAME
mtcp_setlastpkt - modifies the last Ethernet frame of a monitoring flow
SYNOPSIS
#include <mos_api.h> "ssize_t mtcp_setlastpkt(mctx_t " mctx ", int " sockid ", int " side ", off_t " offset ", byte * " data ", uint16_t " datalen ", int " option );
DESCRIPTION
mtcp_setlastpkt () updates the last Ethernet frame for a given flow observed by the stack.
The user can specify the flow and direction with the socket descriptor
"sockid" and the
"side" argument (MOS_SIDE_CLI or MOS_SIDE_SVR)
to specify the Ethernet frame of her choosing to be modified.
The
"option" argument can be used to define which action should be performed on the packet.
The value of
"option" should be the logical disjunction of
action to perform (MOS_DROP or MOS_OVERWRITE),
position for modification (MOS_ETH_HDR or MOS_IP_HDR or MOS_TCP_HDR
or MOS_TCP_PAYLOAD), and checksum operation to perform
(MOS_UPDATE_IP_CHKSUM or MOS_UPDATE_TCP_CHKSUM).
It allows modifying the packet contents
as long as the overall TCP payload size is not changed.
12
MOS_DROP Drop the last Ethernet frame. This option ignores any other
flags in the
"option" parameter.
12
MOS_OVERWRITE Overwrite some data onto the specific header or payload (MOS_ETH_HDR or
MOS_IP_HDR or MOS_TCP_HDR or MOS_TCP_PAYLOAD) of the last Ethernet frame.
The user can specify the offset from where the data should be written (
"offset" ), the data buffer that contains the data to be written (
"data" ), and the bytes in the data buffer (
"datalen" ).
Here are some restrictions on the
"option" field: (a) MOS_DROP and MOS_OVERWRITE are mutually
exclusive parameters, but one of them should be specified in the
"option" field.
(b) MOS_DROP ignores any other flags in the
"option" parameter.
(c) MOS_ETH_HDR, MOS_IP_HDR, MOS_TCP_HDR, and MOS_TCP_PAYLOAD are mutually
exclusive parameters, but one of them should be specified in the
"option" field.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
RETURN VALUE
Returns 0 on success. On all errors, -1 is returned and
"errno" is set appropriately.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" ERRORS
18
"EACCES" The
"mctx" argument is invalid.
18
"EBADF" The socket descriptor
"sockid" is invalid.
18
"EINVAL" The buffer management of the monitoring socket with
"sockid" was already disabled.
18
"ESOCKTNOSUPPORT" The socket referred to by
"sockid" has invalid
"type"
18
"ENOTCONN" Th socket referred to by
"sockid" is in a TCP state that disallows read operations.
18
"ENODATA" The socket referred to by
"sockid" does not have any available bytes in its buffer
for reading.
18
"EPERM" The caller is not permitted
to access this function.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""".SH CONFORMING TO
""""POSIX.1-2001.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
AUTHORS
mOS development team <
[email protected]>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" SEE ALSO
mtcp_getlastpkt (), """"""""""""""""""""""""""""""""""""""""""""""""""""" 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/.
"""""""""""""""""""""""""""""""""""""""""""""""""""""