utils.c (daab7fc734a53fdeaf844b7c03053118ad1769da) | utils.c (82fd5b5d1ec370a50b3060418cde6a4ac8401117) |
---|---|
1/* 2 * Generic address resultion entity 3 * 4 * Authors: 5 * net_random Alan Cox 6 * net_ratelimit Andi Kleen 7 * in{4,6}_pton YOSHIFUJI Hideaki, Copyright (C)2006 USAGI/WIDE Project 8 * --- 78 unchanged lines hidden (view full) --- 87#define IN6PTON_COLON_1_2 0x00400000 /* :: requested */ 88#define IN6PTON_DOT 0x00800000 /* . */ 89#define IN6PTON_DELIM 0x10000000 90#define IN6PTON_NULL 0x20000000 /* first/tail */ 91#define IN6PTON_UNKNOWN 0x40000000 92 93static inline int xdigit2bin(char c, int delim) 94{ | 1/* 2 * Generic address resultion entity 3 * 4 * Authors: 5 * net_random Alan Cox 6 * net_ratelimit Andi Kleen 7 * in{4,6}_pton YOSHIFUJI Hideaki, Copyright (C)2006 USAGI/WIDE Project 8 * --- 78 unchanged lines hidden (view full) --- 87#define IN6PTON_COLON_1_2 0x00400000 /* :: requested */ 88#define IN6PTON_DOT 0x00800000 /* . */ 89#define IN6PTON_DELIM 0x10000000 90#define IN6PTON_NULL 0x20000000 /* first/tail */ 91#define IN6PTON_UNKNOWN 0x40000000 92 93static inline int xdigit2bin(char c, int delim) 94{ |
95 int val; 96 |
|
95 if (c == delim || c == '\0') 96 return IN6PTON_DELIM; 97 if (c == ':') 98 return IN6PTON_COLON_MASK; 99 if (c == '.') 100 return IN6PTON_DOT; | 97 if (c == delim || c == '\0') 98 return IN6PTON_DELIM; 99 if (c == ':') 100 return IN6PTON_COLON_MASK; 101 if (c == '.') 102 return IN6PTON_DOT; |
101 if (c >= '0' && c <= '9') 102 return (IN6PTON_XDIGIT | IN6PTON_DIGIT| (c - '0')); 103 if (c >= 'a' && c <= 'f') 104 return (IN6PTON_XDIGIT | (c - 'a' + 10)); 105 if (c >= 'A' && c <= 'F') 106 return (IN6PTON_XDIGIT | (c - 'A' + 10)); | 103 104 val = hex_to_bin(c); 105 if (val >= 0) 106 return val | IN6PTON_XDIGIT | (val < 10 ? IN6PTON_DIGIT : 0); 107 |
107 if (delim == -1) 108 return IN6PTON_DELIM; 109 return IN6PTON_UNKNOWN; 110} 111 112int in4_pton(const char *src, int srclen, 113 u8 *dst, 114 int delim, const char **end) --- 183 unchanged lines hidden --- | 108 if (delim == -1) 109 return IN6PTON_DELIM; 110 return IN6PTON_UNKNOWN; 111} 112 113int in4_pton(const char *src, int srclen, 114 u8 *dst, 115 int delim, const char **end) --- 183 unchanged lines hidden --- |