> We define the following flag bits, indicating which protocol (instead of
> socket type) to be used for getservbyport(3) lookup. We also define
> NI_DGRAM to be same as NI_UDP for backward compatibility. Note that the
> value of NI_UDP has to be the same as NI_DGRAM in the past
> implementation, for backward compatibility reasons.
>
> #define NI_TCP 0x100 /* the value can vary by implementation */
> #define NI_UDP 0x200 /* the value can vary by implementation */
> #define NI_DCCP 0x400 /* the value can vary by implementation */
> #define NI_SCTP 0x800 /* the value can vary by implementation */
>
> #define NI_DGRAM NI_UDP
>
> If multiple bits are specified (such as NI_UDP | NI_DCCP),
> getnameinfo(3) should raise EAI_BADFLAGS error.
This sort of statement usually indicates a design fault.
Better would be to have a field, with mask and potential values. Thus:
#define NI_PROTOCOL 0x600 /* The value can vary by implementation */
#define NI_TCP 0x000 /* Must have this value, see below */
#define NI_UDP 0x200 /* These may have any value V so long as: */
#define NI_DCCP 0x400 /* * V != 0 */
#define NI_SCTP 0x600 /* * (V & NI_PROTOCOL) == V */
/* * all the NI_ values are different */
#define NI_DGRAM NI_UDP
Forcing NI_TCP to be zero means that:
> If no flag bits are
> specified, getnameinfo(3) should treat it as NI_TCP for backward
> compatibility.
is implicit. Since there are only 4 protocols, NI_PROTOCOL only needs to
have two bits set, but of course an implementation can happily have more
than that when it has additional protocols (or even without them).
--
Clive D.W. Feather | Work: <yyyyy@xxxxxxxxx> | Tel: +44 20 8495 6138
Internet Expert | Home: <yyyyy@xxxxxxxxxx> | Fax: +44 870 051 9937
Demon Internet | WWW: http://www.davros.org | Mobile: +44 7973 377646
Thus plc | |
|