1227 lines
24 KiB
C
1227 lines
24 KiB
C
/* ipmip_util.h - ipmip_util.h */
|
|
/*
|
|
******************************************************************************
|
|
* HEADER FILE
|
|
*
|
|
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip_util.h,v $ $Revision: 1.26 $
|
|
* $Source: /home/interpeak/CVSRoot/ipmip/include/private/ipmip_util.h,v $
|
|
* $Author: jhorteli $ $Date: 2011-01-21 15:31:28 $
|
|
* $State: Exp $ $Locker: $
|
|
*
|
|
* INTERPEAK_COPYRIGHT_STRING
|
|
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
|
******************************************************************************
|
|
*/
|
|
#ifndef IPMIP_UTIL_H
|
|
#define IPMIP_UTIL_H
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 1 DESCRIPTION
|
|
****************************************************************************
|
|
* Miscellaneous utility functions used by the MIP system
|
|
*/
|
|
/*
|
|
DESCRIPTION
|
|
|
|
Miscellaneous utility functions used by the MIP system
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 2 CONFIGURATION
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 3 INCLUDE FILES
|
|
****************************************************************************
|
|
*/
|
|
|
|
#include <ipcom_hash.h>
|
|
#include <ipcom_time.h>
|
|
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 4 DEFINES
|
|
****************************************************************************
|
|
*/
|
|
|
|
#ifdef IPMIP_USE_INET6
|
|
#define IPMIP_IP6_SET_ADDR(dst, src) ipcom_memcpy(dst, src, sizeof(struct Ip_in6_addr))
|
|
#endif
|
|
|
|
#define IPMIP_DO_IF(x, lvl, proc, call) \
|
|
do { \
|
|
if (lvl >= IPCOM_LOG_ ## x) { \
|
|
proc->args.arg32 = IPCOM_LOG_ ## x | IPCOM_SYSLOG_FACILITY; \
|
|
call; \
|
|
} \
|
|
} while(0)
|
|
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 5 TYPES
|
|
****************************************************************************
|
|
*/
|
|
struct Ipmip_context;
|
|
struct Ipmip_proc;
|
|
union Ip_in_addr_union;
|
|
union Ip_sockaddr_union;
|
|
|
|
typedef void (*Ipmip_util_hash_foreach_t)
|
|
(
|
|
struct Ipmip_context *ctx,
|
|
struct Ipmip_proc *proc,
|
|
void *entry,
|
|
void *arg1,
|
|
void *arg2
|
|
);
|
|
|
|
|
|
typedef void (*Ipmip_util_hash_free_t)
|
|
(
|
|
void *arg1
|
|
);
|
|
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 6 FUNCTIONS
|
|
****************************************************************************
|
|
*/
|
|
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_vstrdup - ipmip_util_vstrdup
|
|
*
|
|
* Do a strdup on a varargs format list
|
|
*
|
|
* Parameters:
|
|
* \is
|
|
* \i format
|
|
* The format
|
|
* \i ap
|
|
* The 'printf' arguments.
|
|
* \ie
|
|
*
|
|
* RETURNS: An allocated string created using the format and arguments
|
|
*
|
|
* ERRNO:
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
IP_GLOBAL char * ipmip_util_vstrdup
|
|
(
|
|
const char *format,
|
|
va_list ap
|
|
);
|
|
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_hdrprintf - ipmip_util_hdrprintf
|
|
*
|
|
* Do a header printf which properly indents and aligns based on headersize.
|
|
*
|
|
* Parameters:
|
|
* \is
|
|
* \i proc
|
|
* The process context associated with the currently executing thread. Each
|
|
* thread and/or process in MIP must have its own unique process context.
|
|
* If a process is started using ipmip_proc_start, the process context will
|
|
* be allocated automatically by the IPMIP framework. Otherwise it must
|
|
* be allocated using ipmip_proc_alloc().
|
|
* \i tabs
|
|
* Initial indentation
|
|
* \i header
|
|
* Header value
|
|
* \i hdr_size
|
|
* Header size indentation
|
|
* \i format
|
|
* The format
|
|
* \i ...
|
|
* The 'printf' arguments.
|
|
* \ie
|
|
*
|
|
* RETURNS: No return value
|
|
*
|
|
* ERRNO:
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
IP_GLOBAL void ipmip_util_hdrprintf
|
|
(
|
|
struct Ipmip_proc *proc,
|
|
int tabs,
|
|
const char *header,
|
|
Ip_size_t hdr_size,
|
|
const char *format,
|
|
...
|
|
);
|
|
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_identprintf - ipmip_util_identprintf
|
|
*
|
|
* Ident printf - do an ident prior to printing
|
|
*
|
|
* Parameters:
|
|
* \is
|
|
* \i proc
|
|
* The process context associated with the currently executing thread. Each
|
|
* thread and/or process in MIP must have its own unique process context.
|
|
* If a process is started using ipmip_proc_start, the process context will
|
|
* be allocated automatically by the IPMIP framework. Otherwise it must
|
|
* be allocated using ipmip_proc_alloc().
|
|
* \i tabs
|
|
* Initial indentation
|
|
* \i format
|
|
* The format
|
|
* \i ...
|
|
* The 'printf' arguments.
|
|
* \ie
|
|
*
|
|
* RETURNS: No return value
|
|
*
|
|
* ERRNO:
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
IP_GLOBAL void ipmip_util_identprintf
|
|
(
|
|
struct Ipmip_proc *proc,
|
|
int tabs,
|
|
const char *format,
|
|
...
|
|
);
|
|
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_cmdprintf - ipmip_util_cmdprintf
|
|
*
|
|
* Cmd printf - do command usage printf
|
|
*
|
|
* Parameters:
|
|
* \is
|
|
* \i proc
|
|
* The process context associated with the currently executing thread. Each
|
|
* thread and/or process in MIP must have its own unique process context.
|
|
* If a process is started using ipmip_proc_start, the process context will
|
|
* be allocated automatically by the IPMIP framework. Otherwise it must
|
|
* be allocated using ipmip_proc_alloc().
|
|
* \i tabs
|
|
* Initial indentation
|
|
* \i format
|
|
* The format
|
|
* \i ...
|
|
* The 'printf' arguments.
|
|
* \ie
|
|
*
|
|
* RETURNS: No return value
|
|
*
|
|
* ERRNO:
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
IP_GLOBAL void ipmip_util_cmdprintf
|
|
(
|
|
struct Ipmip_proc *proc,
|
|
int tabs,
|
|
const char *cmd,
|
|
const char *format,
|
|
...
|
|
);
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_bool_safe - ipmip_util_bool_safe
|
|
*
|
|
* Read a bool from an (un)aligned pointer
|
|
*
|
|
* Parameters:
|
|
* \is
|
|
* \i bptr
|
|
* The bool pointer
|
|
* \ie
|
|
*
|
|
* RETURNS: The bool value
|
|
*
|
|
* ERRNO:
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
IP_GLOBAL Ip_bool ipmip_util_bool_safe
|
|
(
|
|
const Ip_bool *bptr
|
|
);
|
|
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_strdup - ipmip_util_strdup
|
|
*
|
|
* Do a strdup on a varargs format list
|
|
*
|
|
* Parameters:
|
|
* \is
|
|
* \i format
|
|
* The format
|
|
* \i ...
|
|
* The 'printf' arguments.
|
|
* \ie
|
|
*
|
|
* RETURNS: An allocated string created using the format and arguments
|
|
*
|
|
* ERRNO:
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
IP_GLOBAL char * ipmip_util_strdup
|
|
(
|
|
const char *format,
|
|
/* args */ ...
|
|
);
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_strnlen - ipmip_util_strnlen
|
|
*
|
|
* Calculates the length of a string, but max the provided max
|
|
* length in case the string is not NULL terminated
|
|
*
|
|
* Parameters:
|
|
* \is
|
|
* \i str
|
|
* The string to calculate
|
|
* \i mlen
|
|
* The maximum length
|
|
* \ie
|
|
*
|
|
* RETURNS: The length of the string, or mlen if the string was not
|
|
* NULL terminated.
|
|
*
|
|
* ERRNO:
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
IP_GLOBAL Ip_size_t ipmip_util_strnlen
|
|
(
|
|
const char *str,
|
|
Ip_size_t mlen
|
|
);
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_strnchr - ipmip_util_strnchr
|
|
*
|
|
* Locate a specific character in a length determined string
|
|
*
|
|
* Parameters:
|
|
* \is
|
|
* \i str
|
|
* The string to calculate
|
|
* \i ch
|
|
* Character to look for
|
|
* \i mlen
|
|
* The maximum length
|
|
* \ie
|
|
*
|
|
* RETURNS: The character pointer or IP_NULL
|
|
*
|
|
* ERRNO:
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
IP_GLOBAL const char* ipmip_util_strnchr
|
|
(
|
|
const char *str,
|
|
const char ch,
|
|
Ip_size_t mlen
|
|
);
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_strnncmp - ipmip_util_strnncmp
|
|
*
|
|
* Compares two size limited strings towards each other
|
|
*
|
|
* Parameters:
|
|
* \is
|
|
* \i str1
|
|
* The first string
|
|
* \i str1_len
|
|
* The length of str1
|
|
* \i str2
|
|
* The second string
|
|
* \i str2_len
|
|
* The length of str2
|
|
* \ie
|
|
*
|
|
* RETURNS: IP_TRUE if equal
|
|
*
|
|
* ERRNO:
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
IP_GLOBAL Ip_bool ipmip_util_strnncmp
|
|
(
|
|
const char *str1,
|
|
Ip_size_t str1_len,
|
|
const char *str2,
|
|
Ip_size_t str2_len
|
|
);
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_strstrip0 - ipmip_util_strstrip0
|
|
*
|
|
* Remove any null terminations from the string.
|
|
*
|
|
* Parameters:
|
|
* \is
|
|
* \i str1
|
|
* The string
|
|
* \i str1_len
|
|
* The length of str1
|
|
* \ie
|
|
*
|
|
* RETURNS: The length without null termination
|
|
*
|
|
* ERRNO:
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
IP_GLOBAL Ip_size_t ipmip_util_strstrip0
|
|
(
|
|
const char *str1,
|
|
Ip_size_t str1_len
|
|
);
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_strnnmatch - ipmip_util_strnnmatch
|
|
*
|
|
* Compares two size limited NAIs towards each other. Will also return IP_TRUE if the
|
|
* either parameter is a DOMAIN (@example.com), and the other NAI belongs to that
|
|
* domain, or if either string begins with a wildcard (*) and the non-wildcard
|
|
* parts match. This means that valid match strings are for example
|
|
* @domain.com, which will also be the same as *@domain.com; but you may also
|
|
* specify *department@domain.com
|
|
*
|
|
* Parameters:
|
|
* \is
|
|
* \i str1
|
|
* The first string
|
|
* \i str1_len
|
|
* The length of str1
|
|
* \i str2
|
|
* The second string
|
|
* \i str2_len
|
|
* The length of str2
|
|
* \ie
|
|
*
|
|
* RETURNS: IP_TRUE if match
|
|
*
|
|
* ERRNO:
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
IP_GLOBAL Ip_bool ipmip_util_strnnmatch
|
|
(
|
|
const char *str1,
|
|
Ip_size_t str1_len,
|
|
const char *str2,
|
|
Ip_size_t str2_len
|
|
);
|
|
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_sock_clear - ipmip_util_sock_clear
|
|
*
|
|
* Clear error on socket
|
|
*
|
|
* Parameters:
|
|
* \is
|
|
* \i fd
|
|
* The filedescriptor to clear
|
|
* \ie
|
|
*
|
|
* RETURNS: No return value
|
|
*
|
|
* ERRNO:
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
IP_GLOBAL void ipmip_util_sock_clear
|
|
(
|
|
Ip_fd fd
|
|
);
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_tunnel_to_proto - ipmip_util_tunnel_to_proto
|
|
*
|
|
* Convert a tunnel index number to an internet protocol
|
|
*
|
|
* Parameters:
|
|
* \is
|
|
* \i tunnel
|
|
* Tunnel index
|
|
* \ie
|
|
*
|
|
* RETURNS: Internet protocol or 0 if no match.
|
|
*
|
|
* ERRNO:
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
IP_GLOBAL Ip_u8 ipmip_util_tunnel_to_proto
|
|
(
|
|
Ip_u8 tunnel
|
|
);
|
|
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_tunnel_to_desc - ipmip_util_tunnel_to_desc
|
|
*
|
|
* Convert a tunnel index number to a human readable description
|
|
*
|
|
* Parameters:
|
|
* \is
|
|
* \i tunnel
|
|
* Tunnel index
|
|
* \ie
|
|
*
|
|
* RETURNS: Human readable description
|
|
*
|
|
* ERRNO:
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
IP_GLOBAL const char *ipmip_util_tunnel_to_desc
|
|
(
|
|
Ip_u8 tunnel
|
|
);
|
|
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_tunnelmask_to_type - ipmip_util_tunnelmask_to_type
|
|
*
|
|
* Convert a tunnel mask to a tunnel type. If more than one bit is set,
|
|
* the first set bit will be used.
|
|
*
|
|
* Parameters:
|
|
* \is
|
|
* \i mask
|
|
* Tunnel mask
|
|
* \ie
|
|
*
|
|
* RETURNS: Tunnel type
|
|
*
|
|
* ERRNO:
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
IP_GLOBAL Ip_u8 ipmip_util_tunnelmask_to_type
|
|
(
|
|
Ip_u32 mask
|
|
);
|
|
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_proto_to_tunnel - ipmip_util_proto_to_tunnel
|
|
*
|
|
* Convert a protocol number to a tunnel index
|
|
*
|
|
* Parameters:
|
|
* \is
|
|
* \i proto
|
|
* Protocol number
|
|
* \ie
|
|
*
|
|
* RETURNS: Tunnel index or IPMIP4_TUNNELTYPE_NONE if no match.
|
|
*
|
|
* ERRNO:
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
IP_GLOBAL Ip_u8 ipmip_util_proto_to_tunnel
|
|
(
|
|
Ip_u8 proto
|
|
);
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_tunnel_to_bsdname - ipmip_util_tunnel_to_bsdname
|
|
*
|
|
* Convert a tunnel index number to a BSD tunnel name
|
|
*
|
|
* Parameters:
|
|
* \is
|
|
* \i tunnel
|
|
* Tunnel index
|
|
* \ie
|
|
*
|
|
* RETURNS: Tunnel name
|
|
*
|
|
* ERRNO:
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
IP_GLOBAL const char * ipmip_util_tunnel_to_bsdname
|
|
(
|
|
Ip_u8 tunnel
|
|
);
|
|
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_tunnel_to_name - ipmip_util_tunnel_to_name
|
|
*
|
|
* Convert a tunnel index number to a tunnel name
|
|
*
|
|
* Parameters:
|
|
* \is
|
|
* \i tunnel
|
|
* Tunnel index
|
|
* \ie
|
|
*
|
|
* RETURNS: Tunnel name
|
|
*
|
|
* ERRNO:
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
IP_GLOBAL const char * ipmip_util_tunnel_to_name
|
|
(
|
|
Ip_u8 tunnel
|
|
);
|
|
|
|
|
|
#ifdef IPMIP_USE_INET
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_inet - ipmip_util_inet
|
|
*
|
|
* Parse an string to the subnet and prefix length it specifies.
|
|
*
|
|
* Parameters:
|
|
* \is
|
|
* \i addrstr
|
|
* The address string
|
|
* \i addr
|
|
* Where to store the address
|
|
* \i plen
|
|
* The prefix length.
|
|
* \ie
|
|
*
|
|
* RETURNS: IP_TRUE if successful.
|
|
*
|
|
* ERRNO:
|
|
*
|
|
*/
|
|
IP_GLOBAL Ip_bool ipmip_util_inet
|
|
(
|
|
const char *addrstr,
|
|
Ip_u32 *addr,
|
|
Ip_u32 *plen
|
|
);
|
|
#endif
|
|
|
|
#ifdef IPMIP_USE_INET6
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_inet6 - ipmip_util_inet6
|
|
*
|
|
* Parse an string to the subnet and prefix length it specifies.
|
|
*
|
|
* Parameters:
|
|
* \is
|
|
* \i addrstr
|
|
* The address string
|
|
* \i addr6
|
|
* Where to store the address
|
|
* \i plen
|
|
* The prefix length.
|
|
* \ie
|
|
*
|
|
* RETURNS: IP_TRUE if successful.
|
|
*
|
|
* ERRNO:
|
|
*
|
|
*/
|
|
IP_GLOBAL Ip_bool ipmip_util_inet6
|
|
(
|
|
const char *addrstr,
|
|
struct Ip_in6_addr *addr6,
|
|
Ip_u8 *plen
|
|
);
|
|
#endif
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_inetX - ipmip_util_inetX
|
|
*
|
|
* Parse an string to the subnet and prefix length it specifies.
|
|
*
|
|
* Parameters:
|
|
* \is
|
|
* \i addrstr
|
|
* The address string
|
|
* \i domain
|
|
* The domain
|
|
* \i addrX
|
|
* Where to store the address
|
|
* \i plen
|
|
* The prefix length.
|
|
* \ie
|
|
*
|
|
* RETURNS: IP_TRUE if successful.
|
|
*
|
|
* ERRNO:
|
|
*
|
|
*/
|
|
IP_GLOBAL Ip_bool ipmip_util_inetX
|
|
(
|
|
const char *addrstr,
|
|
Ip_u8 *domain,
|
|
union Ip_in_addr_union *addrX,
|
|
Ip_u8 *plen
|
|
);
|
|
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_sockaddrX - ipmip_util_sockaddrX
|
|
*
|
|
* Parse an string to the address and port it specifies.
|
|
*
|
|
* Parameters:
|
|
* \is
|
|
* \i addrstr
|
|
* The address string
|
|
* \i unX
|
|
* The sockaddr union
|
|
* \ie
|
|
*
|
|
* RETURNS: IP_TRUE if successful.
|
|
*
|
|
* ERRNO:
|
|
*
|
|
*/
|
|
IP_GLOBAL Ip_bool ipmip_util_sockaddrX
|
|
(
|
|
const char *addrstr,
|
|
union Ip_sockaddr_union *unX
|
|
);
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_ioctl - ipmip_util_ioctl
|
|
*
|
|
* Do an ioctl
|
|
*
|
|
* Parameters:
|
|
* \is
|
|
* \i ctx
|
|
* The generic mobility singleton context for IPMIP. For each started mobility
|
|
* entity, there exists a mobility context which tracks configuration, system
|
|
* events, available features and started processes. The mobility context is
|
|
* created using ipmip_context_create(). See ipmip_context.h for more information
|
|
* regarding the mobility entity context singleton.
|
|
* \i proc
|
|
* The process context associated with the currently executing thread. Each
|
|
* thread and/or process in MIP must have its own unique process context.
|
|
* If a process is started using ipmip_proc_start, the process context will
|
|
* be allocated automatically by the IPMIP framework. Otherwise it must
|
|
* be allocated using ipmip_proc_alloc().
|
|
* \i ioreq
|
|
* The ioctl
|
|
* \i argp
|
|
* Ioctl argument
|
|
* \ie
|
|
*
|
|
* RETURNS: The ioctl return value.
|
|
*
|
|
* ERRNO:
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
IP_GLOBAL int ipmip_util_ioctl
|
|
(
|
|
struct Ipmip_context *ctx,
|
|
struct Ipmip_proc *proc,
|
|
unsigned long ioreq,
|
|
void *argp
|
|
);
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_duplicate - ipmip_util_duplicate
|
|
*
|
|
* Create a duplicate buffer and store in ptr; if ptr is already
|
|
* set, free it.
|
|
*
|
|
* Parameters:
|
|
* \is
|
|
* \i ptr
|
|
* [IN/OUT] Set pointer will be freed, and newly
|
|
* allocated will be set.
|
|
* \i value
|
|
* Value to copy
|
|
* \i sz
|
|
* Size of value
|
|
* \ie
|
|
*
|
|
* RETURNS: No return value
|
|
*
|
|
* ERRNO:
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
IP_GLOBAL void ipmip_util_duplicate
|
|
(
|
|
void **ptr,
|
|
void *value,
|
|
Ip_size_t sz
|
|
);
|
|
#define ipmip_util_dup(p,v,s) ipmip_util_duplicate((void **)((void *)(p)), (v), (s))
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_create_mask - ipmip_util_create_mask
|
|
*
|
|
* Creates a mask which contains 'netbits' number of '1' bits
|
|
* staring with the most significant bit.
|
|
*
|
|
* Parameters:
|
|
* \is
|
|
* \i mask
|
|
* Bitarray to create mask in
|
|
* \i netbits
|
|
* Length of mask
|
|
* \ie
|
|
*
|
|
* RETURNS: No return value
|
|
*
|
|
* ERRNO:
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
IP_GLOBAL void ipmip_util_create_mask
|
|
(
|
|
Ip_u8 *mask,
|
|
int netbits
|
|
);
|
|
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_cmp_bitarray - ipmip_util_cmp_bitarray
|
|
*
|
|
* Compares an opaque bit array
|
|
*
|
|
* Parameters:
|
|
* \is
|
|
* \i bitarray1
|
|
* Bitarray
|
|
* \i bitarray2
|
|
* Bitarray
|
|
* \i bits
|
|
* Length to compare
|
|
* \ie
|
|
*
|
|
* RETURNS: No return value
|
|
*
|
|
* ERRNO:
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
IP_GLOBAL Ip_bool ipmip_util_cmp_bitarray
|
|
(
|
|
void *bitarray1,
|
|
void *bitarray2,
|
|
int bits
|
|
);
|
|
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_hash_foreach - ipmip_util_hash_foreach
|
|
*
|
|
* Go through a hash table and invoke each element through the
|
|
* callback
|
|
*
|
|
* Parameters:
|
|
* \is
|
|
* \i ctx
|
|
* The generic mobility singleton context for IPMIP. For each started mobility
|
|
* entity, there exists a mobility context which tracks configuration, system
|
|
* events, available features and started processes. The mobility context is
|
|
* created using ipmip_context_create(). See ipmip_context.h for more information
|
|
* regarding the mobility entity context singleton.
|
|
* \i proc
|
|
* The process context associated with the currently executing thread. Each
|
|
* thread and/or process in MIP must have its own unique process context.
|
|
* If a process is started using ipmip_proc_start, the process context will
|
|
* be allocated automatically by the IPMIP framework. Otherwise it must
|
|
* be allocated using ipmip_proc_alloc().
|
|
* \i hash
|
|
* Hash table
|
|
* \i func
|
|
* Hash callback functions
|
|
* \i arg1
|
|
* Opaque argument 1
|
|
* \i arg2
|
|
* Opaque argument 2
|
|
* \ie
|
|
*
|
|
* RETURNS: No return value
|
|
*
|
|
* ERRNO:
|
|
*
|
|
*/
|
|
IP_GLOBAL void ipmip_util_hash_foreach
|
|
(
|
|
struct Ipmip_context *ctx,
|
|
struct Ipmip_proc *proc,
|
|
Ipcom_hash *hash,
|
|
Ipmip_util_hash_foreach_t func,
|
|
void *arg1,
|
|
void *arg2
|
|
);
|
|
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_hash_free - ipmip_util_hash_free
|
|
*
|
|
* Remove and free all entries
|
|
*
|
|
* Parameters:
|
|
* \is
|
|
* \i hash
|
|
* Hash table
|
|
* \i func
|
|
* Free func, if IP_NULL, ipcom_free will be invoked directly
|
|
* \ie
|
|
*
|
|
* RETURNS: No return value
|
|
*
|
|
* ERRNO:
|
|
*
|
|
*/
|
|
IP_GLOBAL void ipmip_util_hash_free
|
|
(
|
|
Ipcom_hash *hash,
|
|
Ipmip_util_hash_free_t func
|
|
);
|
|
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_explode - ipmip_util_explode
|
|
*
|
|
* Explode a character string, and return a data block of the form
|
|
* [1 byte num elems]:[1 byte length]:[length byte string]:[1 byte length]:....
|
|
* Parameters:
|
|
* \is
|
|
* \i arg_str
|
|
* String to explode
|
|
* \ie
|
|
*
|
|
* RETURNS: The data block
|
|
*
|
|
* ERRNO:
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
IP_GLOBAL Ip_u8 *ipmip_util_explode
|
|
(
|
|
const char *arg_str
|
|
);
|
|
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_strarr - ipmip_util_strarr
|
|
*
|
|
* Explode a character string an IP_NULL terminated string pointer array
|
|
* Parameters:
|
|
* \is
|
|
* \i arg_str
|
|
* String to explode
|
|
* \i numelem
|
|
* If specified, will contain the number of elements on success.
|
|
* \ie
|
|
*
|
|
* RETURNS: The string pointer array
|
|
*
|
|
* ERRNO:
|
|
*
|
|
*/
|
|
IP_GLOBAL char **ipmip_util_strarr
|
|
(
|
|
const char *buf,
|
|
Ip_size_t *numelem
|
|
);
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_syslog_priority - ipmip_util_syslog_priority
|
|
*
|
|
* Convert a string priority name to a priority value.
|
|
*
|
|
* Parameters:
|
|
* \is
|
|
* \i val
|
|
* String priority name
|
|
* \ie
|
|
*
|
|
* RETURNS: The priority value or -1 on failure.
|
|
*
|
|
* ERRNO:
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
IP_GLOBAL int ipmip_util_syslog_priority
|
|
(
|
|
const char *val
|
|
);
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_syslog_priority_name - ipmip_util_syslog_priority_name
|
|
*
|
|
* Convert a priority value to a string priority name
|
|
*
|
|
* Parameters:
|
|
* \is
|
|
* \i val
|
|
* priority value
|
|
* \ie
|
|
*
|
|
* RETURNS: The priority name
|
|
*
|
|
* ERRNO:
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
IP_GLOBAL const char *ipmip_util_syslog_priority_name
|
|
(
|
|
Ip_u32 val
|
|
);
|
|
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_route_table_alloc - ipmip_util_route_table_alloc
|
|
*
|
|
* Allocate a route table
|
|
*
|
|
* Parameters:
|
|
* \is
|
|
* \i ctx
|
|
* The generic mobility singleton context for IPMIP. For each started mobility
|
|
* entity, there exists a mobility context which tracks configuration, system
|
|
* events, available features and started processes. The mobility context is
|
|
* created using ipmip_context_create(). See ipmip_context.h for more information
|
|
* regarding the mobility entity context singleton.
|
|
* \i proc
|
|
* The process context associated with the currently executing thread. Each
|
|
* thread and/or process in MIP must have its own unique process context.
|
|
* If a process is started using ipmip_proc_start, the process context will
|
|
* be allocated automatically by the IPMIP framework. Otherwise it must
|
|
* be allocated using ipmip_proc_alloc().
|
|
* \ie
|
|
*
|
|
* RETURNS: The table number
|
|
*
|
|
* ERRNO:
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
IP_GLOBAL Ip_u32 ipmip_util_route_table_alloc
|
|
(
|
|
struct Ipmip_context *ctx,
|
|
struct Ipmip_proc *proc
|
|
);
|
|
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_route_table_free - ipmip_util_route_table_free
|
|
*
|
|
* Allocate a route table
|
|
*
|
|
* Parameters:
|
|
* \is
|
|
* \i ctx
|
|
* The generic mobility singleton context for IPMIP. For each started mobility
|
|
* entity, there exists a mobility context which tracks configuration, system
|
|
* events, available features and started processes. The mobility context is
|
|
* created using ipmip_context_create(). See ipmip_context.h for more information
|
|
* regarding the mobility entity context singleton.
|
|
* \i proc
|
|
* The process context associated with the currently executing thread. Each
|
|
* thread and/or process in MIP must have its own unique process context.
|
|
* If a process is started using ipmip_proc_start, the process context will
|
|
* be allocated automatically by the IPMIP framework. Otherwise it must
|
|
* be allocated using ipmip_proc_alloc().
|
|
* \i table
|
|
* Table to free
|
|
* \ie
|
|
*
|
|
* RETURNS: No return value
|
|
*
|
|
* ERRNO:
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
IP_GLOBAL void ipmip_util_route_table_free
|
|
(
|
|
struct Ipmip_context *ctx,
|
|
struct Ipmip_proc *proc,
|
|
Ip_u32 table
|
|
);
|
|
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_values_to_hexarray - ipmip_util_values_to_hexarray
|
|
*
|
|
* Values to hexarray. The values are specified as 0x<value>, where the
|
|
* number of digits specify the type. If you do 0xa,0xbbaa,0xbbccd
|
|
* It will be interpreted as: u8,u16,u32
|
|
*
|
|
* Parameters:
|
|
* \is
|
|
* \i value
|
|
* The value to parse
|
|
* \i size
|
|
* The allocated size
|
|
* \ie
|
|
*
|
|
* RETURNS: The array
|
|
*
|
|
* ERRNO:
|
|
*
|
|
*/
|
|
IP_GLOBAL Ip_u8 *ipmip_util_values_to_hexarray
|
|
(
|
|
const char *value,
|
|
Ip_size_t *size
|
|
);
|
|
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_bswap64 - ipmip_util_bswap64
|
|
*
|
|
*
|
|
* Parameters:
|
|
* \is
|
|
* \i u64
|
|
* The value to translate
|
|
* \ie
|
|
*
|
|
* RETURNS: The NTOH64 transformed value
|
|
*
|
|
* ERRNO:
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
IP_GLOBAL Ip_u64 ipmip_util_bswap64
|
|
(
|
|
Ip_u64 *u64
|
|
);
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_time - ipmip_util_time
|
|
*
|
|
* RETURNS: The number of seconds since epoch
|
|
*
|
|
* ERRNO:
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
#define ipmip_util_time() ipcom_time(IP_NULL)
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_safe_time_t - ipmip_util_safe_time_t
|
|
*
|
|
*
|
|
* Parameters:
|
|
* \is
|
|
* \i tt
|
|
* The pointer to a time_t to safely read
|
|
* \ie
|
|
*
|
|
* RETURNS: The time_t
|
|
*
|
|
* ERRNO:
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
IP_GLOBAL Ip_time_t ipmip_util_safe_time_t
|
|
(
|
|
const Ip_time_t *tt
|
|
);
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* ipmip_util_safe_u64 - ipmip_util_safe_u64
|
|
*
|
|
*
|
|
* Parameters:
|
|
* \is
|
|
* \i u64
|
|
* The pointer to a u64 to safely read
|
|
* \ie
|
|
*
|
|
* RETURNS: The u64
|
|
*
|
|
* ERRNO:
|
|
*
|
|
* NOMANUAL
|
|
*/
|
|
IP_GLOBAL Ip_u64 ipmip_util_safe_u64
|
|
(
|
|
const Ip_u64 *u64
|
|
);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|
|
|
|
/*
|
|
****************************************************************************
|
|
* END OF FILE
|
|
****************************************************************************
|
|
*/
|