Exemplo n.º 1
0
int
disconnect_ndis(int devnum)
{
	int valid_node, qmi_mode = 0;
	char control_node[16] = {0};
	
	valid_node = find_modem_node("cdc-wdm", 0, 0, -1, NULL); // todo (need devnode for cdc-wdm)
	if (valid_node >= 0) {
		qmi_mode = 1;
		sprintf(control_node, "cdc-wdm%d", valid_node);
	}
	else {
		valid_node = find_modem_node("ttyUSB", 1, devnum, -1, NULL);
		if (valid_node < 0)
			valid_node = find_modem_node("ttyUSB", 0, devnum, -1, NULL);
		
		if (valid_node >= 0)
			sprintf(control_node, "ttyUSB%d", valid_node);
	}
	
	if (strlen(control_node) > 0) {
		if (qmi_mode)
			return qmi_stop_network(control_node);
		else
			return doSystem("/bin/comgt -d /dev/%s -s %s/ppp/3g/NDIS_disconn.scr", control_node, MODEM_SCRIPTS_DIR);
	}
	
	return 1;
}
Exemplo n.º 2
0
int
disconnect_ndis(int devnum)
{
	int valid_node, qmi_mode = 0;
	char control_node[16] = {0};

	// check wdm device
	valid_node = find_modem_node("cdc-wdm", 0, 0, -1, NULL); // todo (need devnode for cdc-wdm)
	if (valid_node >= 0) {
		qmi_mode = 1;
		sprintf(control_node, "cdc-wdm%d", valid_node);
	}
	else {
		// check serial device
		valid_node = get_modem_node("ttyUSB", devnum, NULL);
		if (valid_node >= 0)
			sprintf(control_node, "ttyUSB%d", valid_node);
	}

	if (strlen(control_node) > 0) {
		if (!qmi_mode) {
			int vid = 0, pid = 0;
			get_modem_vid_pid(control_node, &vid, &pid);
			if ( (vid == 0x1199 || vid == 0x0f3d) && (pid == 0x68a3 || pid == 0x68aa) )
				return doSystem("/bin/comgt -d /dev/%s -s %s/ppp/3g/%s", control_node, MODEM_SCRIPTS_DIR, "Sierra_disconn.scr");
			else
				return doSystem("/bin/comgt -d /dev/%s -s %s/ppp/3g/%s", control_node, MODEM_SCRIPTS_DIR, "NDIS_disconn.scr");
		}
		else
			return qmi_stop_network(control_node);
	}

	return 1;
}
Exemplo n.º 3
0
static int
get_modem_node(const char* pattern, int devnum, int *devnum_out)
{
	int valid_node = -1;
	int i_node_user = nvram_get_int("modem_node") - 1;
	if (i_node_user >= 0) {
		// manual select
		valid_node = find_modem_node(pattern, 0, 0, i_node_user, devnum_out);
	} else {
		// auto select
		valid_node = find_modem_node(pattern, 1, devnum, -1, devnum_out);
		if (valid_node < 0)
			valid_node = find_modem_node(pattern, 0, devnum, -1, devnum_out);
	}

	return valid_node;
}
Exemplo n.º 4
0
int
get_modem_ndis_ifname(char ndis_ifname[16], int *devnum_out)
{
	int valid_node = 0;

	valid_node = find_modem_node("wwan", 0, 0, -1, devnum_out); // first exist node
	if (valid_node >= 0) {
		sprintf(ndis_ifname, "wwan%d", valid_node);
		return 1;
	} else {
		valid_node = find_modem_node("weth", 0, 0, -1, devnum_out); // first exist node
		if (valid_node >= 0) {
			sprintf(ndis_ifname, "weth%d", valid_node);
			return 1;
		}
	}

	return 0;
}
Exemplo n.º 5
0
static int
ndis_control_network(char *ndis_ifname, int devnum, int is_start)
{
	int valid_node;
	char control_node_wdm[16] = {0}, control_node_tty[16] = {0};

	/* check wdm device */
	valid_node = find_modem_node("cdc-wdm", 0, 0, -1, NULL); // todo (need devnode for cdc-wdm)
	if (valid_node >= 0)
		sprintf(control_node_wdm, "cdc-wdm%d", valid_node);

	/* check tty device */
	valid_node = get_modem_node("ttyUSB", devnum, NULL);
	if (valid_node >= 0)
		sprintf(control_node_tty, "ttyUSB%d", valid_node);

	if (strlen(control_node_wdm) > 0) {
		if (is_usbnet_has_module(ndis_ifname, "qmi_wwan"))
			return qmi_control_network(control_node_wdm, is_start);
		
		if (is_usbnet_has_module(ndis_ifname, "cdc_mbim"))
			return mbim_control_network(control_node_wdm, is_start);
		
		if (is_usbnet_has_module(ndis_ifname, "huawei_cdc_ncm"))
			return ncm_control_network(control_node_wdm, is_start);
	}

	if (strlen(control_node_tty) > 0) {
		if (is_usbnet_has_module(ndis_ifname, "cdc_ncm"))
			return ncm_control_network(control_node_tty, is_start);
		
		if (is_usbnet_has_module(ndis_ifname, "sierra_net"))
			return sierra_control_network(control_node_tty, is_start);
	}

	return 1;
}
Exemplo n.º 6
0
static int
get_modem_ras_node(char node_name[16], int *devnum)
{
	int valid_node, modem_node_user;
	
	modem_node_user = nvram_get_int("modem_node") - 1;
	
	// check ACM device
	if (modem_node_user >= 0) {
		// manual select
		valid_node = find_modem_node("ttyACM", 0, 0, modem_node_user, devnum); // node is worked
	} else {
		// auto select
		valid_node = find_modem_node("ttyACM", 1, 0, -1, devnum); // node has int pipe
		if (valid_node < 0)
			valid_node = find_modem_node("ttyACM", 0, 0, -1, devnum); // first exist node
	}
	
	if (valid_node >= 0) {
		sprintf(node_name, "ttyACM%d", valid_node);
		return 1;
	}
	
	// check serial device
	if (modem_node_user >= 0) {
		// manual select
		valid_node = find_modem_node("ttyUSB", 0, 0, modem_node_user, devnum); // node is worked
	} else {
		// auto select
		valid_node = find_modem_node("ttyUSB", 1, 0, -1, devnum); // node has int pipe
		if (valid_node < 0)
			valid_node = find_modem_node("ttyUSB", 0, 0, -1, devnum); // first exist node
	}
	
	if (valid_node >= 0) {
		sprintf(node_name, "ttyUSB%d", valid_node);
		return 1;
	}

	return 0;
}