libinetutil.h revision 2
2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. 2N/A * Contains SMI-private API for general Internet functionality 2N/A * Extended version of the classic BSD ifaddrlist() interface: 2N/A * int ifaddrlist(struct ifaddrlist **addrlistp, int af, uint_t flags, 2N/A * * addrlistp: Upon success, ifaddrlist() sets *addrlistp to a 2N/A * dynamically-allocated array of addresses. 2N/A * * af: Either AF_INET to obtain IPv4 addresses, or AF_INET6 to 2N/A * obtain IPv6 addresses. 2N/A * * flags: LIFC_* flags that control the classes of interfaces that 2N/A * * errbuf: A caller-supplied buffer of ERRBUFSIZE. Upon failure, 2N/A * provides the reason for the failure. 2N/A * Upon success, ifaddrlist() returns the number of addresses in the array 2N/A * pointed to by `addrlistp'. If the count is 0, then `addrlistp' is NULL. 2N/A * Similar to ifaddrlist(), but returns a linked-list of addresses for a 2N/A * *specific* interface name, and allows specific address flags to be matched 2N/A * against. A linked list is used rather than an array so that information 2N/A * can grow over time without affecting binary compatibility. Also, leaves 2N/A * error-handling up to the caller. Returns the number of ifaddrlistx's 2N/A * chained through ifaddrp. 2N/A * int ifaddrlistx(const char *ifname, uint64_t set, uint64_t clear, 2N/A * ifaddrlistx_t **ifaddrp); 2N/A * * ifname: Interface name to match against. 2N/A * * set: One or more flags that must be set on the address for 2N/A * it to be returned. 2N/A * * clear: Flags that must be clear on the address for it to be 2N/A * * ifaddrp: Upon success, ifaddrlistx() sets *ifaddrp to the head 2N/A * of a dynamically-allocated array of ifaddrlistx structures. 2N/A * Once done, the caller must free `ifaddrp' by calling ifaddrlistx_free(). 2N/A * timer queues are a facility for managing timeouts in unix. in the 2N/A * event driven model, unix provides us with poll(2)/select(3C), which 2N/A * allow us to coordinate waiting on multiple descriptors with an 2N/A * optional timeout. however, often (as is the case with the DHCP 2N/A * agent), we want to manage multiple independent timeouts (say, one 2N/A * for waiting for an OFFER to come back from a server in response to 2N/A * a DISCOVER sent out on one interface, and another for waiting for 2N/A * the T1 time on another interface). timer queues allow us to do 2N/A * this in the event-driven model. 2N/A * note that timer queues do not in and of themselves provide the 2N/A * event driven model (for instance, there is no handle_events() 2N/A * routine). they merely provide the hooks to support multiple 2N/A * independent timeouts. this is done for both simplicity and 2N/A * applicability (for instance, while one approach would be to use 2N/A * this timer queue with poll(2), another one would be to use SIGALRM 2N/A * to wake up periodically, and then process all the expired timers.) 2N/A * a iu_timer_id_t refers to a given timer. its value should not be 2N/A * interpreted by the interface consumer. it is a signed arithmetic 2N/A * type, and no valid iu_timer_id_t has the value `-1'. 2N/A * a iu_tq_callback_t is a function that is called back in response to a 2N/A * timer expiring. it may then carry out any necessary work, 2N/A * including rescheduling itself for callback or scheduling / 2N/A * cancelling other timers. the `void *' argument is the same value 2N/A * that was passed into iu_schedule_timer(), and if it is dynamically 2N/A * allocated, it is the callback's responsibility to know that, and to 2N/A * an event handler is an object-oriented "wrapper" for select(3C) / 2N/A * poll(2), aimed to make the event demultiplexing system calls easier 2N/A * to use and provide a generic reusable component. instead of 2N/A * applications directly using select(3C) / poll(2), they register 2N/A * events that should be received with the event handler, providing a 2N/A * callback function to call when the event occurs. they then call 2N/A * iu_handle_events() to wait and callback the registered functions 2N/A * when events occur. also called a `reactor'. 2N/A * an iu_event_id_t refers to a given event. its value should not be 2N/A * interpreted by the interface consumer. it is a signed arithmetic 2N/A * type, and no valid iu_event_id_t has the value `-1'. 2N/A * an iu_eh_callback_t is a function that is called back in response to 2N/A * an event occurring. it may then carry out any work necessary in 2N/A * response to the event. it receives the file descriptor upon which 2N/A * the event occurred, a bit array of events that occurred (the same 2N/A * array used as the revents by poll(2)), and its context through the 2N/A * `void *' that was originally passed into iu_register_event(). 2N/A * NOTE: the same descriptor may not be registered multiple times for 2N/A * different callbacks. if this behavior is desired, either use dup(2) 2N/A * to get a unique descriptor, or demultiplex in the callback function 2N/A * based on the events. 2N/A * soaf2str() provides numeric to string mapping of socket address family. 2N/A * Returns NULL if no mapping is found. 2N/A * proto2str() provides numeric to string mapping of IP protocol. 2N/A * Returns NULL if no mapping is found. 2N/A * sotype2str() provides numeric to string mapping of socket type. 2N/A * Returns NULL if no mapping is found. 2N/A#
endif /* !defined(_KERNEL) && !defined(_BOOT) */ 2N/A#
endif /* !_LIBINETUTIL_H */