Exemple #1
0
void udp_init(void)
{
    log_category_proto_udp_init();

    static struct proto_ops const ops = {
        .parse       = udp_parse,
        .parser_new  = mux_parser_new,
        .parser_del  = mux_parser_del,
        .info_2_str  = udp_info_2_str,
        .info_addr   = udp_info_addr
    };
    mux_proto_ctor(&mux_proto_udp, &ops, &mux_proto_ops, "UDP", PROTO_CODE_UDP, sizeof(struct port_key), UDP_HASH_SIZE);
    port_muxer_list_ctor(&udp_port_muxers, "UDP muxers");

    ip_subproto_ctor(&ip_subproto, IPPROTO_UDP, proto_udp);
    ip6_subproto_ctor(&ip6_subproto, IPPROTO_UDP, proto_udp);

    // Extension functions to introspect (and modify) port_muxers
    ext_function_ctor(&sg_udp_ports,
        "udp-ports", 0, 0, 0, g_udp_ports,
        "(udp-ports): returns an assoc-list of all defined udp subparsers with their port binding.\n");

    ext_function_ctor(&sg_udp_add_port,
        "udp-add-port", 2, 1, 0, g_udp_add_port,
        "(udp-add-port \"proto\" port [port-max]): ask TCP to try this proto for this port [range].\n"
        "See also (? 'udp-del-port)\n");

    ext_function_ctor(&sg_udp_del_port,
        "udp-del-port", 2, 1, 0, g_udp_del_port,
        "(udp-del-port \"proto\" port [port-max]): ask TCP to stop trying this proto for this port [range].\n"
        "See also (? 'udp-add-port)");
}
Exemple #2
0
void tcp_init(void)
{
    mutex_pool_ctor(&tcp_locks, "TCP subparsers");
    log_category_proto_tcp_init();
    pkt_wl_config_ctor(&tcp_wl_config, "TCP-reordering", 100000, 20, 100000, 3 /* REORDERING TIMEOUT (second) */, true);

    static struct proto_ops const ops = {
        .parse       = tcp_parse,
        .parser_new  = mux_parser_new,
        .parser_del  = mux_parser_del,
        .info_2_str  = tcp_info_2_str,
        .info_addr   = tcp_info_addr,
        .serialize   = tcp_serialize,
        .deserialize = tcp_deserialize,
    };
    static struct mux_proto_ops const mux_ops = {
        .subparser_new = tcp_subparser_new,
        .subparser_del = tcp_subparser_del,
    };
    mux_proto_ctor(&mux_proto_tcp, &ops, &mux_ops, "TCP", PROTO_CODE_TCP, sizeof(struct port_key), TCP_HASH_SIZE);
    port_muxer_list_ctor(&tcp_port_muxers, "TCP muxers");
    ip_subproto_ctor(&ip_subproto, IPPROTO_TCP, proto_tcp);
    ip6_subproto_ctor(&ip6_subproto, IPPROTO_TCP, proto_tcp);

    // Extension functions to introspect (and modify) port_muxers
    ext_function_ctor(&sg_tcp_ports,
        "tcp-ports", 0, 0, 0, g_tcp_ports,
        "(tcp-ports): returns an assoc-list of all defined tcp subparsers with their port binding.\n");

    ext_function_ctor(&sg_tcp_add_port,
        "tcp-add-port", 2, 1, 0, g_tcp_add_port,
        "(tcp-add-port \"proto\" port [port-max]): ask TCP to try this proto for this port [range].\n"
        "See also (? 'tcp-del-port)\n");

    ext_function_ctor(&sg_tcp_del_port,
        "tcp-del-port", 2, 1, 0, g_tcp_del_port,
        "(tcp-del-port \"proto\" port [port-max]): ask TCP to stop trying this proto for this port [range].\n"
        "See also (? 'tcp-add-port)");
}
Exemple #3
0
void on_load(void)
{
    log_category_duplicogram_init();
    ext_param_bucket_width_init();

    SLOG(LOG_INFO, "Duplicogram loaded");

    term_init(&handle_key);

    cli_register("Duplicogram plugin", duplicogram_opts, NB_ELEMS(duplicogram_opts));

    mutex_ctor(&dup_lock, "Duplicogram mutex");

    ext_function_ctor(&sg_get_duplicogram,
        "get-duplicogram", 0, 0, 0, g_get_duplicogram,
        "(get-duplicogram): fetch duplicogram data and reset internal state. Not for the casual user");

    hook_subscriber_ctor(&dup_hook, &dup_subscription, dup_callback);
    hook_subscriber_ctor(&proto_cap->hook, &cap_subscription, cap_callback);
}
Exemple #4
0
void mutex_init(void)
{
    ext_function_ctor(&sg_set_thread_name,
        "set-thread-name", 1, 0, 0, g_set_thread_name,
        "(set-thread-name \"thing\") : set current thread name.\n");
}