| 106 | } |
| 107 | |
| 108 | int |
| 109 | parse_range(const char *token, uint16_t *low, uint16_t *high) |
| 110 | { |
| 111 | char ch; |
| 112 | char num_str[20]; |
| 113 | uint32_t pos; |
| 114 | int range_low = -1; |
| 115 | int range_high = -1; |
| 116 | |
| 117 | if (!low || !high) |
| 118 | return -1; |
| 119 | |
| 120 | memset(num_str, 0, 20); |
| 121 | pos = 0; |
| 122 | |
| 123 | while ((ch = *token++) != '\0') { |
| 124 | if (isdigit(ch)) { |
| 125 | if (pos >= 19) |
| 126 | return -1; |
| 127 | num_str[pos++] = ch; |
| 128 | } else if (ch == ':') { |
| 129 | if (range_low != -1) |
| 130 | return -1; |
| 131 | range_low = atoi(num_str); |
| 132 | memset(num_str, 0, 20); |
| 133 | pos = 0; |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | if (strlen(num_str) == 0) |
| 138 | return -1; |
| 139 | |
| 140 | range_high = atoi(num_str); |
| 141 | |
| 142 | *low = (uint16_t)range_low; |
| 143 | *high = (uint16_t)range_high; |
| 144 | |
| 145 | return 0; |
| 146 | } |
| 147 | |
| 148 | /* |
| 149 | * helper function for parse_mac, parse one section of the ether addr. |
no test coverage detected