| 8425 | } |
| 8426 | |
| 8427 | TSReturnCode |
| 8428 | TSVConnPPInfoGet(TSVConn vconn, uint16_t key, const char **value, int *length) |
| 8429 | { |
| 8430 | NetVConnection *vc = reinterpret_cast<NetVConnection *>(vconn); |
| 8431 | |
| 8432 | if (key < 0x100) { |
| 8433 | auto &tlv = vc->get_proxy_protocol_info().tlv; |
| 8434 | if (auto ite = tlv.find(key); ite != tlv.end()) { |
| 8435 | *value = ite->second.data(); |
| 8436 | *length = ite->second.length(); |
| 8437 | } else { |
| 8438 | return TS_ERROR; |
| 8439 | } |
| 8440 | } else { |
| 8441 | switch (key) { |
| 8442 | case TS_PP_INFO_SRC_ADDR: |
| 8443 | *value = reinterpret_cast<const char *>(vc->get_proxy_protocol_src_addr()); |
| 8444 | if (*value == nullptr) { |
| 8445 | return TS_ERROR; |
| 8446 | } |
| 8447 | *length = ats_ip_size(reinterpret_cast<const sockaddr *>(*value)); |
| 8448 | break; |
| 8449 | case TS_PP_INFO_DST_ADDR: |
| 8450 | *value = reinterpret_cast<const char *>(vc->get_proxy_protocol_dst_addr()); |
| 8451 | if (*value == nullptr) { |
| 8452 | return TS_ERROR; |
| 8453 | } |
| 8454 | *length = ats_ip_size(reinterpret_cast<const sockaddr *>(*value)); |
| 8455 | break; |
| 8456 | default: |
| 8457 | return TS_ERROR; |
| 8458 | } |
| 8459 | } |
| 8460 | |
| 8461 | return TS_SUCCESS; |
| 8462 | } |
| 8463 | |
| 8464 | TSReturnCode |
| 8465 | TSVConnPPInfoIntGet(TSVConn vconn, uint16_t key, TSMgmtInt *value) |