Exemplo n.º 1
0
void
INKPluginInit(int argc, const char *argv[])
{
  INKPluginRegistrationInfo info;

  info.plugin_name = "output-header";
  info.vendor_name = "MyCompany";
  info.support_email = "*****@*****.**";

  if (!INKPluginRegister(INK_SDK_VERSION_5_2, &info)) {
    INKError("[PluginInit] Plugin registration failed.\n");
    goto error;
  }

  if (!check_ts_version()) {
    INKError("[PluginInit] Plugin requires Traffic Server 5.2.0 or later\n");
    goto error;
  }


  INKHttpHookAdd(INK_HTTP_OS_DNS_HOOK, INKContCreate(hdr_plugin, NULL));

error:
  INKError("[PluginInit] Plugin not initialized");
}
Exemplo n.º 2
0
void
INKPluginInit(int argc, const char *argv[])
{
  INKCont pCont;

  LOG_SET_FUNCTION_NAME("INKPluginInit");

  if ((pCont = INKContCreate(contHandler, NULL)) == INK_ERROR_PTR) {
    LOG_API_ERROR("INKContCreate")
  } else if (INKHttpHookAdd(INK_HTTP_TXN_START_HOOK, pCont) == INK_ERROR) {
    LOG_API_ERROR("INKHttpHookAdd");
  }
}
Exemplo n.º 3
0
void
INKPluginInit(int argc, const char *argv[])
{
  LOG_SET_FUNCTION_NAME("INKPluginInit");
  INKCont contp;

  INKDebug(DEBUG_TAG, "INKPluginInit");
  if ((contp = INKContCreate(event_mux, NULL)) == INK_ERROR_PTR) {
    LOG_ERROR("INKContCreate");
  } else if (INKHttpHookAdd(INK_HTTP_SEND_RESPONSE_HDR_HOOK, contp) == INK_ERROR) {
    LOG_ERROR("INKHttpHookAdd");
  }

}
Exemplo n.º 4
0
void
INKPluginInit(int argc, const char *argv[])
{
  INKCont contp, contp2;
  int timeOut = 10;

  INKDebug("tag_sched6643", "INKContSchedule: Initial data value for contp is %d\n", timeOut);

  /* contp = INKContCreate(EventHandler, INKMutexCreate() ); */

  contp = INKContCreate(EventHandler, NULL);
  INKContDataSet(contp, (void *) timeOut);

  INKHttpHookAdd(INK_HTTP_OS_DNS_HOOK, contp);
}
Exemplo n.º 5
0
void
INKPluginInit(int argc, const char *argv[])
{
  INKPluginRegistrationInfo info;

  info.plugin_name = "replace-header";
  info.vendor_name = "MyCompany";
  info.support_email = "*****@*****.**";

  if (!INKPluginRegister(INK_SDK_VERSION_5_2, &info)) {
    INKError("Plugin registration failed. \n");
  }

  if (!check_ts_version()) {
    INKError("Plugin requires Traffic Server 5.2.0 or later\n");
    return;
  }

  INKHttpHookAdd(INK_HTTP_READ_RESPONSE_HDR_HOOK, INKContCreate(replace_header_plugin, NULL));
}
Exemplo n.º 6
0
void
INKPluginInit(int argc, const char *argv[])
{
  LOG_SET_FUNCTION_NAME("INKPluginInit");

  INKCont contp;

  plugin_dir = INKPluginDirGet();
  if ((file_mutex = INKMutexCreate()) == INK_ERROR_PTR) {
    LOG_ERROR("INKMutexCreate");
    return;
  }

  if ((contp = INKContCreate(process_plugin, INKMutexCreate())) == INK_ERROR_PTR) {
    LOG_ERROR("INKContCreate");
    return;
  }

  if (INKHttpHookAdd(INK_HTTP_TXN_START_HOOK, contp) == INK_ERROR)
    LOG_ERROR("INKHttpHookAdd");

}
Exemplo n.º 7
0
void
INKPluginInit(int argc, const char *argv[])
{


  INKMutex lock1 = INKMutexCreate();

  INKCont contp = INKContCreate(startplugin, lock1);

  value = 0;

  INKHttpHookAdd(INK_HTTP_READ_REQUEST_HDR_HOOK, contp);
  INKHttpHookAdd(INK_HTTP_OS_DNS_HOOK, contp);
  INKHttpHookAdd(INK_HTTP_SEND_REQUEST_HDR_HOOK, contp);
  INKHttpHookAdd(INK_HTTP_READ_CACHE_HDR_HOOK, contp);
  INKHttpHookAdd(INK_HTTP_READ_RESPONSE_HDR_HOOK, contp);
  INKHttpHookAdd(INK_HTTP_SEND_RESPONSE_HDR_HOOK, contp);
}
Exemplo n.º 8
0
void
INKPluginInit(int argc, const char *argv[])
{

  INKHttpHookAdd(INK_HTTP_READ_REQUEST_HDR_HOOK, INKContCreate(attach_test, NULL));
}
Exemplo n.º 9
0
void
INKPluginInit(int argc, const char *argv[])
{
  INKMLoc field_loc;
  const char *p;
  int i, retval;
  INKPluginRegistrationInfo info;

  info.plugin_name = "add-header";
  info.vendor_name = "MyCompany";
  info.support_email = "*****@*****.**";

  if (!INKPluginRegister(INK_SDK_VERSION_5_2, &info)) {
    INKError("[PluginInit] Plugin registration failed.\n");
    goto error;
  }

  if (!check_ts_version()) {
    INKError("[PluginInit] Plugin requires Traffic Server 5.2.0 or later\n");
    goto error;
  }

  if (argc < 2) {
    INKError("[PluginInit] Usage: %s \"name1: value1\" \"name2: value2\" ...>\n", argv[0]);
    goto error;
  }

  hdr_bufp = INKMBufferCreate();
  if (hdr_bufp == INK_ERROR_PTR) {
    INKError("[PluginInit] Can not create mbuffer");
    goto error;
  }

  hdr_loc = INKMimeHdrCreate(hdr_bufp);
  if (hdr_loc == INK_ERROR_PTR) {
    INKError("[PluginInit] Can not create mime header");
    goto error;
  }

  for (i = 1; i < argc; i++) {
    field_loc = INKMimeHdrFieldCreate(hdr_bufp, hdr_loc);
    if (field_loc == INK_ERROR_PTR) {
      INKError("[PluginInit] Error while creating field");
      goto error;
    }

    retval = INKMimeHdrFieldAppend(hdr_bufp, hdr_loc, field_loc);
    if (retval == INK_ERROR) {
      INKError("[PluginInit] Error while adding field");
      goto error;
    }

    p = strchr(argv[i], ':');
    if (p) {
      retval = INKMimeHdrFieldNameSet(hdr_bufp, hdr_loc, field_loc, argv[i], p - argv[i]);
      if (retval == INK_ERROR) {
        INKError("[PluginInit] Error while naming field");
        goto error;
      }

      p += 1;
      while (isspace(*p)) {
        p += 1;
      }
      retval = INKMimeHdrFieldValueInsert(hdr_bufp, hdr_loc, field_loc, p, strlen(p), -1);
      if (retval == INK_ERROR) {
        INKError("[PluginInit] Error while inserting field value");
        goto error;
      }
    } else {
      retval = INKMimeHdrFieldNameSet(hdr_bufp, hdr_loc, field_loc, argv[i], strlen(argv[i]));
      if (retval == INK_ERROR) {
        INKError("[PluginInit] Error while inserting field value");
        goto error;
      }
    }
  }

  /* Create a continuation with a mutex as there is a shared global structure
     containing the headers to add */
  retval = INKHttpHookAdd(INK_HTTP_READ_REQUEST_HDR_HOOK, INKContCreate(add_header_plugin, INKMutexCreate()));
  if (retval == INK_ERROR) {
    INKError("[PluginInit] Error while registering to hook");
    goto error;
  }

  goto done;

error:
  INKError("[PluginInit] Plugin not initialized");

done:
  return;
}