00001 /*************************************************************************** 00002 * Copyright (C) 2005 by * 00003 * Pedro J. Fernandez Ruiz pedroj.fernandez@dif.um.es * 00004 * Alejandro Perez Mendez alejandro_perez@dif.um.es * 00005 * * 00006 * This library is free software; you can redistribute it and/or * 00007 * modify it under the terms of the GNU Lesser General Public * 00008 * License as published by the Free Software Foundation; either * 00009 * version 2.1 of the License, or (at your option) any later version. * 00010 * * 00011 * This library is distributed in the hope that it will be useful, * 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00014 * Lesser General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU Lesser General Public * 00017 * License along with this library; if not, write to the Free Software * 00018 * Foundation, Inc., 51 Franklin St, Fifth Floor, * 00019 * Boston, MA 02110-1301 USA * 00020 ***************************************************************************/ 00021 00022 #ifndef UTILES_H 00023 #define UTILES_H 00024 00025 #include "pthread.h" 00026 #include "printable.h" 00027 00028 #include <assert.h> 00029 00030 namespace openikev2 { 00031 00032 //**** MASK UTILS ************************************************* 00033 uint8_t mask_to_prefix(uint8_t *mask, uint16_t len); 00034 void prefix_to_mask(uint8_t prefix, uint8_t *mask, uint16_t mask_len); 00035 uint8_t* get_prefix_address(uint8_t *prefix); 00036 int16_t get_prefix_mask(uint8_t *prefix); 00037 bool prefix_cmp(uint8_t *addr1, uint8_t *addr2, uint16_t prefixlen); 00038 //********************************************************************* 00039 00040 //**** PRINTING UTILS ************************************************* 00041 string intToString(uint32_t integer); 00042 string intToString(int32_t integer); 00043 string intToString(uint64_t integer); 00044 string intToString(int64_t integer); 00045 string floatToString(float floating); 00046 string boolToString(bool boolean); 00047 string charToString(char *str); 00048 bool isPrintable(uint8_t *str, uint16_t size); 00049 00050 string getLeftZeroPaddedString(string base, uint16_t pad); 00051 00052 //********************************************************************* 00053 } 00054 00055 #endif
1.5.1