JosiahWI commented on code in PR #13384: URL: https://github.com/apache/trafficserver/pull/13384#discussion_r3587310768
########## tests/tools/plugins/packet_mark_common.cc: ########## @@ -0,0 +1,186 @@ +/** @file + + Shared helpers for the packet-mark test plugins. + + @section license License + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#include "packet_mark_common.h" + +extern "C" { +#include <sys/socket.h> +} + +#include <cerrno> +#include <cstdint> +#include <cstdio> +#include <cstdlib> +#include <optional> +#include <string> + +namespace packet_mark +{ +namespace +{ + // The tsapi setter and getters are bound as non-type template parameters below, + // which pins the correct client/server trio at compile time. These must be raw + // function-pointer types, not std::function: a non-type template parameter has + // to be a structural type, and std::function is a runtime type-erasure wrapper, + // so template <std::function<...> Setter> is ill-formed. + using MarkSetter = TSReturnCode (*)(TSHttpTxn, int); + using FdGetter = TSReturnCode (*)(TSHttpTxn, int *); + using RespGetter = TSReturnCode (*)(TSHttpTxn, TSMBuffer *, TSMLoc *); + + std::optional<uint32_t> + get_uint_header(TSMBuffer bufp, TSMLoc hdr_loc, std::string_view header) + { + // Values are parsed with strtoul (base 0), so "0x0000000A" and "10" are both + // accepted. Returns std::nullopt if the header is absent, empty, or not a valid + // number -- a malformed value is a test-harness error, not a silent 0. */ + TSMLoc field_loc{TSMimeHdrFieldFind(bufp, hdr_loc, header.data(), static_cast<int>(header.length()))}; Review Comment: It is a typo, but it won't cause a compilation error, and you can't just delete code to introduce a real compilation error. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
