Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Huawei e173-u2 in NDIS mode - problem in Linux

2,414 views
Skip to first unread message

wzab

unread,
Sep 16, 2011, 1:08:11 PM9/16/11
to
Hi,

I'm trying to get the e173-u2 working in NDIS mode.

I can force it to connect to the network after the
AT^NDISDUP=1,1,"my_apn_name"
command.
Then I can run "dhclient wwan0" and obtain the
IP address.
However the Internet communication doesn't
work properly. In the wireshark I can see,
that the outgoing packets are almost correct
(they have the same src and dst MAC-addresses,
which are identical to the MAC of my interface:
02:50:f3:00:00:00)
The incoming packets however have incorrect dst
address: 00:01:02:03:04:05, so they are ignored by the kernel,
even though I can see them in wireshark.

To work it arround I tried to set the MAC of my interface
to 00:01:02:03:04:05 - but it didn't help.
In the logs I can see:
cdc_ether 1-6:1.1: wwan0: CDC: unexpected notification 01!

Is it caused by the bug in cdc_ether driver, or am I doing
something wrong when controlling the e173-u2?

wzab

unread,
Sep 16, 2011, 2:56:35 PM9/16/11
to
> To work it arround I tried to set the MAC of my interface
> to 00:01:02:03:04:05 - but it didn't help.

I must have mistaken. I have tried once again:

in minicom: AT^NDISDUP=1,1,"my_apn_name"
in root console: ifconfig wwan0 hw ether 00:01:02:03:04:05
in root console: dhclient wwan0

And it works!
(Anyway it is a dirty trick. We should find the real cause of
"strange" MAC dst in incoming packets).

To disconnect, it is sufficient to make:
AT^NDISDUP=1,0
ifconfig wwan0 down

(well, it would be wise to kill the dhclient as well).

wzab

unread,
Sep 19, 2011, 4:20:31 AM9/19/11
to
I have prepared two simple Python scripts. One for connecting to the
network,
and the second one for disconnecting from the network.
Of course, they should be further improved:
1. You should add support for modem locking file
2. You should allow script to find the right special device file,
not assuming, that it should always be "/dev/ttyUSB0" (it may
be wrong assumption if you connect any USB->RS232 adapter
to your machine)
In fact the best cure would be to prepare the udev rules, so that
the modem gets a special device name, e.g. /dev/tty_e173
3. On disconnecting, you should be able to kill only this dhclient
which services the wwan0 interface. Now the script kills all
dhclient processes.

Anyway below are my "quick&dirty" scripts (please consider, that some
usenet archives break the indentation in Python scripts, you may need
to fix it before use).

==== e173_NDIS_on.py ============
#!/usr/bin/python
import os
import thread
import threading
class msg_fifo():
def __init__(self):
self.lock=threading.Condition()
self.queue=[]
def append(self,data):
self.lock.acquire()
self.queue.append(data)
self.lock.notifyAll()
self.lock.release()
def pop(self,tmout):
self.lock.acquire()
if len(self.queue) == 0:
self.lock.wait(tmout)
if len(self.queue) == 0:
self.lock.release()
return None
res=self.queue.pop(0)
self.lock.release()
return res

responses = msg_fifo()

resp_lock=thread.allocate_lock()
def receive(in_file,out_fifo):
line=""
while True:
c=in_file.read(1)
if c=="\n":
out_fifo.append(line)
line = ""
else:
line += c

modem="/dev/ttyUSB0"
m_out=open(modem,"w")
m_in=open(modem,"r")

# Start the receiving thread
rcv_thread = thread.start_new_thread(receive,(m_in,responses))
m_out.write("ATZ\r")
m_out.flush()
while True:
l = responses.pop(12)
print l
if l=="OK\r":
break
# else:
# raise SystemExit("Unexpected response: "+l)
m_out.write("AT^NDISDUP=1,1,\"my_apn_name\"\r")
m_out.flush()
while True:
l = responses.pop(12)
print l
if l=="OK\r":
break
# else:
# raise SystemExit("Unexpected response!")
os.system("/sbin/ifconfig wwan0 hw ether 00:01:02:03:04:05")
os.system("/sbin/dhclient wwan0")

======== e173_NDIS_off.py =============================
#!/usr/bin/python

import thread
import threading
import os

class msg_fifo():
def __init__(self):
self.lock=threading.Condition()
self.queue=[]
def append(self,data):
self.lock.acquire()
self.queue.append(data)
self.lock.notifyAll()
self.lock.release()
def pop(self,tmout):
self.lock.acquire()
if len(self.queue) == 0:
self.lock.wait(tmout)
if len(self.queue) == 0:
self.lock.release()
return None
res=self.queue.pop(0)
self.lock.release()
return res

responses = msg_fifo()

resp_lock=thread.allocate_lock()
def receive(in_file,out_fifo):
line=""
while True:
c=in_file.read(1)
if c=="\n":
out_fifo.append(line)
line = ""
else:
line += c

modem="/dev/ttyUSB0"
m_out=open(modem,"w")
m_in=open(modem,"r")

# Start the receiving thread
rcv_thread = thread.start_new_thread(receive,(m_in,responses))
m_out.write("AT^NDISDUP=1,0\r")
m_out.flush()
while True:
l = responses.pop(12)
if l=="OK\r":
break
# else:
# raise SystemExit("Unexpected response!")
os.system("killall dhclient")
os.system("ifconfig wwan0 down")

wzab

unread,
Sep 19, 2011, 1:31:13 PM9/19/11
to
I have stated, that sometimes, after reset, the ttyUSB ports are
assigned in different order.
To have reliable ordering of the special files to different ports it
is necessary to have appropriate
udev rules.
In the file: http://www.t-mobile.de/downloads/neu/linux_driver_4.19.00.00.zip
(this is
a tar.gz archive, even though the extension is .zip!)
you can find the appropriate udev rules (see file 10-Huawei-
Datacard.rules after unarchiving).
The appropriate rules fore my modem were:
SUBSYSTEMS=="usb", ATTRS{modalias}=="usb:v12D1p1436*",
KERNEL=="ttyUSB*", ATTRS{bInterfaceNumber}=="00",
ATTRS{bInterfaceProtocol}=="ff", NAME="ttyUSB_utps_modem"
SUBSYSTEMS=="usb", ATTRS{modalias}=="usb:v12D1p1436*",
KERNEL=="ttyUSB*", ATTRS{bInterfaceNumber}=="03",
ATTRS{bInterfaceProtocol}=="ff", NAME="ttyUSB_utps_diag"
SUBSYSTEMS=="usb", ATTRS{modalias}=="usb:v12D1p1436*",
KERNEL=="ttyUSB*", ATTRS{bInterfaceNumber}=="04",
ATTRS{bInterfaceProtocol}=="ff", NAME="ttyUSB_utps_pcui"


wzab

unread,
Sep 21, 2011, 10:26:56 AM9/21/11
to
I have published my first quick&dirty GUI based dialer for e173 in
NDIS mode for Linux.
The sources are available at alt.sources group (subject: "Public
domain sources for NDIS mode dialer for e173 modem")
The code is public domain, so improve it as you need and want.
I hope, that it may be useful for someone...
--
Regards,
WZab

wzab

unread,
Sep 21, 2011, 10:29:20 AM9/21/11
to
0 new messages