| 2497 | |
| 2498 | |
| 2499 | int getVal(db_val_t *val, db_type_t val_type, db_key_t key, ph_db_table_t *table, |
| 2500 | str *arg, str *page, str *buffer, int mod, int cmd) |
| 2501 | { |
| 2502 | char *p = page->s + page->len; |
| 2503 | char *buf = page->s; |
| 2504 | int _len, i; |
| 2505 | int max_page_len = buffer->len; |
| 2506 | ph_val_flags flags; |
| 2507 | |
| 2508 | str host; |
| 2509 | int port, proto; |
| 2510 | struct sip_uri uri; |
| 2511 | char c; |
| 2512 | |
| 2513 | for(i=0;i<table->cols_size;i++){ |
| 2514 | if(table->cols[i].type==val_type && |
| 2515 | table->cols[i].field.len==key->len && |
| 2516 | strncmp(table->cols[i].field.s,key->s,key->len)==0){ |
| 2517 | if(table->cols[i].validation==0) continue; |
| 2518 | flags = table->cols[i].validation; |
| 2519 | LM_DBG("[%.*s] has flags [%u]\n", key->len, key->s, flags); |
| 2520 | if(flags&PH_FLAG_P_HOST_PORT){ |
| 2521 | //flags&= ~ PH_FLAG_P_HOST_PORT; |
| 2522 | if (parse_phostport(arg->s, arg->len, |
| 2523 | &host.s, &host.len, |
| 2524 | &port, &proto)!=0){ |
| 2525 | PI_HTTP_BUILD_REPLY(page, buffer, mod, cmd, |
| 2526 | "Invalid [proto:]host[:port] for" |
| 2527 | "%.*s [%.*s].", |
| 2528 | key->len, key->s, arg->len, arg->s); |
| 2529 | goto done; |
| 2530 | } |
| 2531 | LM_DBG("[%.*s]->[%d][%.*s][%d]\n", |
| 2532 | arg->len, arg->s, proto, |
| 2533 | host.len, host.s, port); |
| 2534 | continue; |
| 2535 | } |
| 2536 | LM_DBG("[%.*s] has flags [%d]\n", key->len, key->s, flags); |
| 2537 | if(flags&PH_FLAG_P_IPV4_PORT){ |
| 2538 | //flags&= ~ PH_FLAG_P_IPV4_PORT; |
| 2539 | if (parse_phostport(arg->s, arg->len, |
| 2540 | &host.s, &host.len, |
| 2541 | &port, &proto)!=0){ |
| 2542 | PI_HTTP_BUILD_REPLY(page, buffer, mod, cmd, |
| 2543 | "Invalid [proto:]IPv4[:port] for" |
| 2544 | " %.*s [%.*s].", |
| 2545 | key->len, key->s, arg->len, arg->s); |
| 2546 | goto done; |
| 2547 | } |
| 2548 | LM_DBG("[%.*s]->[%d][%.*s][%d]\n", |
| 2549 | arg->len, arg->s, proto, |
| 2550 | host.len, host.s, port); |
| 2551 | if (str2ip(&host)==NULL) { |
| 2552 | PI_HTTP_BUILD_REPLY(page, buffer, mod, cmd, |
| 2553 | "Invalid IPv4 in [proto:]IPv4[:port]" |
| 2554 | " %.*s [%.*s][%.*s].", |
| 2555 | key->len, key->s, |
| 2556 | host.len, host.s, |
no test coverage detected