MCPcopy Create free account
hub / github.com/apache/trafficserver / TSPluginInit

Function TSPluginInit

plugins/tcpinfo/tcpinfo.cc:315–471  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

313}
314
315void
316TSPluginInit(int argc, const char *argv[])
317{
318 static const char usage[] = "tcpinfo.so [--log-file=PATH] [--log-level=LEVEL] [--hooks=LIST] [--sample-rate=COUNT] "
319 "[--rolling-enabled=VALUE] [--rolling-offset-hr=HOUR] [--rolling-interval-sec=SECONDS] "
320 "[--rolling-size=MB]";
321 static const struct option longopts[] = {
322 {const_cast<char *>("sample-rate"), required_argument, nullptr, 'r'},
323 {const_cast<char *>("log-file"), required_argument, nullptr, 'f'},
324 {const_cast<char *>("log-level"), required_argument, nullptr, 'l'},
325 {const_cast<char *>("hooks"), required_argument, nullptr, 'h'},
326 {const_cast<char *>("rolling-enabled"), required_argument, nullptr, 'e'},
327 {const_cast<char *>("rolling-offset-hr"), required_argument, nullptr, 'H'},
328 {const_cast<char *>("rolling-interval-sec"), required_argument, nullptr, 'S'},
329 {const_cast<char *>("rolling-size"), required_argument, nullptr, 'M'},
330 {nullptr, 0, nullptr, 0 },
331 };
332
333 TSPluginRegistrationInfo info;
334 auto config = std::make_unique<Config>();
335 const char *filename = "tcpinfo";
336 TSCont cont;
337 unsigned int hooks = 0;
338 int rolling_enabled = -1;
339 unsigned int rolling_interval_sec = 86400;
340 unsigned int rolling_offset_hr = 0;
341 unsigned int rolling_size = 1024;
342 unsigned int i = 0;
343 char *endptr;
344
345 info.plugin_name = (char *)"tcpinfo";
346 info.vendor_name = (char *)"Apache Software Foundation";
347 info.support_email = (char *)"dev@trafficserver.apache.org";
348
349 if (TSPluginRegister(&info) != TS_SUCCESS) {
350 TSError("[tcpinfo] plugin registration failed");
351 }
352
353 for (;;) {
354 unsigned long lval;
355
356 switch (getopt_long(argc, const_cast<char *const *>(argv), "r:f:l:h:e:H:S:M:", longopts, nullptr)) {
357 case 'r':
358 if (parse_unsigned(optarg, lval)) {
359 config->sample = atoi(optarg);
360 } else {
361 TSError("[tcpinfo] invalid sample rate '%s'", optarg);
362 }
363 break;
364 case 'f':
365 filename = optarg;
366 break;
367 case 'l':
368 if (parse_unsigned(optarg, lval) && (lval <= countof(tcpi_headers))) {
369 config->log_level = lval;
370 } else {
371 TSError("[tcpinfo] invalid log level '%s'", optarg);
372 }

Callers

nothing calls this directly

Calls 15

TSPluginRegisterFunction · 0.85
parse_unsignedFunction · 0.85
parse_hook_listFunction · 0.85
ink_atouiFunction · 0.85
TSTextLogObjectCreateFunction · 0.85
TSTextLogObjectHeaderSetFunction · 0.85
TSContCreateFunction · 0.85
TSContDataSetFunction · 0.85

Tested by

no test coverage detected