diff options
| author | Jacob McDonnell <jacob@jacobmcdonnell.com> | 2026-04-25 19:59:05 -0400 |
|---|---|---|
| committer | Jacob McDonnell <jacob@jacobmcdonnell.com> | 2026-04-25 19:59:05 -0400 |
| commit | 1f19f33e45791ea59aed048796fc68672c6723a5 (patch) | |
| tree | 54625fba89e91d1c2177801ec635e8528bba937f /static/freebsd/man3/CMSG_DATA.3 3.html | |
| parent | ac5e55f5f2af5b92794c2aded46c6bae85b5f5ed (diff) | |
docs: Removed Precompiled HTML
Diffstat (limited to 'static/freebsd/man3/CMSG_DATA.3 3.html')
| -rw-r--r-- | static/freebsd/man3/CMSG_DATA.3 3.html | 211 |
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> - — <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 - <<a class="In">sys/socket.h</a>></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 "hello" - string to the parent process using the received file descriptor.</p> -<div class="Bd Pp Li"> -<pre>#include <sys/socket.h> - -#include <err.h> -#include <stdio.h> -#include <string.h> -#include <sysexits.h> -#include <unistd.h> - -#define HELLOLEN sizeof("hello") - -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, "failed to create a pre-shared socket pair"); - - memset(&msg, 0, sizeof(msg)); - msg.msg_control = &cmsgbuf.buf; - msg.msg_controllen = sizeof(cmsgbuf.buf); - msg.msg_iov = NULL; - msg.msg_iovlen = 0; - - switch (fork()) { - case -1: - err(EX_OSERR, "fork"); - case 0: - close(presharedfd[0]); - strlcpy(buf, "hello", HELLOLEN); - - if (recvmsg(presharedfd[1], &msg, 0) == -1) - err(EX_IOERR, "failed to receive a message"); - if (msg.msg_flags & (MSG_CTRUNC | MSG_TRUNC)) - errx(EX_IOERR, "control message truncated"); - for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; - cmsg = CMSG_NXTHDR(&msg, cmsg)) { - if (cmsg->cmsg_len == CMSG_LEN(sizeof(int)) && - cmsg->cmsg_level == SOL_SOCKET && - cmsg->cmsg_type == SCM_RIGHTS) { - hellofd[1] = *(int *)CMSG_DATA(cmsg); - printf("child: sending '%s'\n", buf); - if (write(hellofd[1], buf, HELLOLEN) == -1) - err(EX_IOERR, "failed to send 'hello'"); - } - } - break; - default: - close(presharedfd[1]); - - if (socketpair(PF_LOCAL, SOCK_STREAM, 0, hellofd) == -1) - err(EX_OSERR, "failed to create a 'hello' socket pair"); - - cmsg = CMSG_FIRSTHDR(&msg); - cmsg->cmsg_len = CMSG_LEN(sizeof(int)); - cmsg->cmsg_level = SOL_SOCKET; - cmsg->cmsg_type = SCM_RIGHTS; - *(int *)CMSG_DATA(cmsg) = hellofd[1]; - - if (sendmsg(presharedfd[0], &msg, 0) == -1) - err(EX_IOERR, "sendmsg"); - close(hellofd[1]); - - if (read(hellofd[0], buf, HELLOLEN) == -1) - err(EX_IOERR, "failed to receive 'hello'"); - printf("parent: received '%s'\n", 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> - <<a class="Mt" href="mailto:jaredy@OpenBSD.org">jaredy@OpenBSD.org</a>> - 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> - <<a class="Mt" href="mailto:0mp@FreeBSD.org">0mp@FreeBSD.org</a>>.</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> |
