1<!-- Creator : groff version 1.22.3 --> 2<!-- CreationDate: Mon Aug 28 06:36:47 2017 --> 3<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 4"http://www.w3.org/TR/html4/loose.dtd"> 5<html> 6<head> 7<meta name="generator" content="groff -Thtml, see www.gnu.org"> 8<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> 9<meta name="Content-Style" content="text/css"> 10<style type="text/css"> 11 p { margin-top: 0; margin-bottom: 0; vertical-align: top } 12 pre { margin-top: 0; margin-bottom: 0; vertical-align: top } 13 table { margin-top: 0; margin-bottom: 0; vertical-align: top } 14 h1 { text-align: center } 15</style> 16<title>mtcp_setlastpkt</title> 17<link rel="stylesheet" href="./common.css"> 18</head> 19<body> 20<div class="main"> 21<h1 align="center">mtcp_setlastpkt</h1> 22<!-- 23<a href="#NAME">NAME</a><br> 24<a href="#SYNOPSIS">SYNOPSIS</a><br> 25<a href="#DESCRIPTION">DESCRIPTION</a><br> 26<a href="#RETURN VALUE">RETURN VALUE</a><br> 27<a href="#ERRORS">ERRORS</a><br> 28<a href="#AUTHORS">AUTHORS</a><br> 29<a href="#SEE ALSO">SEE ALSO</a><br> 30<a href="#COLOPHON">COLOPHON</a><br> 31 32<hr> 33--> 34 35<h2>NAME 36<a name="NAME"></a> 37</h2> 38 39 40 41<p style="margin-left:11%; margin-top: 1em">mtcp_setlastpkt 42− modifies the last Ethernet frame of a monitoring 43flow</p> 44 45<h2>SYNOPSIS 46<a name="SYNOPSIS"></a> 47</h2> 48 49 50<p style="margin-left:11%; margin-top: 1em"><b>#include 51<mos_api.h></b></p> 52 53<p style="margin-left:11%; margin-top: 1em"><b>ssize_t 54mtcp_setlastpkt(mctx_t</b> <i>mctx</i><b>, int</b> 55<i>sockid</i><b>, int</b> <i>side</i><b>, off_t</b> 56<i>offset</i><b>, byte *</b> <i>data</i><b>, uint16_t</b> 57<i>datalen</i><b>, int</b> <i>option</i><b>);</b></p> 58 59<h2>DESCRIPTION 60<a name="DESCRIPTION"></a> 61</h2> 62 63 64 65<p style="margin-left:11%; margin-top: 1em"><b>mtcp_setlastpkt</b>() 66updates the last Ethernet frame for a given flow observed by 67the stack. The user can specify the flow and direction with 68the socket descriptor <i>sockid</i> and the <i>side</i> 69argument (MOS_SIDE_CLI or MOS_SIDE_SVR) to specify the 70Ethernet frame of her choosing to be modified.</p> 71 72<p style="margin-left:11%; margin-top: 1em">The 73<i>option</i> argument can be used to define which action 74should be performed on the packet. The value of 75<i>option</i> should be the logical disjunction of action to 76perform (MOS_DROP or MOS_OVERWRITE), 77position for modification (MOS_ETH_HDR or 78MOS_IP_HDR or MOS_TCP_HDR or MOS_TCP_PAYLOAD), and 79checksum operation to perform (MOS_UPDATE_IP_CHKSUM or 80MOS_UPDATE_TCP_CHKSUM). It allows modifying the packet contents 81as long as the overall TCP payload size is not changed. 82</p> 83 84<table width="100%" border="0" rules="none" frame="void" 85 cellspacing="0" cellpadding="0"> 86<tr valign="top" align="left"> 87<td width="11%"></td> 88<td width="12%"> 89 90<p style="margin-left:11%; margin-top: 1em"><b>MOS_DROP</b></p></td> 91<td width="6%"></td> 92<td width="71%"> 93 94<p>Drop the last Ethernet frame. This option ignores any 95 other flags in the <i>option</i> parameter.</p></td> 96</tr> 97 98<tr valign="top" align="left"> 99<td width="11%"></td> 100<td width="12%"> 101 102<p style="margin-left:11%; margin-top: 1em"><b>MOS_OVERWRITE</b></p></td> 103<td width="6%"></td> 104<td width="71%"> 105 106<p>Overwrite some data onto the 107specific header or payload (MOS_ETH_HDR or MOS_IP_HDR or 108MOS_TCP_HDR or MOS_TCP_PAYLOAD) of the last Ethernet frame. 109The user can specify the offset from where the data should 110be written ( <i>offset</i> ), the data buffer that contains 111the data to be written ( <i>data</i> ), and the bytes in the 112data buffer ( <i>datalen</i> ).</p></td> 113</tr> 114 115</table> 116 117 118<p style="margin-left:11%; margin-top: 1em">Here are some 119restrictions on the <i>option</i> field: (a) MOS_DROP and 120MOS_OVERWRITE are mutually 121exclusive parameters, but one of them should be specified in 122the <i>option</i> field. (b) MOS_DROP ignores any other 123flags in the <i>option</i> parameter. (c) MOS_ETH_HDR, 124MOS_IP_HDR, MOS_TCP_HDR, and MOS_TCP_PAYLOAD are mutually 125exclusive parameters, but one of them should be specified in 126the <i>option</i> field.</p> 127 128<h2>RETURN VALUE 129<a name="RETURN VALUE"></a> 130</h2> 131 132 133<p style="margin-left:11%; margin-top: 1em">Returns 0 on 134success. On all errors, -1 is returned and <i>errno</i> is 135set appropriately.</p> 136 137<h2>ERRORS 138<a name="ERRORS"></a> 139</h2> 140 141 142<table width="100%" border="0" rules="none" frame="void" 143 cellspacing="0" cellpadding="0"> 144<tr valign="top" align="left"> 145<td width="11%"></td> 146<td width="23%"> 147 148 149<p style="margin-top: 1em"><b>EACCES</b></p></td> 150<td width="4%"></td> 151<td width="62%"> 152 153 154<p style="margin-top: 1em">The <i>mctx</i> argument is 155invalid.</p> </td></tr> 156<tr valign="top" align="left"> 157<td width="11%"></td> 158<td width="23%"> 159 160 161<p><b>EBADF</b></p></td> 162<td width="4%"></td> 163<td width="62%"> 164 165 166<p>The socket descriptor <i>sockid</i> is invalid.</p></td></tr> 167<tr valign="top" align="left"> 168<td width="11%"></td> 169<td width="23%"> 170 171 172<p><b>EINVAL</b></p></td> 173<td width="4%"></td> 174<td width="62%"> 175 176 177<p>The buffer management of the monitoring socket with 178<i>sockid</i> was already disabled.</p></td></tr> 179<tr valign="top" align="left"> 180<td width="11%"></td> 181<td width="23%"> 182 183 184<p><b>ESOCKTNOSUPPORT</b></p></td> 185<td width="4%"></td> 186<td width="62%"> 187 188 189<p>The socket referred to by <i>sockid</i> has invalid 190<i>type</i></p> </td></tr> 191<tr valign="top" align="left"> 192<td width="11%"></td> 193<td width="23%"> 194 195 196<p><b>ENOTCONN</b></p></td> 197<td width="4%"></td> 198<td width="62%"> 199 200 201<p>Th socket referred to by <i>sockid</i> is in a TCP state 202that disallows read operations.</p></td></tr> 203<tr valign="top" align="left"> 204<td width="11%"></td> 205<td width="23%"> 206 207 208<p><b>ENODATA</b></p></td> 209<td width="4%"></td> 210<td width="62%"> 211 212 213<p>The socket referred to by <i>sockid</i> does not have 214any available bytes in its buffer for reading.</p></td></tr> 215<tr valign="top" align="left"> 216<td width="11%"></td> 217<td width="23%"> 218 219 220<p><b>EPERM</b></p></td> 221<td width="4%"></td> 222<td width="62%"> 223 224 225<p>The caller is not permitted to access this function.</p></td></tr> 226</table> 227 228<h2>AUTHORS 229<a name="AUTHORS"></a> 230</h2> 231 232 233<p style="margin-left:11%; margin-top: 1em">mOS development 234team <[email protected]></p> 235 236<h2>SEE ALSO 237<a name="SEE ALSO"></a> 238</h2> 239 240 241 242<p style="margin-left:11%; margin-top: 1em"><b>mtcp_getlastpkt</b>(),</p> 243 244<h2>COLOPHON 245<a name="COLOPHON"></a> 246</h2> 247 248 249<p style="margin-left:11%; margin-top: 1em">This page is 250part of mOS release 0.3 <i>docs</i> section. A description 251of the project, and information about reporting bugs, can be 252found at http://mos.kaist.edu/.</p> 253<hr> 254<div class="footer"> 255 <img src="back-arrow.jpg" width="2%" height="2%"><a href="http://mos.kaist.edu/index_man.html">Back to Index</a> 256</div> 257</div> 258</body> 259</html> 260