bneradt commented on code in PR #12995: URL: https://github.com/apache/trafficserver/pull/12995#discussion_r3047738241
########## plugins/experimental/jax_fingerprint/method.h: ########## @@ -0,0 +1,42 @@ +/** @file + + @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. + + */ + +#pragma once + +#include "ts/ts.h" + +#include "context.h" + +using ClientHelloHandler = void (*)(JAxContext *, TSVConn); +using RequestReadHandler = void (*)(JAxContext *, TSHttpTxn); + +struct Method { + enum class Type { + CONNECTION_BASED, + REQUEST_BASED, + }; + + const char *name; Review Comment: Can this be std::string_view instead of char*? I think that will simplify some interactions with it (`==` instead of strcmp, etc.). Maybe add a comment, as well, that these only ever point to static string literals and thus are always null-terminated. ########## plugins/experimental/jax_fingerprint/userarg.cc: ########## @@ -0,0 +1,72 @@ +/** @file + + @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 "plugin.h" +#include "config.h" +#include "userarg.h" + +int +reserve_user_arg(PluginConfig &config) +{ + char name[strlen(PLUGIN_NAME) + strlen(config.method.name) + 1]; + name[0] = '\0'; + strcat(name, PLUGIN_NAME); + strcat(name, config.method.name); Review Comment: Maybe use std::string or ostringstream? ########## plugins/experimental/jax_fingerprint/userarg.cc: ########## @@ -0,0 +1,72 @@ +/** @file + + @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 "plugin.h" +#include "config.h" +#include "userarg.h" + +int +reserve_user_arg(PluginConfig &config) +{ + char name[strlen(PLUGIN_NAME) + strlen(config.method.name) + 1]; + name[0] = '\0'; + strcat(name, PLUGIN_NAME); + strcat(name, config.method.name); + + TSUserArgType type; + if (config.method.type == Method::Type::CONNECTION_BASED) { + type = TS_USER_ARGS_VCONN; + } else { + type = TS_USER_ARGS_TXN; + } + int ret = TSUserArgIndexReserve(type, name, "used to pass JAx context between hooks", &config.user_arg_index); + Dbg(dbg_ctl, "user_arg_name: %s, user_arg_index: %d", name, config.user_arg_index); + return ret; +} + +void +fill_user_arg_index(PluginConfig &config) +{ + char name[strlen(PLUGIN_NAME) + strlen(config.method.name) + 1]; + name[0] = '\0'; + strcat(name, PLUGIN_NAME); + strcat(name, config.method.name); Review Comment: std::string/std::ostringstream? -- 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]
