Changeset 50135 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Jan 21, 2014 9:28:21 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/slirp/resolv_conf_parser.c
r50131 r50135 1 1 /* $Id$ */ 2 2 /** @file 3 * resolv_conf_parser.c - parser of resolv.conf resolver(5) 3 * resolv_conf_parser.c - parser of resolv.conf resolver(5) 4 4 */ 5 5 … … 29 29 #include "resolv_conf_parser.h" 30 30 31 enum RCP_TOKEN { 31 enum RCP_TOKEN 32 { 32 33 tok_eof = -1, /* EOF */ 33 34 tok_string = -2, /* string */ … … 90 91 int xdigit, digit, dot_number; 91 92 RT_ZERO(parser->rcpp_str_buffer); 92 93 93 94 dot_number = 0; 94 95 xdigit = 1; … … 116 117 { 117 118 int port = 0; 118 do 119 do 119 120 { 120 121 *ptr++ = tok; … … 127 128 128 129 PARSER_BUFFER_EXCEEDED(parser, ptr); 129 130 if (port == 0) 130 131 if (port == 0) 131 132 return tok_ipv6; 132 133 else if (port == 1) 133 134 return tok_ipv6_port; 134 else 135 else 135 136 { 136 137 /* eats rest of the token */ 137 do 138 do 138 139 { 139 140 *ptr++ = tok; 140 141 tok = GETCHAR(parser); 141 } while( PARSER_STOP(tok, parser, ptr) 142 } while( PARSER_STOP(tok, parser, ptr) 142 143 && (isalnum(tok) || tok == '.' || tok == '_' || tok == '-')); 143 144 144 145 PARSER_BUFFER_EXCEEDED(parser, ptr); 145 146 146 147 return tok_string; 147 148 } … … 161 162 digit &= (isdigit(tok) || (tok == '.')); 162 163 tok = GETCHAR(parser); 163 } while( PARSER_STOP(tok, parser, ptr) 164 } while( PARSER_STOP(tok, parser, ptr) 164 165 && (isalnum(tok) || tok == '.' || tok == '_' || tok == '-')); 165 166 166 167 PARSER_BUFFER_EXCEEDED(parser, ptr); 167 168 … … 175 176 } while( PARSER_STOP(tok, parser, ptr) 176 177 && (isalnum(tok) || tok == ':' || tok == '.' || tok == '-' || tok == '_')); 177 178 178 179 PARSER_BUFFER_EXCEEDED(parser, ptr); 179 180 … … 207 208 tok = GETCHAR(parser); 208 209 } while (tok != EOF && tok != '\r' && tok != '\n'); 209 210 210 211 if (tok == EOF) return tok_eof; 211 212 … … 239 240 { 240 241 struct rcp_state *st; 242 RTNETADDR *address; 243 char *str_address; 244 241 245 Assert(parser->rcpp_state); 242 246 243 247 st = parser->rcpp_state; 244 RTNETADDR *address = &st->rcps_nameserver[st->rcps_num_nameserver];245 char *str_address = &st->rcps_nameserver_str_buffer[st->rcps_num_nameserver * RCPS_IPVX_SIZE];248 address = &st->rcps_nameserver[st->rcps_num_nameserver]; 249 str_address = &st->rcps_nameserver_str_buffer[st->rcps_num_nameserver * RCPS_IPVX_SIZE]; 246 250 #ifdef RT_OS_DARWIN 247 251 if ( tok == tok_ipv4_port … … 266 270 267 271 strcpy(str_address, parser->rcpp_str_buffer); 268 272 269 273 st->rcps_str_nameserver[st->rcps_num_nameserver] = str_address; 270 274 … … 279 283 int rc = RTNetStrToIPv4Addr(parser->rcpp_str_buffer, &address->uAddr.IPv4); 280 284 if (RT_FAILURE(rc)) return tok_error; 281 285 282 286 address->enmType = RTNETADDRTYPE_IPV4; 283 287 } … … 325 329 st = parser->rcpp_state; 326 330 327 if ( tok != tok_number 331 if ( tok != tok_number 328 332 || tok == tok_eof) 329 333 return tok_error; … … 349 353 350 354 /** 351 * It's nowhere specified how resolver should react on dublicats 355 * It's nowhere specified how resolver should react on dublicats 352 356 * of 'domain' declarations, let's assume that resolv.conf is broken. 353 357 */ … … 359 363 strcpy(st->rcps_domain_buffer, parser->rcpp_str_buffer); 360 364 /** 361 * We initialize this pointer in place, just make single pointer check 362 * in 'domain'-less resolv.conf. 365 * We initialize this pointer in place, just make single pointer check 366 * in 'domain'-less resolv.conf. 363 367 */ 364 368 st->rcps_domain = st->rcps_domain_buffer; … … 383 387 Assert(parser->rcpp_state); 384 388 st = parser->rcpp_state; 385 389 386 390 /** 387 * We asume that duplication of search list in resolv.conf isn't correct. 391 * We asume that duplication of search list in resolv.conf isn't correct. 388 392 */ 389 393 if ( tok == tok_eof … … 406 410 trailing -= len + 1; /* 1 reserved for '\0' */ 407 411 408 st->rcps_searchlist[i] = ptr; 409 410 } while( (tok = rcp_get_token(parser)) == tok_string 412 st->rcps_searchlist[i] = ptr; 413 414 } while( (tok = rcp_get_token(parser)) == tok_string 411 415 && ++i != RCPS_MAX_SEARCHLIST); 412 416 … … 420 424 * ::= portexpr | expr 421 425 * ::= domainexpr | expr 422 * ::= searchexpr | expr 426 * ::= searchexpr | expr 423 427 * ::= searchlistexpr | expr 424 428 * ::= search_orderexpr | expr … … 432 436 433 437 while( tok != tok_eof 434 && tok != tok_error) 438 && tok != tok_error) 435 439 { 436 440 switch (tok) … … 476 480 477 481 /** 478 * for debugging need: with RCP_STANDALONE it's possible 482 * for debugging need: with RCP_STANDALONE it's possible 479 483 * to run simplefied scenarious like 480 484 * 481 * # cat /etc/resolv.conf | rcp-test-0 485 * # cat /etc/resolv.conf | rcp-test-0 482 486 * or in lldb 483 487 * # process launch -i /etc/resolv.conf … … 501 505 RTStrmClose(parser.rcpp_stream); 502 506 503 if (rc == -1) 507 if (rc == -1) 504 508 return -1; 505 509 … … 512 516 state->rcps_port = 53; 513 517 514 for(i = 0; (state->rcps_flags & RCPSF_NO_STR2IPCONV) == 0 518 for(i = 0; (state->rcps_flags & RCPSF_NO_STR2IPCONV) == 0 515 519 && i != RCPS_MAX_NAMESERVERS; ++i) 516 520 {
Note:
See TracChangeset
for help on using the changeset viewer.