* transform_connect * Description: Issue a socket connection to icap server. */
| 441 | * Description: Issue a socket connection to icap server. |
| 442 | */ |
| 443 | static int |
| 444 | transform_connect(TSCont contp, TransformData *data) |
| 445 | { |
| 446 | TSAction action; |
| 447 | struct sockaddr_in ip_addr; |
| 448 | data->state = State::CONNECT; |
| 449 | |
| 450 | /* Only support IPv4 at this point */ |
| 451 | memset(&ip_addr, 0, sizeof(ip_addr)); |
| 452 | ip_addr.sin_family = AF_INET; |
| 453 | ip_addr.sin_port = htons(server_port); |
| 454 | if (inet_pton(AF_INET, server_ip.c_str(), &ip_addr.sin_addr) <= 0) { |
| 455 | TSError("[%s] Invalid address: %s", PLUGIN_NAME, server_ip.c_str()); |
| 456 | return 0; |
| 457 | } |
| 458 | action = TSNetConnect(contp, reinterpret_cast<struct sockaddr const *>(&ip_addr)); |
| 459 | |
| 460 | if (!TSActionDone(action)) { |
| 461 | data->pending_action = action; |
| 462 | } |
| 463 | |
| 464 | return 0; |
| 465 | } |
| 466 | |
| 467 | static int |
| 468 | transform_write_body(TransformData *data) |
no test coverage detected