当前位置: 首页>>代码示例>>C++>>正文


C++ ifc_init函数代码示例

本文整理汇总了C++中ifc_init函数的典型用法代码示例。如果您正苦于以下问题:C++ ifc_init函数的具体用法?C++ ifc_init怎么用?C++ ifc_init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ifc_init函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: rtl871x_drv_rereg_nd_name

int rtl871x_drv_rereg_nd_name(const char *ifname, const char *new_ifname)
{
	int sockfd;
	int ret;

#if 0
	if (ifc_init() < 0)
		return -1;	
	if (ifc_up(ifname)) {
		LOGD("failed to bring up interface %s: %s\n", ifname, strerror(errno));
		return -1;
	}
#endif
	
	sockfd = socket(PF_INET, SOCK_DGRAM, 0);
	if (sockfd< 0) {
		perror("socket[PF_INET,SOCK_DGRAM]");
		ret = -1;
		goto bad;
	}

	ret = rtl871x_drv_rereg_nd_name_fd(
		sockfd
		, ifname
		, get_priv_func_num(sockfd, ifname, "rereg_nd_name")
		, new_ifname
	);
	
	close(sockfd);
bad:
	return ret;
}
开发者ID:fards,项目名称:ainol_elfii_system,代码行数:32,代码来源:SoftapController_realtek.cpp


示例2: set_iface

int set_iface(const char *iface, int on)
{
    int u4Count = 0;

    if(ifc_init() != 0) {
        LOGE("[%s] interface set %d failed", iface, on);
        return -1;
    }
    if(on) {
        while(ifc_up(iface) == -1) {
            LOGD("[%s] interface is not ready, wait %dus", iface, SET_IFACE_DELAY);
            sched_yield();
            usleep(SET_IFACE_DELAY);
            if (++u4Count >= SET_IFACE_POLLING_LOOP) {
                LOGE("[%s] interface set %d failed", iface, on);
                ifc_close();
                return -1;
            }
        }
        LOGD("[%s] interface is up", iface);
        init_iface(iface);
    }
    else {
        ifc_down(iface);
        LOGD("[%s] interface is down", iface);
    }
    ifc_close();
    return 0;
}
开发者ID:AwaisKing,项目名称:mt6577_aosp_source,代码行数:29,代码来源:wifi_common.c


示例3: ALOGE

int SoftapController::startDriver(char *iface) {
    int ret;

    if (mSock < 0) {
        ALOGE("Softap driver start - failed to open socket");
        return ResponseCode::OperationFailed;
    }
    if (!iface || (iface[0] == '\0')) {
        ALOGD("Softap driver start - wrong interface");
        iface = mIface;
    }

    *mBuf = 0;
    ret = setCommand(iface, "START");
    if (ret < 0) {
        ALOGE("Softap driver start: %d", ret);
        return ResponseCode::ServiceStartFailed;
    }
#ifdef HAVE_HOSTAPD
    ifc_init();
    ret = ifc_up(iface);
    ifc_close();
#endif
    usleep(AP_DRIVER_START_DELAY);
    ALOGD("Softap driver start: %d", ret);
    return ResponseCode::SoftapStatusResult;
}
开发者ID:Rohirimor,项目名称:android_device_xiaomi_mione_plus-carbon,代码行数:27,代码来源:SoftapController.cpp


示例4: rtw_issue_driver_cmd

int rtw_issue_driver_cmd(const char *ifname, char *cmd, char *buf, size_t buf_len)
{
	int sockfd;
	int ret;

#if 0
	if (ifc_init() < 0)
		return -1;	
	if (ifc_up(ifname)) {
		LOGD("failed to bring up interface %s: %s\n", ifname, strerror(errno));
		return -1;
	}
#endif
	
	sockfd = socket(PF_INET, SOCK_DGRAM, 0);
	if (sockfd< 0) {
		LOGE("%s socket[PF_INET,SOCK_DGRAM] error:%d %s", __FUNCTION__, errno, strerror(errno));
		ret = -1;
		goto bad;
	}

	ret = rtw_issue_driver_cmd_fd(
		sockfd
		, ifname
		, cmd
		, buf
		, buf_len
	);
	
	close(sockfd);
bad:
	return ret;
}
开发者ID:jamesyan84,项目名称:mt36k_android_4.0.4,代码行数:33,代码来源:wifi_realtek.c


示例5: startDhcpWimaxDaemon

int startDhcpWimaxDaemon()
{
    char dhcp_status[PROPERTY_VALUE_MAX] = {'\0'};
    int count = 100; /* wait at most 10 seconds for completion */

    LOGI("NATIVE::startDhcpWimaxDaemon() - stopping dhcpWimax");
    stopDhcpWimax();
    LOGI("NATIVE::startDhcpWimaxDaemon() - dhcpWimax stopped");
    ifc_init();
    ifc_up("wimax0");
    LOGI("NATIVE::startDhcpWimaxDaemon() - wimax0 up!");

    property_set("ctl.start", WIMAX_DHCP_NAME);
    sched_yield();
    LOGI("NATIVE::startDhcpWimaxDaemon() - dhcp starting...");
   
    while (count-- > 0) {
        if (property_get("dhcp.wimax0.reason", dhcp_status, NULL)) {
            if (strcmp(dhcp_status, "BOUND") == 0 || strcmp(dhcp_status, "RENEW") == 0 || strcmp(dhcp_status, "PREINIT") == 0) {
                LOGI("NATIVE::startDhcpWimaxDaemon() - dhcp finished!");
                return 0;
            }
        }
        usleep(100000);
    }
    return -1;
}
开发者ID:OMFGB,项目名称:hardware_libhardware_legacy,代码行数:27,代码来源:wimax.c


示例6: ifc_configure

int ifc_configure(const char *ifname,
        in_addr_t address,
        in_addr_t gateway)
{
    in_addr_t netmask = ~0;
    (void) gateway;

    ifc_init();

    if (ifc_up(ifname)) {
	LOGE("%s() Failed to turn on interface %s: %s", __func__,
	     ifname,
	     strerror(errno));
	ifc_close();
	return -1;
    }
    if (ifc_set_addr(ifname, address)) {
	LOGE("%s() Failed to set ipaddr %s: %s", __func__,
	     ipaddr_to_string(address), strerror(errno));
	ifc_down(ifname);
	ifc_close();
	return -1;
    }
    if (ifc_set_mask(ifname, netmask)) {
	LOGE("%s() failed to set netmask %s: %s", __func__,
	     ipaddr_to_string(netmask), strerror(errno));
	ifc_down(ifname);
	ifc_close();
	return -1;
    }

    ifc_close();

    return 0;
}
开发者ID:Adamj311,项目名称:android_device_malata_smba_common,代码行数:35,代码来源:net-utils.c


示例7: ifc_enable

int ifc_enable(const char *ifname)
{
    int result;

    ifc_init();
    result = ifc_up(ifname);
    ifc_close();
    return result;
}
开发者ID:4Fwolf,项目名称:mt6572_x201,代码行数:9,代码来源:ifc_utils.c


示例8: META_WIFI_init

int META_WIFI_init(void)
{
    int count = 100;
	
    if(1 == wifi_init){
    	ERR("wifi is already initilized.\n");
    	return true;
    }
#if 0
    if (!wifi_is_loaded()){
        ERR("[META_WIFI] loading wifi driver ... ...\n");    	
        if (wifi_insmod(DRIVER_MODULE_PATH, DRIVER_MODULE_ARG) < 0) {
            ERR("[META_WIFI] failed to load wifi driver!!!\n");    	        	
            goto error;
        }
    }
#endif    
    usleep(200000); 
		
    wifi_set_power(1);


    sched_yield();
    
    while (count-- > 0) {
        if (ifc_init() == 0) {
            if (ifc_up("wlan0") == 0) {
                ifc_close();
                break;
            }
            ERR("[META_WIFI] ifc_up(wlan0) failed\n");
            ifc_close();
        } else {
            ERR("[META_WIFI] ifc_init() failed\n");
        }
        usleep(100000);
    }
    if (count == 0)
        goto error;

    if (wifi_skfd == -1)
        wifi_skfd = openNetHandle();

    if (wifi_skfd < 0) {
        META_WIFI_deinit();
        goto error;
    }

    wifi_init = 1;

    return true;

error:
    wifi_set_power(0);
    return false;
}
开发者ID:Scorpio92,项目名称:mediatek,代码行数:56,代码来源:meta_wifi.c


示例9: ifc_disable

int ifc_disable(const char *ifname)
{
    int result;

    ifc_init();
    result = ifc_down(ifname);
    ifc_set_addr(ifname, 0);
    ifc_close();
    return result;
}
开发者ID:morphis,项目名称:freesmartphone-utilities,代码行数:10,代码来源:ifc_utils.c


示例10: ifc_clear_ipv4_addresses

/*
 * Clears IPv4 addresses on the specified interface.
 */
void ifc_clear_ipv4_addresses(const char *name) {
    unsigned count, addr;
    ifc_init();
    for (count=0, addr=1;((addr != 0) && (count < 255)); count++) {
        if (ifc_get_addr(name, &addr) < 0)
            break;
        if (addr)
            ifc_set_addr(name, 0);
    }
    ifc_close();
}
开发者ID:AwaisKing,项目名称:mt6577_aosp_source,代码行数:14,代码来源:ifc_utils.c


示例11: ifc_disable_allmc

int ifc_disable_allmc(const char *ifname)
{
    int result;

    ifc_init();
    result = ifc_set_flags(ifname, 0, IFF_ALLMULTI);
    ifc_close();

    ALOGD("ifc_disable_allmc(%s) = %d", ifname, result);
    return result;
}
开发者ID:4Fwolf,项目名称:mt6572_x201,代码行数:11,代码来源:ifc_utils.c


示例12: main

int main(int argc, char **argv)
{
    char *iname;
    int n;
    
    if(ifc_init()) {
        die("Cannot perform requested operation");
    }

    if(argc == 1) {
        int result = dump_interfaces();
        ifc_close();
        return result;
    }

    if(argc < 3) usage();

    iname = argv[1];
    if(strlen(iname) > 16) usage();

    argc -= 2;
    argv += 2;
    while(argc > 0) {
        for(n = 0; CMDS[n].name; n++){
            if(!strcmp(argv[0], CMDS[n].name)) {
                char *cmdname = argv[0];
                int nargs = CMDS[n].nargs;
                
                argv[0] = iname;
                if(argc < nargs) {
                    fprintf(stderr, "not enough arguments for '%s'\n", cmdname);
                    ifc_close();
                    exit(1);
                }
                if(call_func(CMDS[n].func, nargs, argv)) {
                    fprintf(stderr, "action '%s' failed (%s)\n", cmdname, strerror(errno));
                    ifc_close();
                    exit(1);
                }
                argc -= nargs;
                argv += nargs;
                goto done;
            }
        }
        fprintf(stderr,"no such action '%s'\n", argv[0]);
        usage();
    done:
        ;
    }
    ifc_close();

    return 0;
}
开发者ID:0omega,项目名称:platform_system_core,代码行数:53,代码来源:netcfg.c


示例13: ifc_set_default_route

/*
 * Sets the specified gateway as the default route for the named interface.
 * DEPRECATED
 */
int ifc_set_default_route(const char *ifname, in_addr_t gateway)
{
    struct in_addr addr;
    int result;

    ifc_init();
    addr.s_addr = gateway;
    if ((result = ifc_create_default_route(ifname, gateway)) < 0) {
        ALOGD("failed to add %s as default route for %s: %s",
              inet_ntoa(addr), ifname, strerror(errno));
    }
    ifc_close();
    return result;
}
开发者ID:4Fwolf,项目名称:mt6572_x201,代码行数:18,代码来源:ifc_utils.c


示例14: doWimaxDhcpRequest

int doWimaxDhcpRequest(int *ipaddr, int *gateway, int *mask,
                    int *dns1, int *dns2, int *server, int *lease) {

    if (ifc_init() < 0)
        return -1;

    if (do_dhcp(iface) < 0) {
        ifc_close();
        return -1;
    }
    ifc_close();
    get_dhcp_info(ipaddr, gateway, mask, dns1, dns2, server, lease);
    return 0;
}
开发者ID:OMFGB,项目名称:hardware_libhardware_legacy,代码行数:14,代码来源:wimax.c


示例15: do_dhcp_client_request

int do_dhcp_client_request(const char *iface, int *ipaddr, int *gateway, int *mask,
                    int *dns1, int *dns2, int *server, int *lease) {

    LOGD("[%s] do_dhcp_client_request\n", iface);

    if (ifc_init() < 0)
        return -1;

    if (do_dhcp(iface) < 0) {
        ifc_close();
        return -1;
    }
    ifc_close();
    get_dhcp_info(ipaddr, gateway, mask, dns1, dns2, server, lease);
    return 0;
}
开发者ID:AwaisKing,项目名称:mt6577_aosp_source,代码行数:16,代码来源:wifi_common.c


示例16: ifc_remove_default_route

/*
 * Removes the default route for the named interface.
 */
int ifc_remove_default_route(const char *ifname)
{
    struct rtentry rt;
    int result;

    ifc_init();
    memset(&rt, 0, sizeof(rt));
    rt.rt_dev = (void *)ifname;
    rt.rt_flags = RTF_UP|RTF_GATEWAY;
    init_sockaddr_in(&rt.rt_dst, 0);
    if ((result = ioctl(ifc_ctl_sock, SIOCDELRT, &rt)) < 0) {
        ALOGD("failed to remove default route for %s: %s", ifname, strerror(errno));
    }
    ifc_close();
    return result;
}
开发者ID:4Fwolf,项目名称:mt6572_x201,代码行数:19,代码来源:ifc_utils.c


示例17: do_dhcp_request

int do_dhcp_request(int *ipaddr, int *gateway, int *mask,
                    int *dns1, int *dns2, int *server, int *lease) {
    /* For test driver, always report success */
    if (strcmp(primary_iface, WIFI_TEST_INTERFACE) == 0)
        return 0;

    if (ifc_init() < 0)
        return -1;

    if (do_dhcp(primary_iface) < 0) {
        ifc_close();
        return -1;
    }
    ifc_close();
    get_dhcp_info(ipaddr, gateway, mask, dns1, dns2, server, lease);
    return 0;
}
开发者ID:flyingwalf,项目名称:sys-auto,代码行数:17,代码来源:wifi.c


示例18: ifc_configure

int
ifc_configure(const char *ifname,
        in_addr_t address,
        in_addr_t netmask,
        in_addr_t gateway,
        in_addr_t dns1,
        in_addr_t dns2) {

#if 0
    char dns_prop_name[PROPERTY_KEY_MAX];
#endif

    ifc_init();

    if (ifc_up(ifname)) {
        printerr("failed to turn on interface %s: %s\n", ifname, strerror(errno));
        ifc_close();
        return -1;
    }
    if (ifc_set_addr(ifname, address)) {
        printerr("failed to set ipaddr %s: %s\n", ipaddr_to_string(address), strerror(errno));
        ifc_close();
        return -1;
    }
    if (ifc_set_mask(ifname, netmask)) {
        printerr("failed to set netmask %s: %s\n", ipaddr_to_string(netmask), strerror(errno));
        ifc_close();
        return -1;
    }
    if (ifc_create_default_route(ifname, gateway)) {
        printerr("failed to set default route %s: %s\n", ipaddr_to_string(gateway), strerror(errno));
        ifc_close();
        return -1;
    }

    ifc_close();

#if 0
    snprintf(dns_prop_name, sizeof(dns_prop_name), "net.%s.dns1", ifname);
    property_set(dns_prop_name, dns1 ? ipaddr_to_string(dns1) : "");
    snprintf(dns_prop_name, sizeof(dns_prop_name), "net.%s.dns2", ifname);
    property_set(dns_prop_name, dns2 ? ipaddr_to_string(dns2) : "");
#endif

    return 0;
}
开发者ID:morphis,项目名称:freesmartphone-utilities,代码行数:46,代码来源:ifc_utils.c


示例19: ifc_reset_connections

int ifc_reset_connections(const char *ifname, const int reset_mask)
{
#ifdef HAVE_ANDROID_OS
    int result, success;
    in_addr_t myaddr = 0;
    struct ifreq ifr;
    struct in6_ifreq ifr6;

    if (reset_mask & RESET_IPV4_ADDRESSES) {
        /* IPv4. Clear connections on the IP address. */
        ifc_init();
        if (!(reset_mask & RESET_IGNORE_INTERFACE_ADDRESS)) {
            ifc_get_info(ifname, &myaddr, NULL, NULL);
        }
        ifc_init_ifr(ifname, &ifr);
        init_sockaddr_in(&ifr.ifr_addr, myaddr);
        result = ioctl(ifc_ctl_sock, SIOCKILLADDR,  &ifr);
        ifc_close();
    } else {
        result = 0;
    }

    if (reset_mask & RESET_IPV6_ADDRESSES) {
        /*
         * IPv6. On Linux, when an interface goes down it loses all its IPv6
         * addresses, so we don't know which connections belonged to that interface
         * So we clear all unused IPv6 connections on the device by specifying an
         * empty IPv6 address.
         */
        ifc_init6();
        // This implicitly specifies an address of ::, i.e., kill all IPv6 sockets.
        memset(&ifr6, 0, sizeof(ifr6));
        success = ioctl(ifc_ctl_sock6, SIOCKILLADDR,  &ifr6);
        if (result == 0) {
            result = success;
        }
        ifc_close6();
    }

    return result;
#else
    return 0;
#endif
}
开发者ID:00zhengfu00,项目名称:platform_system_core,代码行数:44,代码来源:ifc_utils.c


示例20: ifc_remove_host_routes

/*
 * Remove the routes associated with the named interface.
 */
int ifc_remove_host_routes(const char *name)
{
    char ifname[64];
    in_addr_t dest, gway, mask;
    int flags, refcnt, use, metric, mtu, win, irtt;
    struct rtentry rt;
    FILE *fp;
    struct in_addr addr;

    fp = fopen("/proc/net/route", "r");
    if (fp == NULL)
        return -1;
    /* Skip the header line */
    if (fscanf(fp, "%*[^\n]\n") < 0) {
        fclose(fp);
        return -1;
    }
    ifc_init();
    for (;;) {
        int nread = fscanf(fp, "%63s%X%X%X%d%d%d%X%d%d%d\n",
                           ifname, &dest, &gway, &flags, &refcnt, &use, &metric, &mask,
                           &mtu, &win, &irtt);
        if (nread != 11) {
            break;
        }
        if ((flags & (RTF_UP|RTF_HOST)) != (RTF_UP|RTF_HOST)
                || strcmp(ifname, name) != 0) {
            continue;
        }
        memset(&rt, 0, sizeof(rt));
        rt.rt_dev = (void *)name;
        init_sockaddr_in(&rt.rt_dst, dest);
        init_sockaddr_in(&rt.rt_gateway, gway);
        init_sockaddr_in(&rt.rt_genmask, mask);
        addr.s_addr = dest;
        if (ioctl(ifc_ctl_sock, SIOCDELRT, &rt) < 0) {
            ALOGD("failed to remove route for %s to %s: %s",
                  ifname, inet_ntoa(addr), strerror(errno));
        }
    }
    fclose(fp);
    ifc_close();
    return 0;
}
开发者ID:4Fwolf,项目名称:mt6572_x201,代码行数:47,代码来源:ifc_utils.c



注:本文中的ifc_init函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。