예제 #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)");
}
예제 #2
0
파일: icmp.c 프로젝트: krissg/junkie
void icmp_init(void)
{
    log_category_proto_icmp_init();

    static struct proto_ops const ops = {
        .parse      = icmp_parse,
        .parser_new = uniq_parser_new,
        .parser_del = uniq_parser_del,
    };
    uniq_proto_ctor(&uniq_proto_icmp, &ops, "ICMP");
    ip_subproto_ctor(&icmp_ip_subproto, IPPROTO_ICMP, proto_icmp);
    ip6_subproto_ctor(&icmp_ip6_subproto, IPPROTO_ICMP, proto_icmp);
}
예제 #3
0
파일: tcp.c 프로젝트: Mybrc91/junkie
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)");
}