diff options
Diffstat (limited to 'drivers/s390/net/qeth.h')
-rw-r--r-- | drivers/s390/net/qeth.h | 114 |
1 files changed, 47 insertions, 67 deletions
diff --git a/drivers/s390/net/qeth.h b/drivers/s390/net/qeth.h index d238c7ed103b..4df0fcd7b10b 100644 --- a/drivers/s390/net/qeth.h +++ b/drivers/s390/net/qeth.h | |||
@@ -25,8 +25,6 @@ | |||
25 | 25 | ||
26 | #include "qeth_mpc.h" | 26 | #include "qeth_mpc.h" |
27 | 27 | ||
28 | #define VERSION_QETH_H "$Revision: 1.152 $" | ||
29 | |||
30 | #ifdef CONFIG_QETH_IPV6 | 28 | #ifdef CONFIG_QETH_IPV6 |
31 | #define QETH_VERSION_IPV6 ":IPv6" | 29 | #define QETH_VERSION_IPV6 ":IPv6" |
32 | #else | 30 | #else |
@@ -1078,16 +1076,6 @@ qeth_get_qdio_q_format(struct qeth_card *card) | |||
1078 | } | 1076 | } |
1079 | 1077 | ||
1080 | static inline int | 1078 | static inline int |
1081 | qeth_isdigit(char * buf) | ||
1082 | { | ||
1083 | while (*buf) { | ||
1084 | if (!isdigit(*buf++)) | ||
1085 | return 0; | ||
1086 | } | ||
1087 | return 1; | ||
1088 | } | ||
1089 | |||
1090 | static inline int | ||
1091 | qeth_isxdigit(char * buf) | 1079 | qeth_isxdigit(char * buf) |
1092 | { | 1080 | { |
1093 | while (*buf) { | 1081 | while (*buf) { |
@@ -1106,33 +1094,17 @@ qeth_ipaddr4_to_string(const __u8 *addr, char *buf) | |||
1106 | static inline int | 1094 | static inline int |
1107 | qeth_string_to_ipaddr4(const char *buf, __u8 *addr) | 1095 | qeth_string_to_ipaddr4(const char *buf, __u8 *addr) |
1108 | { | 1096 | { |
1109 | const char *start, *end; | 1097 | int count = 0, rc = 0; |
1110 | char abuf[4]; | 1098 | int in[4]; |
1111 | char *tmp; | 1099 | |
1112 | int len; | 1100 | rc = sscanf(buf, "%d.%d.%d.%d%n", |
1113 | int i; | 1101 | &in[0], &in[1], &in[2], &in[3], &count); |
1114 | 1102 | if (rc != 4 || count) | |
1115 | start = buf; | 1103 | return -EINVAL; |
1116 | for (i = 0; i < 4; i++) { | 1104 | for (count = 0; count < 4; count++) { |
1117 | if (i == 3) { | 1105 | if (in[count] > 255) |
1118 | end = strchr(start,0xa); | ||
1119 | if (end) | ||
1120 | len = end - start; | ||
1121 | else | ||
1122 | len = strlen(start); | ||
1123 | } | ||
1124 | else { | ||
1125 | end = strchr(start, '.'); | ||
1126 | len = end - start; | ||
1127 | } | ||
1128 | if ((len <= 0) || (len > 3)) | ||
1129 | return -EINVAL; | ||
1130 | memset(abuf, 0, 4); | ||
1131 | strncpy(abuf, start, len); | ||
1132 | if (!qeth_isdigit(abuf)) | ||
1133 | return -EINVAL; | 1106 | return -EINVAL; |
1134 | addr[i] = simple_strtoul(abuf, &tmp, 10); | 1107 | addr[count] = in[count]; |
1135 | start = end + 1; | ||
1136 | } | 1108 | } |
1137 | return 0; | 1109 | return 0; |
1138 | } | 1110 | } |
@@ -1151,36 +1123,44 @@ qeth_ipaddr6_to_string(const __u8 *addr, char *buf) | |||
1151 | static inline int | 1123 | static inline int |
1152 | qeth_string_to_ipaddr6(const char *buf, __u8 *addr) | 1124 | qeth_string_to_ipaddr6(const char *buf, __u8 *addr) |
1153 | { | 1125 | { |
1154 | const char *start, *end; | 1126 | char *end, *start; |
1155 | u16 *tmp_addr; | 1127 | __u16 *in; |
1156 | char abuf[5]; | 1128 | char num[5]; |
1157 | char *tmp; | 1129 | int num2, cnt, out, found, save_cnt; |
1158 | int len; | 1130 | unsigned short in_tmp[8] = {0, }; |
1159 | int i; | 1131 | |
1160 | 1132 | cnt = out = found = save_cnt = num2 = 0; | |
1161 | tmp_addr = (u16 *)addr; | 1133 | end = start = (char *) buf; |
1162 | start = buf; | 1134 | in = (__u16 *) addr; |
1163 | for (i = 0; i < 8; i++) { | 1135 | memset(in, 0, 16); |
1164 | if (i == 7) { | 1136 | while (end) { |
1165 | end = strchr(start,0xa); | 1137 | end = strchr(end,':'); |
1166 | if (end) | 1138 | if (end == NULL) { |
1167 | len = end - start; | 1139 | end = (char *)buf + (strlen(buf)); |
1168 | else | 1140 | out = 1; |
1169 | len = strlen(start); | 1141 | } |
1170 | } | 1142 | if ((end - start)) { |
1171 | else { | 1143 | memset(num, 0, 5); |
1172 | end = strchr(start, ':'); | 1144 | memcpy(num, start, end - start); |
1173 | len = end - start; | 1145 | if (!qeth_isxdigit(num)) |
1146 | return -EINVAL; | ||
1147 | sscanf(start, "%x", &num2); | ||
1148 | if (found) | ||
1149 | in_tmp[save_cnt++] = num2; | ||
1150 | else | ||
1151 | in[cnt++] = num2; | ||
1152 | if (out) | ||
1153 | break; | ||
1154 | } else { | ||
1155 | if (found) | ||
1156 | return -EINVAL; | ||
1157 | found = 1; | ||
1174 | } | 1158 | } |
1175 | if ((len <= 0) || (len > 4)) | 1159 | start = ++end; |
1176 | return -EINVAL; | 1160 | } |
1177 | memset(abuf, 0, 5); | 1161 | cnt = 7; |
1178 | strncpy(abuf, start, len); | 1162 | while (save_cnt) |
1179 | if (!qeth_isxdigit(abuf)) | 1163 | in[cnt--] = in_tmp[--save_cnt]; |
1180 | return -EINVAL; | ||
1181 | tmp_addr[i] = simple_strtoul(abuf, &tmp, 16); | ||
1182 | start = end + 1; | ||
1183 | } | ||
1184 | return 0; | 1164 | return 0; |
1185 | } | 1165 | } |
1186 | 1166 | ||