1 /** @file 2 3 unit test stubs header for linking nexthop unit tests. 4 5 @section license License 6 7 Licensed to the Apache Software Foundation (ASF) under one 8 or more contributor license agreements. See the NOTICE file 9 distributed with this work for additional information 10 regarding copyright ownership. The ASF licenses this file 11 to you under the Apache License, Version 2.0 (the 12 "License"); you may not use this file except in compliance 13 with the License. You may obtain a copy of the License at 14 15 http://www.apache.org/licenses/LICENSE-2.0 16 17 Unless required by applicable law or agreed to in writing, software 18 distributed under the License is distributed on an "AS IS" BASIS, 19 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 See the License for the specific language governing permissions and 21 limitations under the License. 22 23 @section details Details 24 25 Implements code necessary for Reverse Proxy which mostly consists of 26 general purpose hostname substitution in URLs. 27 28 */ 29 30 #pragma once 31 32 #include <map> 33 #include <string> 34 #include <iostream> 35 36 #include <stdio.h> 37 #include <stdarg.h> 38 39 #ifdef __cplusplus 40 extern "C" { 41 #endif /* __cplusplus */ 42 43 #define NH_Debug(tag, fmt, ...) PrintToStdErr("%s %s:%d:%s() " fmt "\n", tag, __FILE__, __LINE__, __func__, ##__VA_ARGS__) 44 #define NH_Error(fmt, ...) PrintToStdErr("%s:%d:%s() " fmt "\n", __FILE__, __LINE__, __func__, ##__VA_ARGS__) 45 #define NH_Note(fmt, ...) PrintToStdErr("%s:%d:%s() " fmt "\n", __FILE__, __LINE__, __func__, ##__VA_ARGS__) 46 #define NH_Warn(fmt, ...) PrintToStdErr("%s:%d:%s() " fmt "\n", __FILE__, __LINE__, __func__, ##__VA_ARGS__) 47 48 class HttpRequestData; 49 50 void PrintToStdErr(const char *fmt, ...); 51 void build_request(HttpRequestData &h, const char *os_hostname); 52 53 #ifdef __cplusplus 54 } 55 #endif /* __cplusplus */ 56 57 #include "ControlMatcher.h" 58 #include "ParentSelection.h" 59 60 struct trans_config { 61 int64_t parent_retry_time = 0; 62 int64_t parent_fail_threshold = 0; trans_configtrans_config63 trans_config() {} 64 }; 65 66 struct trans_state { 67 ParentResult parent_result; 68 HttpRequestData request_data; 69 trans_config txn_conf; trans_statetrans_state70 trans_state() {} 71 }; 72 73 class HttpSM; 74 75 void br_destroy(HttpSM &sm); 76 77 void build_request(int64_t sm_id, HttpSM *sm, sockaddr_in *ip, const char *os_hostname, sockaddr const *dest_ip); 78