1<!-- Creator : groff version 1.22.2 --> 2<!-- CreationDate: Fri Feb 3 15:37:41 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_ppeek</title> 17<link rel="stylesheet" href="./common.css"> 18</head> 19<body> 20<div class="main"> 21<h1 align="center">mtcp_ppeek</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<hr> 32--> 33 34<h2>NAME 35<a name="NAME"></a> 36</h2> 37 38 39<p style="margin-left:11%; margin-top: 1em">mtcp_ppeek 40− Peek into the bytestream from a monitoring socket 41from a given offset</p> 42 43<h2>SYNOPSIS 44<a name="SYNOPSIS"></a> 45</h2> 46 47 48<p style="margin-left:11%; margin-top: 1em"><b>#include 49<mos_api.h></b></p> 50 51<p style="margin-left:11%; margin-top: 1em"><b>ssize_t 52mtcp_ppeek(mctx_t</b> <i>mctx</i><b>, int</b> 53<i>sockid</i><b>, int</b> <i>side</i><b>, char 54*</b><i>buf</i><b>, size_t</b> <i>len</i><b>, uint64_t</b> 55<i>off</i><b>);</b></p> 56 57<h2>DESCRIPTION 58<a name="DESCRIPTION"></a> 59</h2> 60 61 62 63<p style="margin-left:11%; margin-top: 1em"><b>mtcp_ppeek</b>() 64can be used to peek up to <i>len</i> number of bytes from a 65monitoring socket via socket descriptor <i>sockid</i> into 66the buffer starting at <i>buf. from off ;</i> value which is 67the offset distance (in bytes) from the TCP initial sequence 68number. It is the responsibility of the user to allocate 69memory for <i>buf</i> array.</p> 70 71<p style="margin-left:11%; margin-top: 1em">For cases when 72the total number of buffered unread bytes in the socket are 73less than <i>len,</i> <b>mtcp_ppeek()</b> copies entire data 74to <i>buf</i> and returns the actual number of bytes that 75can be used by the application.</p> 76 77<p style="margin-left:11%; margin-top: 1em">Note that the 78<i>off</i> can also point to the data in the fragmented 79buffer list of the TCP ring buffer (see 80<b>mtcp_getsockopt()).</b> If there is no received byte at 81<i>off</i> in the TCP ring buffer, it returns error. If 82there are received bytes starting from <i>off ,</i> len is 83set to be the number of bytes read from the buffer. After 84<b>mtcp_ppeek(),</b> the data in the TCP ring buffer will 85not be flushed, and the monitor offset used by 86<b>mtcp_peek()</b> is not changed.</p> 87 88<p style="margin-left:11%; margin-top: 1em">An 89<b>mtcp_ppeek</b>() call takes two additional argument named 90<i>mctx ,</i> that represents the per-core mTCP context in 91an application (see <b>mtcp_create_context()</b> for 92details); and <i>side</i> that informs the stack whether it 93needs to peek the client (MOS_SIDE_CLI) or server 94(MOS_SIDE_SVR) side.</p> 95 96<h2>RETURN VALUE 97<a name="RETURN VALUE"></a> 98</h2> 99 100 101<p style="margin-left:11%; margin-top: 1em">On success, the 102number of bytes read is returned. It is not an error if this 103number is smaller than the number of bytes requested; this 104may happen when the socket has fewer number of bytes 105buffered at that moment. On all errors, -1 is returned and 106<i>errno</i> is set appropriately.</p> 107 108<h2>ERRORS 109<a name="ERRORS"></a> 110</h2> 111 112 113<table width="100%" border="0" rules="none" frame="void" 114 cellspacing="0" cellpadding="0"> 115<tr valign="top" align="left"> 116<td width="11%"></td> 117<td width="23%"> 118 119 120<p style="margin-top: 1em"><b>EACCES</b></p></td> 121<td width="4%"></td> 122<td width="62%"> 123 124 125<p style="margin-top: 1em">The <i>mctx</i> argument is 126invalid.</p> </td></tr> 127<tr valign="top" align="left"> 128<td width="11%"></td> 129<td width="23%"> 130 131 132<p><b>EBADF</b></p></td> 133<td width="4%"></td> 134<td width="62%"> 135 136 137<p>The socket descriptor <i>sockid</i> is invalid.</p></td></tr> 138<tr valign="top" align="left"> 139<td width="11%"></td> 140<td width="23%"> 141 142 143<p><b>EINVAL</b></p></td> 144<td width="4%"></td> 145<td width="62%"> 146 147 148<p>The buffer management of the monitoring socket with 149<i>sockid</i> was already disabled.</p></td></tr> 150<tr valign="top" align="left"> 151<td width="11%"></td> 152<td width="23%"> 153 154 155<p><b>ESOCKTNOSUPPORT</b></p></td> 156<td width="4%"></td> 157<td width="62%"> 158 159 160<p>The socket referred to by <i>sockid</i> has invalid 161<i>type</i></p> </td></tr> 162<tr valign="top" align="left"> 163<td width="11%"></td> 164<td width="23%"> 165 166 167<p><b>ENOTCONN</b></p></td> 168<td width="4%"></td> 169<td width="62%"> 170 171 172<p>Th socket referred to by <i>sockid</i> is in a TCP state 173that disallows read operations.</p></td></tr> 174<tr valign="top" align="left"> 175<td width="11%"></td> 176<td width="23%"> 177 178 179<p><b>ENODATA</b></p></td> 180<td width="4%"></td> 181<td width="62%"> 182 183 184<p>The socket referred to by <i>sockid</i> does not have 185any available bytes in its buffer for reading.</p></td></tr> 186<tr valign="top" align="left"> 187<td width="11%"></td> 188<td width="23%"> 189 190 191<p><b>EPERM</b></p></td> 192<td width="4%"></td> 193<td width="62%"> 194 195 196<p>The caller is not permitted to access this function.</p></td></tr> 197</table> 198 199<h2>AUTHORS 200<a name="AUTHORS"></a> 201</h2> 202 203 204<p style="margin-left:11%; margin-top: 1em">mOS development 205team <[email protected]></p> 206 207 208<!-----------------------------------------------------------> 209<h2>EXAMPLES 210 <a name="EXAMPLES"></a> 211</h2> 212 213<p style="margin-left:11%; margin-top: 1em"> 214 <a href="http://mos.kaist.edu/guide/programmer/05_api_example.html#monitoring-reassembled-tcp-payload"> 215 http://mos.kaist.edu/guide/programmer/05_api_example.html#monitoring-reassembled-tcp-payload 216 </a> 217</p> 218<!-----------------------------------------------------------> 219 220 221<h2>SEE ALSO 222<a name="SEE ALSO"></a> 223</h2> 224 225 226 227<p style="margin-left:11%; margin-top: 1em"><b>mtcp_peek</b>(), 228<b>mtcp_socket</b>(),</p> 229 230<h2>COLOPHON 231<a name="COLOPHON"></a> 232</h2> 233 234 235<p style="margin-left:11%; margin-top: 1em">This page is 236part of mOS release 0.3 <i>docs</i> section. A description 237of the project, and information about reporting bugs, can be 238found at http://mos.kaist.edu/.</p> 239<!-- <hr>--> 240<br> 241<div class="footer"> 242 <img src="back-arrow.jpg" width="2%" height="2%"><a href="http://mos.kaist.edu/index_man.html">Back to Index</a> 243</div> 244</div> 245</body> 246</html> 247