OpenHIP 0.9svn1
/home/tomh/svn/openhip/hip/trunk/src/include/hip/hip_cfg_api.h
Go to the documentation of this file.
00001 /* -*- Mode:cc-mode; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
00002 /* vim: set ai sw=2 ts=2 et cindent cino={1s: */
00003 /*
00004  * Host Identity Protocol
00005  * Copyright (c) 2008-2012 the Boeing Company
00006  * 
00007  * Permission is hereby granted, free of charge, to any person obtaining a copy
00008  * of this software and associated documentation files (the "Software"), to deal
00009  * in the Software without restriction, including without limitation the rights
00010  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00011  * copies of the Software, and to permit persons to whom the Software is
00012  * furnished to do so, subject to the following conditions:
00013  * 
00014  * The above copyright notice and this permission notice shall be included in
00015  * all copies or substantial portions of the Software.
00016  * 
00017  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00018  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00019  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00020  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00021  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00022  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00023  * THE SOFTWARE.
00024  *
00025  *  \file  hip_cfg_api.h
00026  *
00027  *  \authors    Jin Fang <jin.fang@boeing.com>
00028  *
00029  *  \brief  Configuration API definitions.
00030  */
00031 
00032 #ifndef _HIP_CFG_API_H_
00033 #define _HIP_CFG_API_H_
00034 #include <sys/types.h>
00035 #include <sys/socket.h>
00036 #include <net/ethernet.h>
00037 #include <hip/hip_types.h>
00038 
00039 /* Input: the name of the dynamic link library
00040  *    e.g. the xml file based library "libhipcfg.so"
00041  *   Return: 0 if succeed, non-zero if error.
00042  */
00043 #define hipcfg_init_fn "hipcfg_init"
00044 extern int (*hipcfg_init_p)(struct hip_conf *hc);
00045 extern int hipcfg_init(char *dlname, struct hip_conf *hc);
00046 
00047 /* Input: none
00048  *   Return: 0 if succeed, non-zero if error.
00049  */
00050 #define hipcfg_close_fn "hipcfg_close"
00051 extern int (*hipcfg_close_p)();
00052 extern int hipcfg_close();
00053 
00054 /* Input: the two peer hosts identified by their HITs
00055  * Return: 1 if a HIP base exchange is allowed between the peers.
00056  *         0 otherwise.
00057  */
00058 #define hipcfg_allowed_peers_fn "hipcfg_allowed_peers"
00059 extern int (*hipcfg_allowed_peers_p)(const hip_hit hit1, const hip_hit hit2);
00060 extern int hipcfg_allowed_peers(const hip_hit hit1, const hip_hit hit2);
00061 
00062 
00063 /* Get all pairs of peers allowed to comunicate with each other
00064  * Return: the number of hit pairs returned if succeed
00065  *         0 if no such hit pair
00066  *         -1 if error.
00067  * Note: hits1 and hits2 are arrays with the at least max_cnt size, and have
00068  **pre-alloced
00069  *       when calling this function.
00070  */
00071 #define hipcfg_peers_allowed_fn "hipcfg_peers_allowed"
00072 extern int (*hipcfg_peers_allowed_p)(hip_hit *hits1, hip_hit *hits2,
00073                                      int max_cnt);
00074 extern int hipcfg_peers_allowed(hip_hit *hits1, hip_hit *hits2, int max_cnt);
00075 
00076 
00077 /* Set the Endbox Underlay IP Address
00078  * Input: ip - the current Underlay IP address of the endbox
00079  *             the sockaddr should point to a sockaddr_storage structure so that
00080  *             either an IPv4 or IPv6 address can be passed in. The sa_family
00081  **must
00082  *             be set to AF_INET for an IPv4 address, or AF_INET6 for an IPv6
00083  **address.
00084  *
00085  * Output: none
00086  *
00087  * Return: 0 on success, -1 on error
00088  */
00089 #define hipcfg_setUnderlayIpAddress_fn "hipcfg_setUnderlayIpAddress"
00090 extern int (*hipcfg_setUnderlayIpAddress_p)(const char *ip);
00091 extern int hipcfg_setUnderlayIpAddress(const char *ip);
00092 
00093 
00094 /* Input: host - the legacy host IPv4/IPv6 address
00095  *               the sockaddr should point to a sockaddr_storage structure so
00096  **that
00097  *               either an IPv4 or IPv6 address can be passed in. The sa_family
00098  **must
00099  *               be set to AF_INET for an IPv4 address, or AF_INET6 for an IPv6
00100  **address.
00101  * Output: eb - the endbox's LSI/HIT. sockaddr should point to a
00102  **sockaddr_storage
00103  *              structure so that either an IPv4 or IPv6 address can be
00104  **returned.
00105  *              When the call is returned, the sa_family is set to AF_INET if
00106  *              sockaddr_storage contains an IPv4 address, or AF_INET6 if it
00107  *              contains an IPv6 address.
00108  * Return: 0 if the mapping found, a positive number if not found, -1 if error.
00109  *
00110  * Note: the old function is find_endbox2() which
00111  *       looking up file host_map.
00112  */
00113 #define hipcfg_getEndboxByLegacyNode_fn "hipcfg_getEndboxByLegacyNode"
00114 extern int (*hipcfg_getEndboxByLegacyNode_p)(const struct sockaddr *host,
00115                                              struct sockaddr *eb);
00116 extern int hipcfg_getEndboxByLegacyNode(const struct sockaddr *host,
00117                                         struct sockaddr *eb);
00118 
00119 /* Input: eb - endbox address either in IPv4 (LSI) or IPv6 (HIT)
00120  *             The sa_family must be set to ether  AF_INET or AF_INET6
00121  *             before calling this function.
00122  * Output: llip -  lower layer IP address, either IPv4/v6.
00123  *             sa_family will be set to either AF_INET or AF_INET6 after
00124  **successfully
00125  *             calling this function per its actual IP address family.
00126  * Return: 0 - if the lookup succeeed, 1 - if the mapping is not found, -1 if
00127  **error.
00128  */
00129 #define hipcfg_getLlipByEndbox_fn "hipcfg_getLlipByEndbox"
00130 extern int (*hipcfg_getLlipByEndbox_p)(const struct sockaddr *eb,
00131                                        struct sockaddr *llip);
00132 extern int hipcfg_getLlipByEndbox(const struct sockaddr *eb,
00133                                   struct sockaddr *llip);
00134 
00135 /* Input eb - endbox address either in IPv4 (LSI) or IPv6 (HIT)
00136  *            The sa_family must be set to ether  AF_INET or AF_INET6
00137  *            before calling this function.
00138  * Output hosts - an array of legacy nodes. sa_family of each element
00139  *                will be set to either AF_INET or AF_INET6 per its actual IP
00140  **address family
00141  *                The caller must provide the storage for the  array.
00142  *        size - the size of array hosts (maximum number of elements can be
00143  **returned).
00144  * Return -1 if error,  0 if cannot find a match, a positivie number for the
00145  **actual elements in hosts.
00146  */
00147 #define hipcfg_getLegacyNodesByEndbox_fn "hipcfg_getLegacyNodesByEndbox"
00148 extern int (*hipcfg_getLegacyNodesByEndbox_p)(const struct sockaddr *eb,
00149                                               struct sockaddr_storage *hosts,
00150                                               int size);
00151 extern int hipcfg_getLegacyNodesByEndbox(const struct sockaddr *eb,
00152                                          struct sockaddr_storage *hosts,
00153                                          int size);
00154 
00155 /* obtain the certificate that hold host identity (public key) in PEM format
00156  * indexed by hit
00157  * that is derived from the public key
00158  * Input: hit - the hit in IPv6 notation string
00159  *        size - the buffer size
00160  *
00161  * Output: cert - a buffer that will hold certificate in PEM format
00162  * Return -1 if error,  0 if succeeded
00163  */
00164 #define hipcfg_verifyCert_fn "hipcfg_verifyCert"
00165 extern int (*hipcfg_verifyCert_p)(const char *url, const hip_hit hit1);
00166 extern int hipcfg_verifyCert(const char *url, const hip_hit hit1);
00167 
00168 /* obtain the local certificate URL which is null terminated string
00169  *
00170  * Output: url - a buffer that will hold url certificate URL
00171  * Input:  size - the buffer size
00172  * Return -1 if error,  0 if succeeded
00173  */
00174 #define hipcfg_getLocalCertUrl_fn "hipcfg_getLocalCertUrl"
00175 extern int (*hipcfg_getLocalCertUrl_p)(char *url, unsigned int size);
00176 extern int hipcfg_getLocalCertUrl(char *url, unsigned int size);
00177 
00178 /* Post the certificate that holds host identity (public key) in PEM format
00179  * indexed by hit
00180  * that is derived from the public key
00181  * Input: hit - the hit in IPv6 notation string
00182  *        cert - a null terminated certificate in PEM format
00183  * Return -1 if error,  0 if succeeded.
00184  */
00185 #define hipcfg_postLocalCert_fn "hipcfg_postLocalCert"
00186 extern int (*hipcfg_postLocalCert_p)(const char *hit);
00187 extern int hipcfg_postLocalCert(const char *hit);
00188 
00189 /* return a pointer to the local host identity struct */
00190 #define hipcfg_getMyHostId_fn "hipcfg_getMyHostId"
00191 extern hi_node *(*hipcfg_getMyHostId_p)();
00192 extern hi_node *hipcfg_getMyHostId();
00193 
00194 /* Get an array of configured known host peers.
00195  *  return a positive number indicating the number of actual entries.
00196  *         0 if there is no entries
00197  *        -1 if error
00198  *  Input:
00199  *       peerNodes: an array of peer_node which will hold the configured peers
00200  *                  the memory must have been allocated before calling the
00201  * function.
00202  *       max_count: the size of the peerNodes array
00203  *
00204  */
00205 
00206 #define hipcfg_getPeerNodes_fn "hipcfg_getPeerNodes"
00207 extern int (*hipcfg_getPeerNodes_p)(struct peer_node *peerNodes,
00208                                     unsigned int max_count);
00209 extern int hipcfg_getPeerNodes(struct peer_node *peerNodes,
00210                                unsigned int max_count);
00211 
00212 #endif