Skip Navigation Links | |
Exit Print View | |
man pages section 3: Networking Library Functions Oracle Solaris 11.1 Information Library |
DNSServiceConstructFullName(3DNS_SD)
DNSServiceCreateConnection(3DNS_SD)
DNSServiceEnumerateDomains(3DNS_SD)
DNSServiceProcessResult(3DNS_SD)
DNSServiceQueryRecord(3DNS_SD)
DNSServiceReconfirmRecord(3DNS_SD)
DNSServiceRefDeallocate(3DNS_SD)
DNSServiceRegisterRecord(3DNS_SD)
DNSServiceRemoveRecord(3DNS_SD)
DNSServiceUpdateRecord(3DNS_SD)
gss_create_empty_oid_set(3GSS)
gss_inquire_cred_by_mech(3GSS)
gss_inquire_mechs_for_name(3GSS)
gss_inquire_names_for_mech(3GSS)
gss_process_context_token(3GSS)
ldap_enable_translation(3LDAP)
ldap_get_entry_controls(3LDAP)
ldap_get_lang_values_len(3LDAP)
ldap_init_getfilter_buf(3LDAP)
ldap_init_searchprefs_buf(3LDAP)
ldap_init_templates_buf(3LDAP)
ldap_parse_extended_result(3LDAP)
ldap_parse_sasl_bind_result(3LDAP)
ldap_sasl_interactive_bind_s(3LDAP)
ldap_set_string_translators(3LDAP)
ldap_translate_from_t61(3LDAP)
rpc_gss_get_principal_name(3NSL)
rpc_gss_svc_max_data_length(3NSL)
sasl_auxprop_add_plugin(3SASL)
sasl_canonuser_add_plugin(3SASL)
sasl_client_plug_init_t(3SASL)
sasl_server_plug_init_t(3SASL)
sasl_server_userdb_checkpass_t(3SASL)
sasl_server_userdb_setpass_t(3SASL)
sdp_add_connection(3COMMPUTIL)
sdp_add_information(3COMMPUTIL)
sdp_delete_all_field(3COMMPUTIL)
sdp_delete_all_media_field(3COMMPUTIL)
sdp_delete_attribute(3COMMPUTIL)
sdp_find_attribute(3COMMPUTIL)
sdp_find_media_rtpmap(3COMMPUTIL)
sdp_session_to_str(3COMMPUTIL)
sip_create_dialog_req_nocontact(3SIP)
sip_delete_header_by_name(3SIP)
sip_disable_dialog_logging(3SIP)
sip_disable_trans_logging(3SIP)
sip_enable_dialog_logging(3SIP)
sip_enable_trans_logging(3SIP)
sip_get_contact_display_name(3SIP)
sip_get_content_sub_type(3SIP)
sip_get_dialog_local_contact_uri(3SIP)
sip_get_dialog_local_cseq(3SIP)
sip_get_dialog_local_tag(3SIP)
sip_get_dialog_local_uri(3SIP)
sip_get_dialog_remote_cseq(3SIP)
sip_get_dialog_remote_tag(3SIP)
sip_get_dialog_remote_target_uri(3SIP)
sip_get_dialog_remote_uri(3SIP)
sip_get_dialog_route_set(3SIP)
sip_get_from_display_name(3SIP)
sip_get_passertedid_display_name(3SIP)
sip_get_passertedid_uri_str(3SIP)
sip_get_ppreferredid_display_name(3SIP)
sip_get_ppreferredid_uri_str(3SIP)
sip_get_proxy_authen_param(3SIP)
sip_get_proxy_authen_scheme(3SIP)
sip_get_proxy_author_param(3SIP)
sip_get_proxy_author_scheme(3SIP)
sip_get_replyto_display_name(3SIP)
sip_get_retry_after_cmts(3SIP)
sip_get_retry_after_time(3SIP)
sip_get_route_display_name(3SIP)
sip_get_via_sent_by_host(3SIP)
sip_get_via_sent_by_port(3SIP)
sip_get_via_sent_protocol_name(3SIP)
sip_get_via_sent_protocol_version(3SIP)
sip_get_via_sent_transport(3SIP)
sip_get_www_authen_param(3SIP)
sip_get_www_authen_scheme(3SIP)
sip_unregister_all_sent_by(3SIP)
- get network entry
cc [ flag ... ] file ... -lsocket -lnsl [ library ... ] #include <netdb.h> struct netent *getnetbyname(const char *name);
struct netent *getnetbyname_r(const char *name, struct netent *result, char *buffer, int buflen);
struct netent *getnetbyaddr(long net, int type);
struct netent *getnetbyaddr_r(long net, int type, struct netent *result, char *buffer, int buflen);
struct netent *getnetent(void);
struct netent *getnetent_r(struct netent *result, char *buffer, int buflen);
int setnetent(int stayopen);
int endnetent(void);
These functions are used to obtain entries for networks. An entry may come from any of the sources for networks specified in the /etc/nsswitch.conf file. See nsswitch.conf(4).
getnetbyname() searches for a network entry with the network name specified by the character string parameter name.
getnetbyaddr() searches for a network entry with the network address specified by net. The parameter type specifies the family of the address. This should be one of the address families defined in <sys/socket.h>. See the NOTES section below for more information.
Network numbers and local address parts are returned as machine format integer values, that is, in host byte order. See also inet(3SOCKET).
The netent.n_net member in the netent structure pointed to by the return value of the above functions is calculated by inet_network(). The inet_network() function returns a value in host byte order that is aligned based upon the input string. For example:
|
Commonly, the alignment of the returned value is used as a crude approximate of pre-CIDR (Classless Inter-Domain Routing) subnet mask. For example:
in_addr_t addr, mask; addr = inet_network(net_name); mask= ~(in_addr_t)0; if ((addr & IN_CLASSA_NET) == 0) addr <<= 8, mask <<= 8; if ((addr & IN_CLASSA_NET) == 0) addr <<= 8, mask <<= 8; if ((addr & IN_CLASSA_NET) == 0) addr <<= 8, mask <<= 8;
This usage is deprecated by the CIDR requirements. See Fuller, V., Li, T., Yu, J., and Varadhan, K. RFC 1519, Classless Inter-Domain Routing (CIDR): an Address Assignment and Aggregation Strategy. Network Working Group. September 1993.
The functions setnetent(), getnetent(), and endnetent() are used to enumerate network entries from the database.
setnetent() sets (or resets) the enumeration to the beginning of the set of network entries. This function should be called before the first call to getnetent(). Calls to getnetbyname() and getnetbyaddr() leave the enumeration position in an indeterminate state. If the stayopen flag is non-zero, the system may keep allocated resources such as open file descriptors until a subsequent call to endnetent().
Successive calls to getnetent() return either successive entries or NULL, indicating the end of the enumeration.
endnetent() may be called to indicate that the caller expects to do no further network entry retrieval operations; the system may then deallocate resources it was using. It is still allowed, but possibly less efficient, for the process to call more network entry retrieval functions after calling endnetent().
The functions getnetbyname(), getnetbyaddr(), and getnetent() use static storage that is reused in each call, making these routines unsafe for use in multi-threaded applications.
The functions getnetbyname_r(), getnetbyaddr_r(), and getnetent_r() provide reentrant interfaces for these operations.
Each reentrant interface performs the same operation as its non-reentrant counterpart, named by removing the ``_r'' suffix. The reentrant interfaces, however, use buffers supplied by the caller to store returned results, and are safe for use in both single-threaded and multi-threaded applications.
Each reentrant interface takes the same parameters as its non-reentrant counterpart, as well as the following additional parameters. The parameter result must be a pointer to a struct netent structure allocated by the caller. On successful completion, the function returns the network entry in this structure. The parameter buffer must be a pointer to a buffer supplied by the caller. This buffer is used as storage space for the network entry data. All of the pointers within the returned struct netent result point to data stored within this buffer. See RETURN VALUES. The buffer must be large enough to hold all of the data associated with the network entry. The parameter buflen should give the size in bytes of the buffer indicated by buffer.
For enumeration in multi-threaded applications, the position within the enumeration is a process-wide property shared by all threads. setnetent() may be used in a multi-threaded application but resets the enumeration position for all threads. If multiple threads interleave calls to getnetent_r(), the threads will enumerate disjointed subsets of the network database.
Like their non-reentrant counterparts, getnetbyname_r() and getnetbyaddr_r() leave the enumeration position in an indeterminate state.
Network entries are represented by the struct netent structure defined in <netdb.h>.
The functions getnetbyname(), getnetbyname_r, getnetbyaddr, and getnetbyaddr_r() each return a pointer to a struct netent if they successfully locate the requested entry; otherwise they return NULL.
The functions getnetent() and getnetent_r() each return a pointer to a struct netent if they successfully enumerate an entry; otherwise they return NULL, indicating the end of the enumeration.
The functions getnetbyname(), getnetbyaddr(), and getnetent() use static storage, so returned data must be copied before a subsequent call to any of these functions if the data is to be saved.
When the pointer returned by the reentrant functions getnetbyname_r(), getnetbyaddr_r(), and getnetent_r() is non-NULL, it is always equal to the result pointer that was supplied by the caller.
The functions setnetent() and endnetent() return 0 on success.
The reentrant functions getnetbyname_r(), getnetbyaddr_r and getnetent_r() will return NULL and set errno to ERANGE if the length of the buffer supplied by caller is not large enough to store the result. See Intro(2) for the proper usage and interpretation of errno in multi-threaded applications.
network name database
configuration file for the name service switch
See attributes(5) for descriptions of the following attributes:
|
Intro(2), Intro(3), byteorder(3SOCKET), inet(3SOCKET), netdb.h(3HEAD), networks(4), nsswitch.conf(4), attributes(5)
Fuller, V., Li, T., Yu, J., and Varadhan, K. RFC 1519, Classless Inter-Domain Routing (CIDR): an Address Assignment and Aggregation Strategy. Network Working Group. September 1993.
The reentrant interfaces getnetbyname_r(), getnetbyaddr_r(), and getnetent_r() are included in this release on an uncommitted basis only, and are subject to change or removal in future minor releases.
The current implementation of these functions only return or accept network numbers for the Internet address family (type AF_INET). The functions described in inet(3SOCKET) may be helpful in constructing and manipulating addresses and network numbers in this form.
When compiling multi-threaded applications, see Intro(3), Notes On Multithread Applications, for information about the use of the _REENTRANT flag.
Use of the enumeration interfaces getnetent() and getnetent_r() is discouraged; enumeration may not be supported for all database sources. The semantics of enumeration are discussed further in nsswitch.conf(4).