2016-11-02 16:27:58 +00:00
|
|
|
#ifndef PROTOUTILS
|
|
|
|
#define PROTOUTILS
|
2017-02-13 18:25:43 +00:00
|
|
|
|
2016-11-09 22:53:11 +00:00
|
|
|
//////////////////////////////////////////////////////////
|
2017-02-13 18:25:43 +00:00
|
|
|
char ASCII2bits(char ch);
|
|
|
|
|
|
|
|
void hex2bin (char *dst, char *src, int len);
|
2016-11-09 22:53:11 +00:00
|
|
|
|
2017-02-13 18:25:43 +00:00
|
|
|
char bits2ASCII(char b);
|
2016-11-02 16:27:58 +00:00
|
|
|
|
2017-02-13 18:25:43 +00:00
|
|
|
void bin2hex (char *dst, char *src, int len);
|
2016-11-09 22:53:11 +00:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////
|
2016-11-02 16:27:58 +00:00
|
|
|
//IPv4 VALIDATOR
|
|
|
|
#define DELIM "."
|
|
|
|
|
|
|
|
/* return 1 if string contain only digits, else return 0 */
|
2017-02-13 18:25:43 +00:00
|
|
|
int valid_digit(char *ip_str);
|
2016-11-02 16:27:58 +00:00
|
|
|
|
2017-02-13 18:25:43 +00:00
|
|
|
/* return 1 if IP string is valid, else return 0 */
|
|
|
|
int is_valid_ipv4(char *ip_str);
|
2016-11-02 16:27:58 +00:00
|
|
|
|
|
|
|
//////////////IPv6 Validator
|
|
|
|
#define MAX_HEX_NUMBER_COUNT 8
|
|
|
|
|
2017-02-13 18:25:43 +00:00
|
|
|
int ishexdigit(char ch);
|
2016-11-02 16:27:58 +00:00
|
|
|
|
2017-02-13 18:25:43 +00:00
|
|
|
int is_valid_ipv6(char *str);
|
2016-11-02 16:27:58 +00:00
|
|
|
|
2017-02-13 19:12:32 +00:00
|
|
|
uint64_t ip2int(const char * ipconvertint);
|
2016-11-02 16:27:58 +00:00
|
|
|
|
2017-02-13 18:25:43 +00:00
|
|
|
char * int2ip(int inputintip);
|
2016-11-02 16:27:58 +00:00
|
|
|
|
2016-11-06 01:57:36 +00:00
|
|
|
//I didn't feel another address_bytes_to_string was necesarry sry guys
|
2017-02-13 19:12:32 +00:00
|
|
|
int bytes_to_string(char * resultzx, const uint8_t * catx,int xbsize);
|
2017-02-13 18:25:43 +00:00
|
|
|
|
2017-02-13 19:12:32 +00:00
|
|
|
char * address_string_to_bytes(struct protocol * xx, const char * abc, size_t getsznow);
|
2016-11-06 01:57:36 +00:00
|
|
|
|
2017-02-13 19:12:32 +00:00
|
|
|
int string_to_bytes(uint8_t * finalbytes,size_t* realbbsize,char * strx, size_t strsize);
|
2016-11-08 11:02:45 +00:00
|
|
|
|
2016-11-06 01:57:36 +00:00
|
|
|
#endif
|