//----------------------------------------------------------------------------- static int __init gtpusp_tg_init(void) //----------------------------------------------------------------------------- { int err; pr_info(MODULE_NAME": Initializing module (KVersion: %d)\n", KVERSION); pr_info(MODULE_NAME": Copyright Polaris Networks 2010-2011\n"); pr_info(MODULE_NAME": Modified by EURECOM Lionel GAUTHIER 2014\n"); #ifndef CMAKER pr_info(MODULE_NAME": Compiled %s at time %s\n",__DATE__,__TIME__); #endif #if defined(WITH_IPV6) pr_info(MODULE_NAME": IPv4/IPv6 enabled\n"); #else pr_info(MODULE_NAME": IPv4 only enabled\n"); #endif pr_info(MODULE_NAME": params gtpu_enb_port=%u, gtpu_sgw_port=%u, sgw_addr=%s\n", gtpu_enb_port, gtpu_sgw_port, sgw_addr); // UDP socket socket memset(&_gtpusp_sock, 0, sizeof(gtpusp_sock_t)); /* create a socket */ if ((err = sock_create(AF_INET, SOCK_DGRAM, IPPROTO_UDP, &_gtpusp_sock.sock)) < 0 ) { PR_INFO(": Could not create a datagram socket, error = %d\n", -ENXIO); return err; } _gtpusp_sock.addr.sin_family = AF_INET; _gtpusp_sock.addr.sin_port = htons(gtpu_sgw_port); _gtpusp_sock.addr.sin_addr.s_addr = in_aton(sgw_addr); _gtpusp_sock.addr_send.sin_family = AF_INET; _gtpusp_sock.addr_send.sin_port = htons(gtpu_enb_port); _gtpusp_sock.addr_send.sin_addr.s_addr = in_aton(sgw_addr); _gtpusp_sock.thread_stop_requested = 0; if ( (err = _gtpusp_sock.sock->ops->bind(_gtpusp_sock.sock, (struct sockaddr *)&_gtpusp_sock.addr, sizeof(struct sockaddr) ) ) < 0) { pr_info(MODULE_NAME": Could not bind socket, error = %d\n", -err); goto close_and_out; } // start kernel thread _gtpusp_sock.thread = kthread_run((void *)_udp_thread, NULL, MODULE_NAME); if (IS_ERR(_gtpusp_sock.thread)) { pr_info(MODULE_NAME": unable to start kernel thread\n"); return -ENOMEM; } if((_gtpusp_sock.thread)) { wake_up_process(_gtpusp_sock.thread); } return xt_register_targets(gtpusp_tg_reg, ARRAY_SIZE(gtpusp_tg_reg)); close_and_out: sock_release(_gtpusp_sock.sock); _gtpusp_sock.sock = NULL; return err; }
static int __init xt_set_init(void) { int ret = xt_register_matches(set_matches, ARRAY_SIZE(set_matches)); if (!ret) { ret = xt_register_targets(set_targets, ARRAY_SIZE(set_targets)); if (ret) xt_unregister_matches(set_matches, ARRAY_SIZE(set_matches)); } return ret; }
static int __init log_tg_init(void) { int ret; ret = xt_register_targets(log_tg_regs, ARRAY_SIZE(log_tg_regs)); if (ret < 0) return ret; nf_log_register(NFPROTO_IPV4, &ipt_log_logger); #if IS_ENABLED(CONFIG_IP6_NF_IPTABLES) nf_log_register(NFPROTO_IPV6, &ip6t_log_logger); #endif return 0; }
static int __init xt_ct_tg_init(void) { int ret; ret = xt_register_target(¬rack_tg_reg); if (ret < 0) return ret; ret = xt_register_targets(xt_ct_tg_reg, ARRAY_SIZE(xt_ct_tg_reg)); if (ret < 0) { xt_unregister_target(¬rack_tg_reg); return ret; } return 0; }
static int __init log_tg_init(void) { int ret; ret = register_pernet_subsys(&log_net_ops); if (ret < 0) goto err_pernet; ret = xt_register_targets(log_tg_regs, ARRAY_SIZE(log_tg_regs)); if (ret < 0) goto err_target; nf_log_register(NFPROTO_IPV4, &ipt_log_logger); #if IS_ENABLED(CONFIG_IP6_NF_IPTABLES) nf_log_register(NFPROTO_IPV6, &ip6t_log_logger); #endif return 0; err_target: unregister_pernet_subsys(&log_net_ops); err_pernet: return ret; }
/* * vlantag_init() * Module init function. */ static int __init vlantag_init(void) { int ret; offload_vlantag_register(vlantag_get_target_info); ret = xt_register_matches(vlantag_pre, ARRAY_SIZE(vlantag_pre)); if (ret < 0) { DEBUGP("failed to register vlantag_pre\n"); return ret; } ret = xt_register_targets(vlantag_post, ARRAY_SIZE(vlantag_post)); if (ret < 0) { DEBUGP("failed to register vlantag_post\n"); xt_unregister_matches(vlantag_pre, ARRAY_SIZE(vlantag_pre)); return ret; } DEBUGP("vlantag_tg_init success\n"); return 0; }
static int __init audit_tg_init(void) { return xt_register_targets(audit_tg_reg, ARRAY_SIZE(audit_tg_reg)); }
static int __init hl_tg_init(void) { return xt_register_targets(hl_tg_reg, ARRAY_SIZE(hl_tg_reg)); }
static int __init redirect_tg_init(void) { return xt_register_targets(redirect_tg_reg, ARRAY_SIZE(redirect_tg_reg)); }
static int __init tcpoptstrip_tg_init(void) { return xt_register_targets(tcpoptstrip_tg_reg, ARRAY_SIZE(tcpoptstrip_tg_reg)); }
static int __init classify_tg_init(void) { return xt_register_targets(classify_tg_reg, ARRAY_SIZE(classify_tg_reg)); }
static int __init tproxy_tg_init(void) { return xt_register_targets(tproxy_tg_reg, ARRAY_SIZE(tproxy_tg_reg)); }
static int __init nflog_tg_init(void) { return xt_register_targets(nflog_tg_reg, ARRAY_SIZE(nflog_tg_reg)); }
static int __init xt_nfp6_init(void) { need_conntrack(); return xt_register_targets(xt_nfp6_target, ARRAY_SIZE(xt_nfp6_target)); }
static int __init xt_nfqueue_init(void) { return xt_register_targets(xt_nfqueue_target, ARRAY_SIZE(xt_nfqueue_target)); }
static int __init connsecmark_tg_init(void) { return xt_register_targets(connsecmark_tg_reg, ARRAY_SIZE(connsecmark_tg_reg)); }
static int __init nfqueue_tg_init(void) { get_random_bytes(&jhash_initval, sizeof(jhash_initval)); return xt_register_targets(nfqueue_tg_reg, ARRAY_SIZE(nfqueue_tg_reg)); }
static int __init udpencap_tg_init(void) { return xt_register_targets(udpencap_tg_reg, ARRAY_SIZE(udpencap_tg_reg)); }
static int __init xt_secmark_init(void) { return xt_register_targets(xt_secmark_target, ARRAY_SIZE(xt_secmark_target)); }
static int __init ip6t_npt_init(void) { return xt_register_targets(ip6t_npt_target_reg, ARRAY_SIZE(ip6t_npt_target_reg)); }
static int __init init(void) { return xt_register_targets(xt_imq_reg, ARRAY_SIZE(xt_imq_reg)); }
static int __init xt_mpls_init(void) { return xt_register_targets(xt_mpls_target, ARRAY_SIZE(xt_mpls_target)); }