⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 t_optmgmt.html

📁 unix 下的C开发手册,还用详细的例程。
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>t_optmgmt</title></head><body bgcolor=white><center><font size=2>The Single UNIX &reg; Specification, Version 2<br>Copyright &copy; 1997 The Open Group</font></center><hr size=2 noshade><xref type="10" name="optmgmt"></xref><h4>NAME</h4><blockquote>t_optmgmt - manage options for a transport endpoint</blockquote><h4>SYNOPSIS</h4><blockquote><pre><code>#include &lt;<a href="xti.h.html">xti.h</a>&gt;int t_optmgmt(    int fd,    const struct t_optmgmt *req,    struct t_optmgmt *ret)</code></pre></blockquote><h4>DESCRIPTION</h4><blockquote><pre><P><table  bordercolor=#000000 border=1 align=center><tr valign=top><th align=center><b>Parameters</b><th align=center><b>Before call</b><th align=center><b>After call</b><tr valign=top><td align=left>fd<td align=center>x<td align=center>/<tr valign=top><td align=left>req-&gt;opt.maxlen<td align=center>=<td align=center>=<tr valign=top><td align=left>req-&gt;opt.len<td align=center>x<td align=center>=<tr valign=top><td align=left>req-&gt;opt.buf<td align=center>x (x)<td align=center>=<tr valign=top><td align=left>req-&gt;flags<td align=center>x<td align=center>=<tr valign=top><td align=left>ret-&gt;opt.maxlen<td align=center>x<td align=center>=<tr valign=top><td align=left>ret-&gt;opt.len<td align=center>/<td align=center>x<tr valign=top><td align=left>ret-&gt;opt.buf<td align=center>?<td align=center>(?)<tr valign=top><td align=left>ret-&gt;flags<td align=center>/<td align=center>x</table></pre><p>The<i>t_optmgmt()</i>function enables a transport user to retrieve,verify or negotiate protocol options with the transport provider.The argument<I>fd</I>identifies a transport endpoint.<p>The<I>req</I>and<I>ret</I>arguments point to a<B>t_optmgmt</B>structure containing the following members:<pre><code>struct      netbuf opt;t_scalar_t  flags;</code></pre><p>The<I>opt</I>field identifies protocol optionsand the<I>flags</I>field is used to specify the action to take with those options.<p>The options are represented by a<B>netbuf</B>structurein a manner similar to the address in<i><a href="t_bind.html">t_bind()</a></i>.The argument<I>req</I>is used to request a specific action of the provider and to send optionsto the provider.  The argument<I>len</I>specifies the number of bytes in the options,<I>buf</I>points to the options buffer, and<I>maxlen</I>has no meaning for the<I>req</I>argument.The transport provider may return options and flag values to theuser through<I>ret</I>.For<I>ret</I>,<I>maxlen</I>specifies the maximum size of the options buffer and<I>buf</I>points to the buffer where the options are to be placed.If <I>maxlen</I>in <I>ret</I>is set to zero, no options values are returned.On return,<I>len</I>specifies the number of bytes of options returned.The value in<I>maxlen</I>has no meaning for the<I>req</I>argument, but must be set in the<I>ret</I>argument to specify the maximum number of bytes the options buffer can hold.<p>Each option in the options buffer is of the form<B>struct t_opthdr</B>possibly followed by an option value.<p>The<I>level</I>field of<B>struct t_opthdr</B>identifies the XTI level or a protocol of the transport provider.The<I>name</I>field identifies the option within the level, and<I>len</I>contains itstotal length; that is, the length of the option header<B>t_opthdr</B>plus the length of the option value.  If<i>t_optmgmt()</i>is called with the action T_NEGOTIATE set, the<I>status</I>field of the returned optionscontains information about the success or failure of a negotiation.<p>Several options can be concatenated. The option user has, however toensure that each options header and value part starts at a boundaryappropriate for the architecture-specific alignment rules. ThemacrosT_OPT_FIRSTHDR(nbp), T_OPT_NXTHDR(nbp, tohp), T_OPT_DATA(tohp)are provided for that purpose.<dl compact><dt>T_OPT_DATA<dd>If argument is a pointer to a<B>t_opthdr</B>structure, this macro returns an unsigned character pointerto the data associated with the<B>t_opthdr</B>.<dt>T_OPT_NXTHDR<dd>If the first argument is a pointer to anetbuf structure associated with an optionbuffer and second argument is a pointer to a<B>t_opthdr</B>structure within that option buffer,this macro returns a pointer to the next<B>t_opthdr</B>structure or a null pointer if this<B>t_opthdr</B>is the last<B>t_opthdr</B>in the option buffer.<dt>T_OPT_FIRSTHDR<dd>If the argument is a pointer to a<B>netbuf</B>structure associated with an optionbuffer, this macro returns the pointer to the first<B>t_opthdr</B>structure in the associatedoption buffer, or a null pointer if there isno option buffer associated with this<B>netbuf</B>or if it is not possible or the associatedoption buffer is too small to accommodateeven the first aligned option header.</dl><p>T_OPT_FIRSTHDR is useful for findingan appropriately aligned start of the option buffer.T_OPT_NEXTHDR is useful for moving to the startof the next appropriately alignedoption in the option buffer. Note thatOPT_NEXTHDR is also available for backward compatibilityrequirements. T_OPT_DATA is useful for finding the start ofthe data part in the option buffer where the contents of itsvalues start on an appropriately aligned boundary.<p>If the transport user specifies several options on input, all optionsmust address the same level.<p>If any option in the options buffer does not indicate the samelevel as the first option, or the level specified is unsupported,then the<i>t_optmgmt()</i>request will fail with [TBADOPT].If the error is detected, some options have possibly been successfullynegotiated.The transport user can check the current status by calling<i>t_optmgmt()</i>with the T_CURRENT flag set.<p><xref href=chap5></xref>contains a detailed description about the use of optionsand should be read before using this function.<p>The<I>flags</I>field of<I>req</I>must specify one of the following actions:<dl compact><dt>T_NEGOTIATE<dd>This action enables the transport user to negotiate option values.The user specifies the options of interest and their values in the bufferspecified by<I>req-&gt;opt.buf</I>and<I>req-&gt;opt.len</I>.The negotiated option values are returned in the buffer pointed to by<I>ret-&gt;opt.buf</I>.The<I>status</I>field of each returned option is set to indicate the result of thenegotiation.The value is T_SUCCESS if the proposed value was negotiated,T_PARTSUCCESS if a degraded value was negotiated, T_FAILURE if thenegotiation failed (according to the negotiation rules), T_NOTSUPPORT ifthe transport provider does not support this option or illegally requestsnegotiation of a privileged option, and T_READONLY if modification of aread-only option was requested.If the status is T_SUCCESS, T_FAILURE, T_NOTSUPPORT or T_READONLY,the returned option value is the same as the one requested on input.The overall result of the negotiation is returned in<I>ret-&gt;flags</I>.This field contains the worst single result, whereby the rating is doneaccording to the order T_NOTSUPPORT, T_READONLY, T_FAILURE, T_PARTSUCCESS,T_SUCCESS.The value T_NOTSUPPORT is the worst result and T_SUCCESS is the best.For each level, the option T_ALLOPT (see below) can be requested on input.No value is given with this option; only the<B>t_opthdr</B>part is specified.This input requests to negotiate all supported optionsof this level to their default values.The result is returned option by option in<I>ret-&gt;opt.buf</I>.(Note that depending on the state of the transport endpoint, not allrequests to negotiate the default value may be successful.)<dt>T_CHECK<dd>This action enables the user to verify whether the options specified in<I>req</I>are supported by the transport provider.If an option is specified with no option value (it consists only of a<B>t_opthdr</B>structure), the option is returned with its<I>status</I>field set to T_SUCCESS ifit is supported, T_NOTSUPPORT if it is not or needs additional userprivileges, and T_READONLY if it is read-only (in the current XTI state).No option value is returned.If an option is specified with an option value, the<I>status</I>field of the returned option has the same value, as if the user hadtried to negotiate this value with T_NEGOTIATE.If the status is T_SUCCESS, T_FAILURE, T_NOTSUPPORT or T_READONLY, thereturned option value is the same as the one requested on input.The overall result of the option checks is returned in<I>ret-&gt;flags</I>.This field contains the worst single result of the option checks, whereby therating is the same as for T_NEGOTIATE.Note that no negotiation takes place.All currently effective option values remain unchanged.<dt>T_DEFAULT<dd>This action enables the transport user to retrieve the default optionvalues.The user specifies the options of interest in<I>req-&gt;opt.buf</I>.The option values are irrelevant and will be ignored;it is sufficient to specify the<B>t_opthdr</B>part of an option only.The default values are then returned in<I>ret-&gt;opt.buf</I>.The <I>status</I> field returned is T_NOTSUPPORT if the protocollevel does not support this option or the transport user illegallyrequested a privileged option, T_READONLY if the option is read-only,and set to T_SUCCESS in all other cases.The overall result of the request is returned in<I>ret-&gt;flags</I>.This field contains the worst single result, whereby the rating is thesame as for T_NEGOTIATE.For each level, the option T_ALLOPT (see below) can be requested on input.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -