summaryrefslogtreecommitdiff
path: root/static/freebsd/man3/CMSG_DATA.3 3.html
diff options
context:
space:
mode:
Diffstat (limited to 'static/freebsd/man3/CMSG_DATA.3 3.html')
-rw-r--r--static/freebsd/man3/CMSG_DATA.3 3.html211
1 files changed, 0 insertions, 211 deletions
diff --git a/static/freebsd/man3/CMSG_DATA.3 3.html b/static/freebsd/man3/CMSG_DATA.3 3.html
deleted file mode 100644
index bbc6823b..00000000
--- a/static/freebsd/man3/CMSG_DATA.3 3.html
+++ /dev/null
@@ -1,211 +0,0 @@
-<table class="head">
- <tr>
- <td class="head-ltitle">CMSG_DATA(3)</td>
- <td class="head-vol">Library Functions Manual</td>
- <td class="head-rtitle">CMSG_DATA(3)</td>
- </tr>
-</table>
-<div class="manual-text">
-<section class="Sh">
-<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
-<p class="Pp"><code class="Nm">CMSG_DATA</code>,
- <code class="Nm">CMSG_FIRSTHDR</code>, <code class="Nm">CMSG_LEN</code>,
- <code class="Nm">CMSG_NXTHDR</code>, <code class="Nm">CMSG_SPACE</code>
- &#x2014; <span class="Nd">socket control message routines for ancillary data
- access</span></p>
-</section>
-<section class="Sh">
-<h1 class="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h1>
-<p class="Pp"><code class="In">#include
- &lt;<a class="In">sys/socket.h</a>&gt;</code></p>
-<p class="Pp"><var class="Ft">unsigned char *</var>
- <br/>
- <code class="Fn">CMSG_DATA</code>(<var class="Fa" style="white-space: nowrap;">struct
- cmsghdr *</var>);</p>
-<p class="Pp"><var class="Ft">struct cmsghdr *</var>
- <br/>
- <code class="Fn">CMSG_FIRSTHDR</code>(<var class="Fa" style="white-space: nowrap;">struct
- msghdr *</var>);</p>
-<p class="Pp"><var class="Ft">size_t</var>
- <br/>
- <code class="Fn">CMSG_LEN</code>(<var class="Fa" style="white-space: nowrap;">size_t</var>);</p>
-<p class="Pp"><var class="Ft">struct cmsghdr *</var>
- <br/>
- <code class="Fn">CMSG_NXTHDR</code>(<var class="Fa" style="white-space: nowrap;">struct
- msghdr *</var>, <var class="Fa" style="white-space: nowrap;">struct cmsghdr
- *</var>);</p>
-<p class="Pp"><var class="Ft">size_t</var>
- <br/>
- <code class="Fn">CMSG_SPACE</code>(<var class="Fa" style="white-space: nowrap;">size_t</var>);</p>
-</section>
-<section class="Sh">
-<h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
-<p class="Pp">The control message API is used to construct ancillary data
- objects for use in control messages sent and received across sockets.</p>
-<p class="Pp">Control messages are passed around by the
- <a class="Xr">recvmsg(2)</a> and <a class="Xr">sendmsg(2)</a> system calls.
- The <var class="Vt">cmsghdr</var> structure, described in
- <a class="Xr">recvmsg(2)</a>, is used to specify a chain of control
- messages.</p>
-<p class="Pp">These routines should be used instead of directly accessing the
- control message header members and data buffers as they ensure that
- necessary alignment constraints are met.</p>
-<p class="Pp">The following routines are provided:</p>
-<dl class="Bl-tag">
- <dt id="CMSG_DATA"><a class="permalink" href="#CMSG_DATA"><code class="Fn">CMSG_DATA</code></a>(<var class="Fa">cmsg</var>)</dt>
- <dd>This routine accesses the data portion of the control message header
- <var class="Fa">cmsg</var>. It ensures proper alignment constraints on the
- beginning of ancillary data are met.</dd>
- <dt id="CMSG_FIRSTHDR"><a class="permalink" href="#CMSG_FIRSTHDR"><code class="Fn">CMSG_FIRSTHDR</code></a>(<var class="Fa">msghdr</var>)</dt>
- <dd>This routine accesses the first control message attached to the message
- <var class="Fa">msghdr</var>. If no control messages are attached to the
- message, this routine returns <code class="Dv">NULL</code>.</dd>
- <dt id="CMSG_LEN"><a class="permalink" href="#CMSG_LEN"><code class="Fn">CMSG_LEN</code></a>(<var class="Fa">len</var>)</dt>
- <dd>This routine determines the size in bytes of a control message, which
- includes the control message header. <var class="Fa">len</var> specifies
- the length of the data held by the control message. This value is what is
- normally stored in the <var class="Fa">cmsg_len</var> of each control
- message. This routine accounts for any alignment constraints on the
- beginning of ancillary data.</dd>
- <dt id="CMSG_NXTHDR"><a class="permalink" href="#CMSG_NXTHDR"><code class="Fn">CMSG_NXTHDR</code></a>(<var class="Fa">msghdr</var>,
- <var class="Fa">cmsg</var>)</dt>
- <dd>This routine returns the location of the control message following
- <var class="Fa">cmsg</var> in the message <var class="Fa">msghdr</var>. If
- <var class="Fa">cmsg</var> is the last control message in the chain, this
- routine returns <code class="Dv">NULL</code>.</dd>
- <dt id="CMSG_SPACE"><a class="permalink" href="#CMSG_SPACE"><code class="Fn">CMSG_SPACE</code></a>(<var class="Fa">len</var>)</dt>
- <dd>This routine determines the size in bytes needed to hold a control message
- and its contents of length <var class="Fa">len</var>, which includes the
- control message header. This value is what is normally stored in
- <var class="Fa">msg_msgcontrollen</var>. This routine accounts for any
- alignment constraints on the beginning of ancillary data as well as any
- needed to pad the next control message.</dd>
-</dl>
-</section>
-<section class="Sh">
-<h1 class="Sh" id="EXAMPLES"><a class="permalink" href="#EXAMPLES">EXAMPLES</a></h1>
-<p class="Pp">The following example constructs a control message containing a
- file descriptor in the parent process and passes it over a pre-shared socket
- over the child process. Then the child process sends a &quot;hello&quot;
- string to the parent process using the received file descriptor.</p>
-<div class="Bd Pp Li">
-<pre>#include &lt;sys/socket.h&gt;
-
-#include &lt;err.h&gt;
-#include &lt;stdio.h&gt;
-#include &lt;string.h&gt;
-#include &lt;sysexits.h&gt;
-#include &lt;unistd.h&gt;
-
-#define HELLOLEN sizeof(&quot;hello&quot;)
-
-int
-main()
-{
- struct msghdr msg;
- union {
- struct cmsghdr hdr;
- unsigned char buf[CMSG_SPACE(sizeof(int))];
- } cmsgbuf;
- char buf[HELLOLEN];
- int hellofd[2];
- int presharedfd[2];
- struct cmsghdr *cmsg;
-
- if (socketpair(PF_LOCAL, SOCK_STREAM, 0, presharedfd) == -1)
- err(EX_OSERR, &quot;failed to create a pre-shared socket pair&quot;);
-
- memset(&amp;msg, 0, sizeof(msg));
- msg.msg_control = &amp;cmsgbuf.buf;
- msg.msg_controllen = sizeof(cmsgbuf.buf);
- msg.msg_iov = NULL;
- msg.msg_iovlen = 0;
-
- switch (fork()) {
- case -1:
- err(EX_OSERR, &quot;fork&quot;);
- case 0:
- close(presharedfd[0]);
- strlcpy(buf, &quot;hello&quot;, HELLOLEN);
-
- if (recvmsg(presharedfd[1], &amp;msg, 0) == -1)
- err(EX_IOERR, &quot;failed to receive a message&quot;);
- if (msg.msg_flags &amp; (MSG_CTRUNC | MSG_TRUNC))
- errx(EX_IOERR, &quot;control message truncated&quot;);
- for (cmsg = CMSG_FIRSTHDR(&amp;msg); cmsg != NULL;
- cmsg = CMSG_NXTHDR(&amp;msg, cmsg)) {
- if (cmsg-&gt;cmsg_len == CMSG_LEN(sizeof(int)) &amp;&amp;
- cmsg-&gt;cmsg_level == SOL_SOCKET &amp;&amp;
- cmsg-&gt;cmsg_type == SCM_RIGHTS) {
- hellofd[1] = *(int *)CMSG_DATA(cmsg);
- printf(&quot;child: sending '%s'\n&quot;, buf);
- if (write(hellofd[1], buf, HELLOLEN) == -1)
- err(EX_IOERR, &quot;failed to send 'hello'&quot;);
- }
- }
- break;
- default:
- close(presharedfd[1]);
-
- if (socketpair(PF_LOCAL, SOCK_STREAM, 0, hellofd) == -1)
- err(EX_OSERR, &quot;failed to create a 'hello' socket pair&quot;);
-
- cmsg = CMSG_FIRSTHDR(&amp;msg);
- cmsg-&gt;cmsg_len = CMSG_LEN(sizeof(int));
- cmsg-&gt;cmsg_level = SOL_SOCKET;
- cmsg-&gt;cmsg_type = SCM_RIGHTS;
- *(int *)CMSG_DATA(cmsg) = hellofd[1];
-
- if (sendmsg(presharedfd[0], &amp;msg, 0) == -1)
- err(EX_IOERR, &quot;sendmsg&quot;);
- close(hellofd[1]);
-
- if (read(hellofd[0], buf, HELLOLEN) == -1)
- err(EX_IOERR, &quot;failed to receive 'hello'&quot;);
- printf(&quot;parent: received '%s'\n&quot;, buf);
- break;
- }
-
- return (0);
-}</pre>
-</div>
-</section>
-<section class="Sh">
-<h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
- ALSO</a></h1>
-<p class="Pp"><a class="Xr">recvmsg(2)</a>, <a class="Xr">sendmsg(2)</a>,
- <a class="Xr">socket(2)</a>, <a class="Xr">ip(4)</a>,
- <a class="Xr">ip6(4)</a>, <a class="Xr">unix(4)</a></p>
-</section>
-<section class="Sh">
-<h1 class="Sh" id="STANDARDS"><a class="permalink" href="#STANDARDS">STANDARDS</a></h1>
-<ul class="Bl-item">
- <li><cite class="Rs"><span class="RsA">W. Stevens</span> and
- <span class="RsA">M. Thomas</span>, <span class="RsT">Advanced Sockets API
- for IPv6</span>, <span class="RsR">RFC 2292</span>,
- <span class="RsD">February 1998</span>.</cite></li>
- <li><cite class="Rs"><span class="RsA">W. Stevens</span>, <span class="RsA">M.
- Thomas</span>, <span class="RsA">E. Nordmark</span>, and
- <span class="RsA">T. Jinmei</span>, <span class="RsT">Advanced Sockets
- Application Program Interface (API) for IPv6</span>, <span class="RsR">RFC
- 3542</span>, <span class="RsD">May 2003</span>.</cite></li>
-</ul>
-</section>
-<section class="Sh">
-<h1 class="Sh" id="HISTORY"><a class="permalink" href="#HISTORY">HISTORY</a></h1>
-<p class="Pp">The control message API first appeared in
- <span class="Ux">4.2BSD</span>. This manual page was originally written by
- <span class="An">Jared Yanovich</span>
- &lt;<a class="Mt" href="mailto:jaredy@OpenBSD.org">jaredy@OpenBSD.org</a>&gt;
- for <span class="Ux">OpenBSD 3.8</span> and eventually brought to
- <span class="Ux">FreeBSD 12.0</span> by <span class="An">Mateusz
- Piotrowski</span>
- &lt;<a class="Mt" href="mailto:0mp@FreeBSD.org">0mp@FreeBSD.org</a>&gt;.</p>
-</section>
-</div>
-<table class="foot">
- <tr>
- <td class="foot-date">March 13, 2020</td>
- <td class="foot-os">FreeBSD 15.0</td>
- </tr>
-</table>