aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2006-12-03 01:04:04 -0500
committerDavid S. Miller <davem@davemloft.net>2006-12-03 01:04:04 -0500
commit9a7c9337a09b1ef07e55f95a4309957a2328a01f (patch)
tree9d382a443d82ece7246fe83d297865b66ace713f
parenta163148c1bec895c1332ea5be497bcda8ce110df (diff)
[NET]: Accept wildcard delimiters in in[46]_pton
Accept -1 as delimiter to abort parsing without an error at the first unknown character. This is needed by the upcoming nf_conntrack SIP helper, where addresses are delimited by either '\r' or '\n' characters. Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/linux/inet.h4
-rw-r--r--net/core/utils.c10
2 files changed, 8 insertions, 6 deletions
diff --git a/include/linux/inet.h b/include/linux/inet.h
index b7c6da7d6d32..675a7dbe86f8 100644
--- a/include/linux/inet.h
+++ b/include/linux/inet.h
@@ -46,7 +46,7 @@
46#include <linux/types.h> 46#include <linux/types.h>
47 47
48extern __be32 in_aton(const char *str); 48extern __be32 in_aton(const char *str);
49extern int in4_pton(const char *src, int srclen, u8 *dst, char delim, const char **end); 49extern int in4_pton(const char *src, int srclen, u8 *dst, int delim, const char **end);
50extern int in6_pton(const char *src, int srclen, u8 *dst, char delim, const char **end); 50extern int in6_pton(const char *src, int srclen, u8 *dst, int delim, const char **end);
51#endif 51#endif
52#endif /* _LINUX_INET_H */ 52#endif /* _LINUX_INET_H */
diff --git a/net/core/utils.c b/net/core/utils.c
index d93fe64f6693..61556065f07e 100644
--- a/net/core/utils.c
+++ b/net/core/utils.c
@@ -88,7 +88,7 @@ EXPORT_SYMBOL(in_aton);
88#define IN6PTON_NULL 0x20000000 /* first/tail */ 88#define IN6PTON_NULL 0x20000000 /* first/tail */
89#define IN6PTON_UNKNOWN 0x40000000 89#define IN6PTON_UNKNOWN 0x40000000
90 90
91static inline int digit2bin(char c, char delim) 91static inline int digit2bin(char c, int delim)
92{ 92{
93 if (c == delim || c == '\0') 93 if (c == delim || c == '\0')
94 return IN6PTON_DELIM; 94 return IN6PTON_DELIM;
@@ -99,7 +99,7 @@ static inline int digit2bin(char c, char delim)
99 return IN6PTON_UNKNOWN; 99 return IN6PTON_UNKNOWN;
100} 100}
101 101
102static inline int xdigit2bin(char c, char delim) 102static inline int xdigit2bin(char c, int delim)
103{ 103{
104 if (c == delim || c == '\0') 104 if (c == delim || c == '\0')
105 return IN6PTON_DELIM; 105 return IN6PTON_DELIM;
@@ -113,12 +113,14 @@ static inline int xdigit2bin(char c, char delim)
113 return (IN6PTON_XDIGIT | (c - 'a' + 10)); 113 return (IN6PTON_XDIGIT | (c - 'a' + 10));
114 if (c >= 'A' && c <= 'F') 114 if (c >= 'A' && c <= 'F')
115 return (IN6PTON_XDIGIT | (c - 'A' + 10)); 115 return (IN6PTON_XDIGIT | (c - 'A' + 10));
116 if (delim == -1)
117 return IN6PTON_DELIM;
116 return IN6PTON_UNKNOWN; 118 return IN6PTON_UNKNOWN;
117} 119}
118 120
119int in4_pton(const char *src, int srclen, 121int in4_pton(const char *src, int srclen,
120 u8 *dst, 122 u8 *dst,
121 char delim, const char **end) 123 int delim, const char **end)
122{ 124{
123 const char *s; 125 const char *s;
124 u8 *d; 126 u8 *d;
@@ -173,7 +175,7 @@ EXPORT_SYMBOL(in4_pton);
173 175
174int in6_pton(const char *src, int srclen, 176int in6_pton(const char *src, int srclen,
175 u8 *dst, 177 u8 *dst,
176 char delim, const char **end) 178 int delim, const char **end)
177{ 179{
178 const char *s, *tok = NULL; 180 const char *s, *tok = NULL;
179 u8 *d, *dc = NULL; 181 u8 *d, *dc = NULL;