/*
 *===========================================================================
 *                    ipnet_nat_proxy_dns
 *===========================================================================
 * Description: NAT proxy for the DNS protocol.
 * Parameters:  newhdr    - pointer to optionally write new IP header.
 *              appdata   - pointer to application data.
 *              applen    - pointer to length of application data.
 *              growspace - space available to extend application data.
 *              param     - pointer to proxy parameters.
 *              newdata   - pointer to pointer to new application data.
 * Returns:     1 = Packet modified.
 *              0 = Packet untouched.
 *             -1 = Drop packet.
 */
IP_PUBLIC int
ipnet_nat_proxy_dns(Ip_u8 *newhdr,
                    Ip_u8 *appdata,
                    int   *applen,
                    int    growspace,
                    Ipnet_nat_proxy_param *param,
                    Ip_u8 **newdata)
{
    IP_STATIC int init = 0;

    (void)newhdr;

    /* Cannot handle fragments other than the first */
    if (param->fragoff != 0)
        return 0;

    /* DNS proxy only applicable for NAT-PT */
    if(param->natpt == IP_TRUE)
    {
        if (!init)
        {
            ipcom_list_init(&ipnet_nat_proxy_dns_list);
            init = 1;
        }
        if (param->incoming == IP_FALSE)
        {
            return ipnet_nat_proxy_dns_request(appdata, applen, growspace, param, newdata);
        }
        else
        {
            return ipnet_nat_proxy_dns_reply(appdata, applen, growspace, param, newdata);
        }
    }
    return 0;
}
Exemplo n.º 2
0
/*
 *===========================================================================
 *                    ipcom_shellcmd_init
 *===========================================================================
 * Description:
 * Parameters:
 * Returns:
 *
 */
IP_STATIC Ip_err
ipcom_shellcmd_init(void *unused)
{
    (void)unused;

    ipcom_list_init(&ipcom_shell_cmd_head);

    return IPCOM_SUCCESS;
}
Exemplo n.º 3
0
/*
 *===========================================================================
 *                    ipcom_shellalias_init
 *===========================================================================
 * Description:
 * Parameters:
 * Returns:
 *
 */
IP_STATIC Ip_err
ipcom_shellalias_init(void *unused)
{
    int i;
    (void)unused;

    ipcom_list_init(&ipcom_shellalias_head);

    for (i = 0; ipcom_shellalias_config[i].name != IP_NULL; i++)
        ipcom_shellalias_set(ipcom_shellalias_config[i].name, ipcom_shellalias_config[i].cmd);

    return IPCOM_SUCCESS;
}
Exemplo n.º 4
0
/*
 *===========================================================================
 *                       ipppp_work_init
 *===========================================================================
 * Description:
 * Parameters:
 * Returns:
 *
 */
IP_STATIC Ip_err
ipppp_work_init(void *unused)
{
    IPCOM_UNUSED_ARG(unused);

    ipcom_list_init(&ipppp_work_queue);
    ipcom_mutex_create(&ipppp_work_lock);
    ipcom_sem_create(&ipppp_work_sem, 0);

    return ipcom_proc_create("ipppp_work",
                             (Ipcom_proc_func)ipppp_work,
                             IPCOM_PROC_STACK_DEFAULT,
                             IP_NULL);
}
/*
 *===========================================================================
 *                    ipl2tp_start
 *===========================================================================
 * Description: Start L2TP daemon.
 * Parameters:  
 * Returns:     
 *
 */
IP_PUBLIC Ip_err
ipl2tp_start(void)
{
    Ip_u16  pw_list[]   = 
    { 
        IPL2TP_ATTR_PW_TYPE_ETHERNET, 
        IPL2TP_ATTR_PW_TYPE_ETHERNET_VLAN        
    };

    Ipl2tp_attrobj attr      = IP_NULL;
    Ipl2tp_attrobj tattr2    = IP_NULL;
    Ipl2tp_attrobj sattr2    = IP_NULL;
    Ipl2tp_attrobj tattr3    = IP_NULL;
    Ipl2tp_attrobj sattr3    = IP_NULL;

    Ip_u32 enable_v2;
    Ip_u32 enable_v3;

    ipl2tp_example_sessions = ipcom_hash_new((Ipcom_hash_obj_func)ipl2tp_example_obj_hash_key,
                                             (Ipcom_hash_key_func)ipl2tp_example_obj_hash_key,
                                             (Ipcom_hash_cmp_func)ipl2tp_example_cmp_key);

    ipcom_list_init(&ipl2tp_example_fds);

    /* Initialize */
    ipl2tp_attr_strappend(&attr, 
                          IPL2TP_ATTR_SET_HOST_NAME, 
                          L2TP_HOST_NAME);
    ipl2tp_attr_pappend(&attr, 
                        IPL2TP_ATTR_SET_L2TP_WRITE_CALLBACK,
                        (void *)ipl2tp_l2tp_write);

    ipl2tp_attr_iappend(&attr, 
                        IPL2TP_ATTR_SET_ENABLE_OUTGOING,
                        IPL2TP_MIB_YES);

#if L2TP_VERSION_2_ENABLE == TRUE
    enable_v2 = IPL2TP_MIB_YES;
#else
    enable_v2 = IPL2TP_MIB_NO;
#endif

    ipl2tp_attr_iappend(&attr, 
                        IPL2TP_ATTR_SET_ENABLE_L2TP_V2,
                        enable_v2);

#if L2TP_VERSION_3_ENABLE == TRUE
    enable_v3 = IPL2TP_MIB_YES;
#else
    enable_v3 = IPL2TP_MIB_NO;
#endif

    ipl2tp_attr_iappend(&attr, 
                        IPL2TP_ATTR_SET_ENABLE_L2TP_V3,
                        enable_v3);

    ipl2tp_attr_pappend(&tattr2, 
                        IPL2TP_TATTR_SET_STATUS_CALLBACK,
                        (void *)ipl2tp_example_tstatus_v2);
    ipl2tp_attr_pappend(&tattr3, 
                        IPL2TP_TATTR_SET_STATUS_CALLBACK,
                        (void *)ipl2tp_example_tstatus_v3);
    ipl2tp_attr_vappend(&tattr3, 
                        IPL2TP_TATTR_SET_LOCAL_PSEUDOWIRE_CAPABILITIES_LIST,
                        (void *)pw_list,
                        sizeof(pw_list));

    ipl2tp_attr_pappend(&sattr2, 
                        IPL2TP_SATTR_SET_STATUS_CALLBACK,
                        (void *)ipl2tp_example_sstatus_v2);
    ipl2tp_attr_pappend(&sattr2, 
                        IPL2TP_SATTR_SET_DATA_CALLBACK,
                        (void *)ipl2tp_ppp_data_cb);
    ipl2tp_attr_pappend(&sattr3, 
                        IPL2TP_SATTR_SET_STATUS_CALLBACK,
                        (void *)ipl2tp_example_sstatus_v3);
    ipl2tp_attr_iappend(&sattr3, 
                        IPL2TP_SATTR_SET_PSEUDOWIRE_TYPE,
                        IPL2TP_ATTR_PW_TYPE_ETHERNET_VLAN);

    ipl2tp_api_open(attr, tattr2, tattr3, sattr2, sattr3);

    ipl2tp_attr_delete(&attr);
    ipl2tp_attr_delete(&tattr2);
    ipl2tp_attr_delete(&sattr2);
    ipl2tp_attr_delete(&tattr3);
    ipl2tp_attr_delete(&sattr3);

    /* Spawn new daemon process */
    return ipcom_proc_acreate("l2tps", ipl2tps, IP_NULL, IP_NULL);
}