inline int arg_count ()
| arg_count |
#include <c_format.hh>
template <class A>
inline int arg_count (A)
| arg_count |
#include <c_format.hh>
template <class A, class B>
inline int arg_count (A,B)
| arg_count |
#include <c_format.hh>
template <class A, class B, class C>
inline int arg_count (A,B,C)
| arg_count |
#include <c_format.hh>
template <class A, class B, class C, class D>
inline int arg_count (A,B,C,D)
| arg_count |
#include <c_format.hh>
template <class A, class B, class C, class D, class E>
inline int arg_count (A,B,C,D,E)
| arg_count |
#include <c_format.hh>
template <class A, class B, class C,class D, class E, class F>
inline int arg_count (A,B,C,D,E,F)
| arg_count |
#include <c_format.hh>
template <class A, class B, class C, class D, class E, class F, class G>
inline int arg_count (A,B,C,D,E,F,G)
| arg_count |
#include <c_format.hh>
template <class A, class B, class C, class D, class E, class F, class G,
class H>
inline int arg_count (A,B,C,D,E,F,G,H)
| arg_count |
#include <c_format.hh>
template <class A, class B, class C, class D, class E, class F, class G,
class H, class I>
inline int arg_count (A,B,C,D,E,F,G,H,I)
| arg_count |
#include <c_format.hh>
template <class A, class B, class C, class D, class E, class F, class G,
class H, class I, class J>
inline int arg_count (A,B,C,D,E,F,G,H,I,J)
| arg_count |
#include <c_format.hh>
template <class A, class B, class C, class D, class E, class F, class G,
class H, class I, class J, class K>
inline int arg_count (A,B,C,D,E,F,G,H,I,J,K)
| arg_count |
#include <c_format.hh>
template <class A, class B, class C, class D, class E, class F, class G,
class H, class I, class J, class K, class L>
inline int arg_count (A,B,C,D,E,F,G,H,I,J,K,L)
| arg_count |
#include <c_format.hh>
template <class A, class B, class C, class D, class E, class F, class G,
class H, class I, class J, class K, class L, class M>
inline int arg_count (A,B,C,D,E,F,G,H,I,J,K,L,M)
| arg_count |
#include <c_format.hh>
template <class A, class B, class C, class D, class E, class F, class G,
class H, class I, class J, class K, class L, class M, class N>
inline int arg_count (A,B,C,D,E,F,G,H,I,J,K,L,M,N)
| arg_count |
#include <c_format.hh>
void c_format_validate (const char* fmt, int n)
| c_format_validate |
#include <c_format.hh>
string do_c_format (const char* fmt, ...)
| do_c_format |
#include <c_format.hh>
enum { DAEMON_CHDIR = 0, DAEMON_NOCHDIR = 1, DAEMON_CLOSE = 0, DAEMON_NOCLOSE = 1 } |
#include <daemon.h>
int xorp_daemonize (int nochdir, int noclose)
| xorp_daemonize |
#include <daemon.h>
A local implementation of daemon(3).
Fork a new process and detach from parent in a controlled way, allowing XORP processes to run as UNIX daemons. Uses the POSIX setsid() to detach from the controlling terminal.
The parent SHOULD use the platform _exit() function to exit.
This function is a no-op under Microsoft Windows.
Parameters:
nochdir | set to 0 if the process should chdir to / once detached. |
noclose | set to 0 if the process should close |
Returns: -1 if any error occurred, 0 if we are in the child process, otherwise the return value is the child process ID.
inline void swallow_args (const char*)
| swallow_args |
#include <debug.h>
template <class A>
inline void swallow_args (const char*, A)
| swallow_args |
#include <debug.h>
template <class A, class B>
inline void swallow_args (const char*, A, B)
| swallow_args |
#include <debug.h>
template <class A, class B, class C>
inline void swallow_args (const char*, A, B, C)
| swallow_args |
#include <debug.h>
template <class A, class B, class C, class D>
inline void swallow_args (const char*, A, B, C, D)
| swallow_args |
#include <debug.h>
template <class A, class B, class C, class D, class E>
inline void swallow_args (const char*, A, B, C, D, E)
| swallow_args |
#include <debug.h>
template <class A, class B, class C, class D, class E, class F>
inline void swallow_args (const char*, A, B, C, D, E, F)
| swallow_args |
#include <debug.h>
template <class A, class B, class C, class D, class E, class F, class G>
inline void swallow_args (const char*, A, B, C, D, E, F, G)
| swallow_args |
#include <debug.h>
template <class A, class B, class C, class D, class E, class F, class G, class H>
inline void swallow_args (const char*, A, B, C, D, E, F, G, H)
| swallow_args |
#include <debug.h>
template <class A, class B, class C, class D, class E, class F, class G, class H, class I>
inline void swallow_args (const char*, A, B, C, D, E, F, G, H, I)
| swallow_args |
#include <debug.h>
template <class A, class B, class C, class D, class E, class F, class G, class H, class I, class J>
inline void swallow_args (const char*, A, B, C, D, E, F, G, H, I, J)
| swallow_args |
#include <debug.h>
template <class A, class B, class C, class D, class E, class F, class G, class H, class I, class J, class K>
inline void swallow_args (const char*, A, B, C, D, E, F, G, H, I, J, K)
| swallow_args |
#include <debug.h>
template <class A, class B, class C, class D, class E, class F, class G, class H, class I, class J, class K, class L>
inline void swallow_args (const char*, A, B, C, D, E, F, G, H, I, J, K, L)
| swallow_args |
#include <debug.h>
inline void
check_args (const char*, ...)
| check_args |
#include <debug.h>
void xorp_catch_standard_exceptions ()
| xorp_catch_standard_exceptions |
#include <exceptions.hh>
Print diagnostic message if exception is derived from XorpException or from standard exceptions, and terminate the program.
void xorp_print_standard_exceptions ()
| xorp_print_standard_exceptions |
#include <exceptions.hh>
Print diagnostic message if exception is derived from XorpException or from standard exceptions.
Note that unlike xorp_catch_standard_exceptions(), the program does NOT terminate.
void xorp_unexpected_handler ()
| xorp_unexpected_handler |
#include <exceptions.hh>
Unexpected exceptions are programming errors and this handler can be installed with XorpUnexpectedHandler to print out as much information as possible. The default behaviour is just to dump core, but it very hard to detect what happened.
enum IoEventType { IOT_READ, IOT_WRITE, IOT_EXCEPTION, IOT_ACCEPT, IOT_CONNECT, IOT_DISCONNECT, IOT_ANY } | IoEventType |
#include <ioevents.hh>
Enumeration of various event types supported by the I/O callback facade.
typedef XorpCallback2<void,XorpFd,IoEventType>::RefPtr IoEventCb | IoEventCb |
#include <ioevents.hh>
template <class A> uint32_t
overlap (const IPNet<A>& a1, const IPNet<A>& a2)
| overlap |
#include <ipnet.hh>
Determine the number of the most significant bits overlapping between two subnets.
Parameters:
a1 | the first subnet. |
a2 | the subnet. |
Returns: the number of bits overlapping between a1 and a2.
typedef IPNet<IPv4> IPv4Net | IPv4Net |
#include <ipv4net.hh>
typedef IPNet<IPv6> IPv6Net | IPv6Net |
#include <ipv6net.hh>
inline size_t
family2addr_bytelen (const int family)
| family2addr_bytelen |
#include <ipvx.hh>
inline uint32_t
family2addr_bitlen (const int family)
| family2addr_bitlen |
#include <ipvx.hh>
typedef IPNet<IPvX> BaseIPvXNet | BaseIPvXNet |
#include <ipvxnet.hh>
Base IPvXNet just has IPNet methods. IPvXNet is derived from BaseIPvXNet and has IPvX specific functions such as whether contained type is an IPv4 network or an IPv6 network.
See IPNet for available methods.
inline bool
operator== (const Mac& m1, const Mac& m2)
| operator== |
#include <mac.hh>
The multicast bit in the first octet of the address.
inline bool
operator== (const EtherMac& m1, const EtherMac& m2)
| operator== |
#include <mac.hh>
typedef IPNextHop<IPv4> IPv4NextHop | IPv4NextHop |
#include <nexthop.hh>
typedef IPNextHop<IPv6> IPv6NextHop | IPv6NextHop |
#include <nexthop.hh>
typedef IPNextHop<IPvX> IPvXNextHop | IPvXNextHop |
#include <nexthop.hh>
typedef IPPeerNextHop<IPv4> IPv4PeerNextHop | IPv4PeerNextHop |
#include <nexthop.hh>
typedef IPPeerNextHop<IPv6> IPv6PeerNextHop | IPv6PeerNextHop |
#include <nexthop.hh>
typedef IPPeerNextHop<IPvX> IPvXPeerNextHop | IPvXPeerNextHop |
#include <nexthop.hh>
typedef IPEncapsNextHop<IPv4> IPv4EncapsNextHop | IPv4EncapsNextHop |
#include <nexthop.hh>
typedef IPEncapsNextHop<IPv6> IPv6EncapsNextHop | IPv6EncapsNextHop |
#include <nexthop.hh>
typedef IPEncapsNextHop<IPvX> IPvXEncapsNextHop | IPvXEncapsNextHop |
#include <nexthop.hh>
typedef IPExternalNextHop<IPv4> IPv4ExternalNextHop | IPv4ExternalNextHop |
#include <nexthop.hh>
typedef IPExternalNextHop<IPv6> IPv6ExternalNextHop | IPv6ExternalNextHop |
#include <nexthop.hh>
typedef IPExternalNextHop<IPvX> IPvXExternalNextHop | IPvXExternalNextHop |
#include <nexthop.hh>
pid_t popen2 (const string& command, const list<string>& arguments,
FILE *& outstream, FILE *& errstream,
bool redirect_stderr_to_stdout)
| popen2 |
#include <popen.hh>
int pclose2 (FILE *iop_out, bool dont_wait)
| pclose2 |
#include <popen.hh>
int popen2_mark_as_closed (pid_t pid, int wait_status)
| popen2_mark_as_closed |
#include <popen.hh>
HANDLE pgethandle (pid_t pid)
| pgethandle |
#include <popen.hh>
long xorp_random (void)
| xorp_random |
#include <random.h>
void xorp_srandom (unsigned long)
| xorp_srandom |
#include <random.h>
char* xorp_initstate (unsigned long, char *, long)
| xorp_initstate |
#include <random.h>
char* xorp_setstate (char *)
| xorp_setstate |
#include <random.h>
void xorp_srandomdev (void)
| xorp_srandomdev |
#include <random.h>
inline bool operator== (const uint32_t& lhs, const U32Range& rhs)
| operator== |
#include <range.hh>
Equality Operator for uint32_t against U32Range operand.
Parameters:
lhs | the left-hand uint32_t type operand. |
rhs | the right-hand U32Range operand. |
Returns: true if the value of the left-hand operand falls inside the range defined by the right-hand operand.
inline bool operator!= (const uint32_t& lhs, const U32Range& rhs)
| operator!= |
#include <range.hh>
Non-equality Operator for uint32_t against U32Range operand.
Parameters:
lhs | the left-hand uint32_t type operand. |
rhs | the right-hand U32Range operand. |
Returns: true if the value of the left-hand operand falls outside the range defined by the right-hand operand.
inline bool operator< (const uint32_t& lhs, const U32Range& rhs)
| operator< |
#include <range.hh>
Less-than comparison for uint32_t against U32Range operand.
Parameters:
lhs | the left-hand uint32_t type operand. |
rhs | the right-hand U32Range operand. |
Returns: true if the value of the left-hand operand is bellow the range defined by the right-hand operand.
inline bool operator<= (const uint32_t& lhs, const U32Range& rhs)
| operator<= |
#include <range.hh>
Less-than or equal comparison for uint32_t against U32Range
Parameters:
lhs | the left-hand uint32_t type operand. |
rhs | the right-hand U32Range operand. |
Returns: true if the value of the left-hand operand is bellow or within the range defined by the right-hand operand.
inline bool operator> (const uint32_t& lhs, const U32Range& rhs)
| operator> |
#include <range.hh>
Greater-than comparison for uint32_t against U32Range operand.
Parameters:
lhs | the left-hand uint32_t type operand. |
rhs | the right-hand U32Range operand. |
Returns: true if the value of the left-hand operand is above the range defined by the right-hand operand.
inline bool operator>= (const uint32_t& lhs, const U32Range& rhs)
| operator>= |
#include <range.hh>
Greater-than or equal comparison for uint32_t against U32Range
Parameters:
lhs | the left-hand uint32_t type operand. |
rhs | the right-hand U32Range operand. |
Returns: true if the value of the left-hand operand is above or within the range defined by the right-hand operand.
typedef IPvXRange<IPv4> IPv4Range | IPv4Range |
#include <range.hh>
typedef IPvXRange<IPv6> IPv6Range | IPv6Range |
#include <range.hh>
enum SelectorMask { SEL_NONE = 0x0, SEL_RD = 0x01, SEL_WR = 0x02, SEL_EX = 0x04, SEL_ALL = SEL_RD | SEL_WR | SEL_EX } | SelectorMask |
#include <selector.hh>
typedef ref_ptr<SelectorTag> Selector | Selector |
#include <selector.hh>
enum ServiceStatus { SERVICE_READY = 0x001, SERVICE_STARTING = 0x002, SERVICE_RUNNING = 0x004, SERVICE_PAUSING = 0x008, SERVICE_PAUSED = 0x010, SERVICE_RESUMING = 0x020, SERVICE_SHUTTING_DOWN = 0x040, SERVICE_SHUTDOWN = 0x080, SERVICE_FAILED = 0x100, SERVICE_ALL = SERVICE_READY | SERVICE_STARTING | SERVICE_RUNNING | SERVICE_PAUSING | SERVICE_PAUSED | SERVICE_RESUMING | SERVICE_SHUTTING_DOWN | SERVICE_SHUTDOWN | SERVICE_FAILED } | ServiceStatus |
#include <service.hh>
Enumeration of states objects derived from ServiceBase may be in.
const char* service_status_name (ServiceStatus s)
| service_status_name |
#include <service.hh>
Get text description of enumerated service status.
Parameters:
s | service status to recover name for. |
typedef enum -- | -- |
#include <status_codes.h>
Explanation of Process States ----------------------------- +-------------> PROC_NULL | | | | (1) | V | PROC_STARTUP | | | | (2) | V | PROC_NOT_READY | | ^ |(9) (3) | | (4) | V | | PROC_READY | / \ | (5)/ \(6) | V V | PROC_SHUTDOWN PROC_FAILED | \ / | (7)\ /(8) | \ / | V V | PROC_DONE | | | | | | | V +-------------------+ Events/Actions -------------- (1) Register with finder. (2) External dependencies satisfied, ready to be configured. (3) Finished processing any config changes, ready for other processes that depend on this process to be configured. (4) Received a config change that needs to be processed before other processes that depend on this process are configured. (5) Received a request for a clean shutdown. (6) Something failed, this process is no longer functioning correctly. (7) The shutdown has completed. (8) The process has completed the cleanup after the failure. (9) Deregister with finder. States ------ PROC_NULL Process is not registered with finder. It may or may not be running. PROC_STARTUP Process is registered with finder, but is waiting on some other processes before it is ready to be configured. PROC_NOT_READY For any reason, the process is not ready for processes that depend on this process to be configured or reconfigured. A common reason is that this process just received a config change, and is still in the process of making the config change active. PROC_READY Process is running normally. Processes that depend on the state of this process can be configured or reconfigured. PROC_SHUTDOWN Process has received a shutdown request is shutting down cleanly. Normally the process will terminate by itself after being in this state. PROC_FAILED Process has suffered a fatal error, and is in the process of cleaning up the mess. Normally the process will terminate by itself after being in this state. PROC_DONE The process has completed operation, but is still capable of responding to XRLs. Notes ----- A process may spend zero time in PROC_STARTUP, PROC_NOT_READY, PROC_READY, PROC_SHUTDOWN, PROC_FAILED, or PROC_DONE states. For example, a process may effectively go directly from PROC_NULL to PROC_READY state on startup if there are no dependencies that need to be taken into account. A process may go from PROC_STARTUP or PROC_NOT_READY states to PROC_SHUTDOWN or PROC_FAILED states without spending any time in PROC_READY state if required. On reconfiguration, a process does not need to go to NOT_READY state unless it needs to delay the reconfiguration of processes that depend on the completion of this reconfiguration. After shutdown or a failure, the process may remain indefinitely in PROC_DONE state (e.g., if the process itself shoudn't really exit but rather await further instructions).
enum -- { PROC_NULL = 0, PROC_STARTUP = 1, PROC_NOT_READY = 2, PROC_READY = 3, PROC_SHUTDOWN = 4, PROC_FAILED = 5, PROC_DONE = 6 } | -- |
#include <status_codes.h>
typedef XorpCallback0<void>::RefPtr OneoffTaskCallback | OneoffTaskCallback |
#include <task.hh>
typedef XorpCallback0<bool>::RefPtr RepeatedTaskCallback | RepeatedTaskCallback |
#include <task.hh>
typedef XorpCallback1<void, XorpTask&>::RefPtr BasicTaskCallback | BasicTaskCallback |
#include <task.hh>
typedef XorpCallback0<void>::RefPtr OneoffTimerCallback | OneoffTimerCallback |
#include <timer.hh>
typedef XorpCallback0<bool>::RefPtr PeriodicTimerCallback | PeriodicTimerCallback |
#include <timer.hh>
typedef XorpCallback1<void, XorpTimer&>::RefPtr BasicTimerCallback | BasicTimerCallback |
#include <timer.hh>
inline TimeVal
operator- (const TimeVal& v)
| operator- |
#include <timeval.hh>
inline TimeVal
operator* (int n, const TimeVal& t)
| operator* |
#include <timeval.hh>
inline TimeVal
operator* (const double& d, const TimeVal& t)
| operator* |
#include <timeval.hh>
inline TimeVal
random_uniform (const TimeVal& lower, const TimeVal& upper)
| random_uniform |
#include <timeval.hh>
Generate a TimeVal value from a uniform random distribution between specified bounds.
Parameters:
lower | lower bound of generated value. |
upper | upper bound of generated value. |
Returns: value chosen from uniform random distribution.
inline TimeVal
random_uniform (const TimeVal& upper)
| random_uniform |
#include <timeval.hh>
Generate a TimeVal value from a uniform random distribution between zero and specified bound.
Parameters:
upper | upper bound of generated value. |
Returns: value chosen from uniform random distribution.
inline TimeVal
random_uniform (const TimeVal& center, const double& factor)
| random_uniform |
#include <timeval.hh>
Generate a TimeVal value from a uniform random distribution between the bounds center - factor * center and center + factor * center. If the lower bound is less than TimeVal::ZERO() it is rounded up to TimeVal::ZERO().
Parameters:
center | mid-point of generated time value. |
factor | the spread of the uniform random distribution. |
Returns: value chosen from uniform random distribution.
string copy_token (const string& token_org)
| copy_token |
#include <token.hh>
Copy a token.
If the token contains token separators, enclose it within quotations.
Parameters:
token_org | the token to copy. |
Returns: the copy of the token with token separators enclosed within quotations.
string pop_token (string& token_line)
| pop_token |
#include <token.hh>
Pop a token from a token line.
Parameters:
token_line | the token line to pop a token from. |
Returns: the first token from the front of the line. Also, token_line is modified to exlude that token.
bool is_token_separator (const char c)
| is_token_separator |
#include <token.hh>
Test if a character is a token separator.
Currently, the is_space(3) characters and '|' are considered as token separators.
Parameters:
c | the character to test whether it is token separator. |
Returns: true if c is a token separator, otherwise false.
bool has_more_tokens (const string& token_line)
| has_more_tokens |
#include <token.hh>
Test if a token line contains more tokens.
Parameters:
token_line | the token line to test. |
Returns: true if token_line contains more tokens, otherwise false.
vector<string> token_line2vector (const string& token_line)
| token_line2vector |
#include <token.hh>
Split a token line into a vector with the tokens.
Parameters:
token_line | the token line to split. |
Returns: a vector with all tokens.
list<string> token_line2list (const string& token_line)
| token_line2list |
#include <token.hh>
Split a token line into a list with the tokens.
Parameters:
token_line | the token line to split. |
Returns: a list with all tokens.
string token_vector2line (const vector<string>& token_vector)
| token_vector2line |
#include <token.hh>
Combine a vector with the tokens into a single line with spaces as separators.
Parameters:
token_vector | the vector with the tokens. |
Returns: a line with the tokens separated by spaces.
string token_list2line (const list<string>& token_list)
| token_list2line |
#include <token.hh>
Combine a list with the tokens into a single line with spaces as separators.
Parameters:
token_list | the list with the tokens. |
Returns: a line with the tokens separated by spaces.
inline
void
tokenize (const string& str,
vector<string>& tokens,
const string& delimiters = " ")
| tokenize |
#include <tokenize.hh>
inline const struct sockaddr_in *
sockaddr2sockaddr_in (const struct sockaddr* sa)
| sockaddr2sockaddr_in |
#include <utility.h>
inline struct sockaddr_in *
sockaddr2sockaddr_in (struct sockaddr* sa)
| sockaddr2sockaddr_in |
#include <utility.h>
inline const struct sockaddr_in6 *
sockaddr2sockaddr_in6 (const struct sockaddr* sa)
| sockaddr2sockaddr_in6 |
#include <utility.h>
inline struct sockaddr_in6 *
sockaddr2sockaddr_in6 (struct sockaddr* sa)
| sockaddr2sockaddr_in6 |
#include <utility.h>
inline const struct sockaddr *
sockaddr_storage2sockaddr (const struct sockaddr_storage* ss)
| sockaddr_storage2sockaddr |
#include <utility.h>
inline struct sockaddr *
sockaddr_storage2sockaddr (struct sockaddr_storage* ss)
| sockaddr_storage2sockaddr |
#include <utility.h>
extern int xorp_isalnum (int c)
| xorp_isalnum |
#include <utility.h>
extern int xorp_isalpha (int c)
| xorp_isalpha |
#include <utility.h>
extern int xorp_iscntrl (int c)
| xorp_iscntrl |
#include <utility.h>
extern int xorp_isdigit (int c)
| xorp_isdigit |
#include <utility.h>
extern int xorp_isgraph (int c)
| xorp_isgraph |
#include <utility.h>
extern int xorp_islower (int c)
| xorp_islower |
#include <utility.h>
extern int xorp_isprint (int c)
| xorp_isprint |
#include <utility.h>
extern int xorp_ispunct (int c)
| xorp_ispunct |
#include <utility.h>
extern int xorp_isspace (int c)
| xorp_isspace |
#include <utility.h>
extern int xorp_isupper (int c)
| xorp_isupper |
#include <utility.h>
extern int xorp_isxdigit (int c)
| xorp_isxdigit |
#include <utility.h>
extern int xorp_tolower (int c)
| xorp_tolower |
#include <utility.h>
extern int xorp_toupper (int c)
| xorp_toupper |
#include <utility.h>
extern char * xorp_strptime (const char *buf, const char *fmt, struct tm *tm)
| xorp_strptime |
#include <utility.h>
extern const char * bool_c_str (int v)
| bool_c_str |
#include <utility.h>
inline string
unix_path_to_native (const string& unixpath)
| unix_path_to_native |
#include <utils.hh>
Convert a UNIX style path to the platform's native path format.
Parameters:
path | the UNIX style path to be converted. |
Returns: the converted path.
inline bool
is_absolute_path (const string& path, bool homeok = false)
| is_absolute_path |
#include <utils.hh>
Determine if a provided native path string is an absolute path, or possibly relative to a user's home directory under UNIX.
Parameters:
path | a path in native format to inspect. |
homeok | allow paths relative to a home directory to be regarded as absolute paths by this function. |
Returns: true if the path if satisfies the criteria for an absolute path.
list<string> split (const string& s, char sep)
| split |
#include <utils.hh>
Tokenize a string by breaking into separate strings when separator character is encountered.
Parameters:
s | string to be tokenized. |
sep | separator to break string it. |
Returns: list of tokens.
string strip_empty_spaces (const string& s)
| strip_empty_spaces |
#include <utils.hh>
Remove the heading and trailing empty spaces from string value.
Parameters:
s | string that may have heading and trailing empty spaces. |
Returns: copy of the string with heading and trailing empty spaces removed.
bool has_empty_space (const string& s)
| has_empty_space |
#include <utils.hh>
Test if a string contains an empty space (i.e., <SPACE> or <TAB>).
Parameters:
s | the string to test. |
Returns: true if the string contains an empty space, otherwise false.
const char* xorp_basename (const char* argv0)
| xorp_basename |
#include <utils.hh>
Return basename of a path.
Parameters:
argv0 | the argv[0] supplied to main(). |
template<class T> void
delete_pointers_list (list<T *>& delete_list)
| delete_pointers_list |
#include <utils.hh>
Template to delete a list of pointers, and the objects pointed to.
Parameters:
delete_list | the list of pointers to objects to delete. |
template<class T> void
delete_pointers_vector (vector<T *>& delete_vector)
| delete_pointers_vector |
#include <utils.hh>
Template to delete an array of pointers, and the objects pointed to.
Parameters:
delete_vector | the vector of pointers to objects to delete. |
FILE* xorp_make_temporary_file (const string& tmp_dir,
const string& filename_template,
string& final_filename,
string& errmsg)
| xorp_make_temporary_file |
#include <utils.hh>
Create a temporary file with unique name.
This function takes the given file name template, and adds a suffix to it to create an unique file name in a chosen temporary directory. The temporary directory is selected from the following list by choosing the first directory that allows us the create the temporary file (in the given order): (a) The value of one of the following environment variables if defined (in the given order): - "TMPDIR" - "TEMP" (Windows only) - "TMP" (Windows only) (b) Argument tmp_dir if it is not an empty string. (c) The system-specific path of the directory designated for temporary files: - GetTempPath() (Windows only) (d) The "P_tmpdir" directory if this macro is defined (typically in the <stdio.h> include file). (e) The first directory from the following list we can write to: - "C:\TEMP" (Windows only) - "/tmp" (UNIX only) - "/usr/tmp" (UNIX only) - "/var/tmp" (UNIX only)
For example, if the file name template is "foo", and if the chosen temporary directory is "/tmp", then the temporary file name would be like "/tmp/foo.XXXXXX" where "XXXXXX" is alpha-numerical suffix chosen automatically to compose the unique file name. The created file has mode 0600 (i.e., readable and writable only by the owner).
Parameters:
tmp_dir | the preferred directory to store the file. |
filename_template | the file name template. |
final_filename | a return-by-reference argument that on success returns the final name of the temporary file (including the directory name). |
errmsg | the error message (if error). |
Returns: a file descriptor pointer for the temporary file (opened for reading and writing) on success, otherwise NULL.
void win_quote_args (const list<string>& args, string& cmdline)
| win_quote_args |
#include <utils.hh>
Helper function to quote command line arguments for MSVCRT-linked programs.
Given an argv array represented by an STL list of strings, and a writable command line string, walk through the arguments and perform quoting/escaping according to the rules for invoking programs linked against the Microsoft Visual C Runtime Library.
This function is necessary because the Win32 CreateProcess() API function accepts a single command line string, as opposed to a UNIX-style argv[] array; arguments must therefore be delimited by white space, so white space in arguments themselves must be quoted.
Note that such extensive quoting shouldn't be performed for the pathname to the executable -- generally it is desirable to only wrap the path name with quotes, and then pass that string to this helper function.
Parameters:
args | list of argument strings to be escaped. |
cmdline | string to which the escaped command line should be appended. |
inline uint32_t
xorp_bit_count_uint32 (uint32_t x)
| xorp_bit_count_uint32 |
#include <utils.hh>
Count the number of bits that are set in a 32-bit wide integer.
Code taken from the following URL (the "Population Count (Ones Count)" algorithm): http://aggregate.org/MAGIC/
Note: this solution appears to be faster even compared to the "Parallel Count" and "MIT HACKMEM Count" from: http://www-db.stanford.edu/~manku/bitcount/bitcount.html
Parameters:
x | the value to test. |
Returns: the number of bits that are set in x.
inline uint32_t
xorp_leading_zero_count_uint32 (uint32_t x)
| xorp_leading_zero_count_uint32 |
#include <utils.hh>
Count the number of leading zeroes in a 32-bit wide integer.
Code taken from the following URL (the "Leading Zero Count" algorithm): http://aggregate.org/MAGIC/
Parameters:
x | the value to test. |
Returns: the number of leading zeroes in x.
typedef map<IoEventTuple, IoEventCb> IoEventMap | IoEventMap |
#include <win_dispatcher.hh>
A map of Windows object handle and I/O event type to an I/O callback for each member.
typedef map<HANDLE, XorpFd> EventSocketMap | EventSocketMap |
#include <win_dispatcher.hh>
A map of Windows event handle to socket handle, used for faster dispatch of socket events on return from WFMO(). Note that XorpFd is used as the value type.
typedef std::pair<HANDLE, long> MaskEventPair | MaskEventPair |
#include <win_dispatcher.hh>
A value-type tuple of a Windows event handle and a WSA event mask.
typedef map<SOCKET, MaskEventPair> SocketEventMap | SocketEventMap |
#include <win_dispatcher.hh>
A map of sockets to a MaskEventPair tuple.
int win_strerror_r (DWORD errnum, char *strerrbuf, size_t buflen)
| win_strerror_r |
#include <win_io.h>
char * win_strerror (DWORD errnum)
| win_strerror |
#include <win_io.h>
ssize_t win_con_read (HANDLE h, void *buf, size_t bufsize)
| win_con_read |
#include <win_io.h>
ssize_t win_pipe_read (HANDLE h, void *buf, size_t bufsize)
| win_pipe_read |
#include <win_io.h>
typedef enum -- | -- |
#include <xlog.h>
The log levels. Typically used only by xlog_enable() and xlog_disable()
enum -- { XLOG_LEVEL_MIN = 0, XLOG_LEVEL_FATAL = 0, XLOG_LEVEL_ERROR, XLOG_LEVEL_WARNING, XLOG_LEVEL_INFO, XLOG_LEVEL_TRACE, XLOG_LEVEL_MAX } | -- |
#include <xlog.h>
typedef enum -- | -- |
#include <xlog.h>
The messages verbose level. Typically used only by xlog_set_verbose() and xlog_level_set_verbose()
enum -- { XLOG_VERBOSE_LOW = 0, XLOG_VERBOSE_MEDIUM, XLOG_VERBOSE_HIGH, XLOG_VERBOSE_MAX } | -- |
#include <xlog.h>
typedef int (*xlog_output_func_t) (void *obj, xlog_level_t level, const char *msg) | (*xlog_output_func_t) |
#include <xlog.h>
The type of add-on functions to process the log messages.
int xlog_init (const char *argv0, const char *preamble_message)
| xlog_init |
#include <xlog.h>
Initialize the log utility.
As part of the initialization, the preamble string will be set to <process_name><preamble_message> Use in preference to xlog_set_preamble which will be removed.
Parameters:
argv0 | the path of the process executable from which the program name will be extract to become part of the preamble string. |
preamble_message | a string that will become part of the preamble string. |
Returns: 0 on success, otherwise -1.
int xlog_exit (void)
| xlog_exit |
#include <xlog.h>
Gracefully exit logging.
Returns: 0 on success, otherwise -1.
int xlog_start (void)
| xlog_start |
#include <xlog.h>
Start logging.
Returns: 0 on success, otherwise -1.
int xlog_stop (void)
| xlog_stop |
#include <xlog.h>
Stop logging.
Returns: 0 on success, otherwise -1.
int xlog_is_running (void)
| xlog_is_running |
#include <xlog.h>
Check if xlog is running.
Returns: non-zero if xlog is running, otherwise 0.
int xlog_enable (xlog_level_t log_level)
| xlog_enable |
#include <xlog.h>
Enable logging for messages of a given type (log_level_t).
By default, all message types are enabled.
Parameters:
log_level | the message type xlog_level_t (e.g., XLOG_LEVEL_WARNING) to enable the logging for. |
Returns: 0 on success, otherwise -1.
int xlog_disable (xlog_level_t log_level)
| xlog_disable |
#include <xlog.h>
Disable logging for messages of a given type (log_level_t).
Note: XLOG_LEVEL_FATAL cannot be disabled.
Parameters:
log_level | the message type xlog_level_t (e.g., XLOG_LEVEL_WARNING) to disable the logging for. |
Returns: 0 on success, otherwise -1.
void xlog_set_preamble (const char *text)
| xlog_set_preamble |
#include <xlog.h>
Set the preamble string for the log entries.
Parameters:
text | the preamble string, or NULL if no preamble. |
const char* xlog_process_name (void)
| xlog_process_name |
#include <xlog.h>
Get process name as set with xlog_init.
Returns: pointer to name on success, NULL otherwise.
void xlog_set_verbose (xlog_verbose_t verbose_level)
| xlog_set_verbose |
#include <xlog.h>
Set the level of verbosity (xlog_verbose_t) for the log entries.
Applies for all type of messages except for XLOG_LEVEL_FATAL which always is set to the most verbose level.
Parameters:
verbose_level | the level of verbosity xlog_verbose_t (higher is more verbose). |
void xlog_level_set_verbose (xlog_level_t log_level,
xlog_verbose_t verbose_level)
| xlog_level_set_verbose |
#include <xlog.h>
Set the level of verbosity (xlog_verbose_t) for the log entries of messages of a given type (xlog_level_t).
Note: XLOG_LEVEL_FATAL verbosity cannot be changed, and is always set to the most verbose level.
Parameters:
log_level | the message type xlog_level_t to set the verbosity of. |
verbose_level | the level of verbosity xlog_verbose_t (higher is more verbose). |
int xlog_add_output (FILE *fp)
| xlog_add_output |
#include <xlog.h>
Add a file descriptor to the set of output streams.
Parameters:
fp | the file descriptor to add to the set of output streams. |
Returns: 0 on success, otherwise -1.
int xlog_remove_output (FILE *fp)
| xlog_remove_output |
#include <xlog.h>
Remove a file descriptor from the set of output streams.
Parameters:
fp | the file descriptor to remove from the set of output streams. |
Returns: 0 on success, otherwise -1.
int xlog_add_output_func (xlog_output_func_t func, void *obj)
| xlog_add_output_func |
#include <xlog.h>
Add a processing function and an object to the set of output streams.
Parameters:
func | the function to add to the set of output streams. |
obj | the object to supply func with when called. |
Returns: 0 on success, otherwise -1.
int xlog_add_syslog_output (const char *syslogspec)
| xlog_add_syslog_output |
#include <xlog.h>
Add a channel which goes to the X/Open compatible system log aka syslog.
Parameters:
syslogspec | the syslog facility and priority as a string "facility.priority" |
Returns: 0 on success, otherwise -1.
int xlog_remove_output_func (xlog_output_func_t func, void *obj)
| xlog_remove_output_func |
#include <xlog.h>
Remove a processing function and an object from the set of output streams.
Parameters:
func | the function to remove from the set of output streams. |
obj | the object that func was supplied with. |
Returns: 0 on success, otherwise -1.
int xlog_add_default_output (void)
| xlog_add_default_output |
#include <xlog.h>
Add default output stream to list of output streams.
XXX: right now the default is '/dev/stderr', but it should eventually be: `/dev/console' if the process has sufficient permissions, and `/dev/stderr' otherwise.
Returns: 0 on success, otherwise -1.
int xlog_remove_default_output (void)
| xlog_remove_default_output |
#include <xlog.h>
Remove the default output stream from the set of output streams.
Returns: 0 on success, otherwise -1.
void _xcond_trace_entry (const char *module_name, const char *file,
int line, const char *fn)
| _xcond_trace_entry |
#include <xlog.h>
A marker that can be used to indicate code that is not yet implemented and hence should not be run.
Note that it cannot be conditionally disabled and logs error through the standard XLOG mechanism. Always calls XLOG_FATAL.
const char * xlog_localtime2string (void)
| xlog_localtime2string |
#include <xlog.h>
Compute the current local time and return it as a string.
The return string has the format: Year/Month/Day Hour:Minute:Second.Microsecond Example: 2002/02/05 20:22:09.808632 Note that the returned string uses statically allocated memory, and does not need to be de-allocated.
Returns: a statically allocated string with the local time using the format described above.
int x_vasprintf (char **ret, const char *format, va_list ap)
| x_vasprintf |
#include <xlog.h>
A local implementation of vasprintf(3).
If vasprintf(3) is available, it is called instead.
Parameters:
ret | a pointer to the string pointer to store the result. |
format | the printf(3)-style format. |
ap | the variable arguments for format. |
Returns: (From FreeBSD vasprintf(3) manual page): The number of characters printed (not including the trailing '\0' used to end output to strings). Also, set the value pointed to by ret to be a pointer to a buffer sufficiently large to hold the formatted string. This pointer should be passed to free(3) to release the allocated storage when it is no longer needed. If sufficient space cannot be allocated, will return -1 and set ret to be a NULL pointer.
int x_asprintf (char **ret, const char *format, ...)
| x_asprintf |
#include <xlog.h>
A local implementation of asprintf(3).
Parameters:
ret | a pointer to the string pointer to store the result. |
format | the printf(3)-style format. @param ... the variable arguments for format. |
Returns: (From FreeBSD asprintf(3) manual page): The number of characters printed (not including the trailing '\0' used to end output to strings). Also, set ret to be a pointer to a buffer sufficiently large to hold the formatted string. This pointer should be passed to free(3) to release the allocated storage when it is no longer needed. If sufficient space cannot be allocated, will return -1 and set ret to be a NULL pointer.
typedef enum -- | -- |
#include <xorp.h>
enum -- { true = TRUE, false = FALSE } | -- |
#include <xorp.h>
typedef bool bool_t | bool_t |
#include <xorp.h>
char * gai_strerror (int ecode)
| gai_strerror |
#include <xorp_osdep_end.h>
typedef HANDLE xfd_t | xfd_t |
#include <xorp_osdep_mid.h>
typedef SOCKET xsock_t | xsock_t |
#include <xorp_osdep_mid.h>
typedef unsigned long gid_t | gid_t |
#include <xorp_osdep_mid.h>
typedef unsigned long uid_t | uid_t |
#include <xorp_osdep_mid.h>
typedef _off_t off_t | off_t |
#include <xorp_osdep_mid.h>
typedef _pid_t pid_t | pid_t |
#include <xorp_osdep_mid.h>
typedef long ssize_t | ssize_t |
#include <xorp_osdep_mid.h>
typedef _sigset_t sigset_t | sigset_t |
#include <xorp_osdep_mid.h>
typedef int xfd_t | xfd_t |
#include <xorp_osdep_mid.h>
typedef int xsock_t | xsock_t |
#include <xorp_osdep_mid.h>
size_t strlcpy (char *dst, const char *src, size_t size)
| strlcpy |
#include <xorp_osdep_mid.h>
int inet_pton (int af, const char *src, void *dst)
| inet_pton |
#include <xorp_osdep_mid.h>
const char * inet_ntop (int af, const void *src, char *dst, size_t size)
| inet_ntop |
#include <xorp_osdep_mid.h>
int getopt (int argc, char * const argv[], const char *optstring)
| getopt |
#include <xorp_osdep_mid.h>