Re: 4G LTE connection stability with USB voltage requirement

2020-01-27 Thread Daniel Wagner
Hi JH,

On Mon, Jan 27, 2020 at 01:26:41PM +1100, JH wrote:
> It seems to me there are subtle differences between connman / ofono
> and OpenWrt netifd, could the connman / ofono require more rigid
> stable USB voltage than OpenWrt netifd? Or could the OpenWrt netifd be
> more superior than connman / ofono in terms of 4G LTE connections?
> 
> Appreciate your insight comments and advice.

What about measuring the power drawn by the device? And while at it
also careful check the datasheets of the components if the tolerances
of the hardware components are meet.

I cannot comment on netifd since I don't know anything about it. But
it could be that ConnMan and oFono together do more CPU work hence the
device drains more power. I can tell you from experience if the CPU
doesn't get enough power you see really random crashes and weird
behaviors. Check the reports on Raspberry Pi and power supplies.

Thanks,
Daniel
___
ofono mailing list -- ofono@ofono.org
To unsubscribe send an email to ofono-le...@ofono.org


Re: connman settings for modem APN

2020-01-07 Thread Daniel Wagner

Hi,

On 07.01.20 17:38, nick83ola wrote:

I have to manage a modem with connman through dbus and I'm willing to
work on the ofono plugin to add the APN handling but I'm not familiar
with connman code.

Connman is already creating a ofono internet context by default for
the modem but it doesn't offer the possibility to configure the APN
(and user/password) for the connection.


Correct.


Where you would put the dbus method to set the APN for a particular
connection? 


See oFono documentation on Connection Context.


I would prefer if possible only to connect to connman not
connman/ofono.


/*
 * The way this plugin works is following:
 *
 *   powered -> SubscriberIdentity or Online = True -> gprs, context ->
 * attached -> netreg -> ready
 *
 * Depending on the modem type, this plugin will behave differently.
 *
 * GSM working flow:
 *
 * When a new modem appears, the plugin always powers it up. This
 * allows the plugin to create a connman_device. The core will call
 * modem_enable() if the technology is enabled. modem_enable() will
 * then set the modem online. If the technology is disabled then
 * modem_disable() will just set the modem offline. The modem is
 * always kept powered all the time.
 *
 * After setting the modem online the plugin waits for the
 * ConnectionManager and ConnectionContext to appear. When the context
 * signals that it is attached and the NetworkRegistration interface
 * appears, a new Service will be created and registered at the core.
 *
 * When asked to connect to the network (network_connect()) the plugin
 * will set the Active property on the context. If this operation is
 * successful the modem is connected to the network. oFono will inform
 * the plugin about IP configuration through the updating the context's
 * properties.
[...]

I have only a vague memory on this topic, but I think to remember that 
oFono will only show the CM if the APN was provisioned in oFono. Maybe I 
have false memory on it.


Thanks,
Daniel
___
ofono mailing list -- ofono@ofono.org
To unsubscribe send an email to ofono-le...@ofono.org


Re: Unsalble cellular connection

2019-08-15 Thread Daniel Wagner

On 8/15/19 2:45 PM, JH wrote:

Well, the log _seemed_ to indicate that connman does an NTP request to a
server that isn't available and thereby decides to take the link down...
off the top of my head I can't say whether that's something connman
actually does so hopefully somebody else will jump in here.  Did ofono
indicate the context as still established after that?


That seems critical, every time when the link down, connman called:

connmand[213]: Time request for server 10.114.52.97 failed
(101/Network is unreachable)


The NTP code is just telling it can't reach the server. This has no 
direct connenction to the next entry.



Then deleted the link IP address to cause the link down:
connmand[213]: wwan0 {del} address 10.114.52.98/30 label wwan0


This message is from the kernel via RTNL interface. The kernel tells 
ConnMan the interface state has changed.



connmand[213]: Skipping disconnect of /ubloxqmi_0/context1, network is
connecting.
connmand[213]: ipconfig state 2 ipconfig method 1


and the above is then the cause of the RTNL message.


Seeing the issue with complete logs would be useful.  I thought your
previous logs indicated connman trying to deactivate the context when it
took the link down, but the ofono logs didn't show any of that... what's
going on there?


The full connman log file attached, there was no information for ofono
log files. I don't think that ofono was aware of that connman deleted
the IP address from the LTE link, I cannot understand why the connman
did it. Anyway, I'll try to debug and to generate ofono log again.


Your log does not contain the debug information (connmand -d).
___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono


Re: Unsalble cellular connection

2019-08-15 Thread Daniel Wagner

Hi,

On 8/14/19 3:00 PM, Jonas Bonn wrote:
Well, the log _seemed_ to indicate that connman does an NTP request to a 
server that isn't available and thereby decides to take the link down... 


NTP lookup failures won't trigger a disconnect. As long oFono or the 
kernel via RNTL changes the state ConnMan doesn't change the routing.


off the top of my head I can't say whether that's something connman 
actually does so hopefully somebody else will jump in here.  Did ofono 
indicate the context as still established after that?


Mabye checking what monitor-ofono shows.

Seeing the issue with complete logs would be useful.  I thought your 
previous logs indicated connman trying to deactivate the context when it 
took the link down, but the ofono logs didn't show any of that... what's 
going on there?


Yes, that is a good question. If oFono doesn't tell ConnMan anything, 
then ConnMan reacts to a state change of the device.


Thanks,
Daniel
___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono


Re: status

2018-09-28 Thread Daniel Wagner
Hi,

On 27/09/2018 18:52, Denis Kenzior wrote:>> For the
gemaltomodem/gprs-context, it is not clear how to proceed. Would
>> you kindly give some suggestion other than "these modules don't exist
>> in my world"?
> 
> I did give you a suggestion on how to proceed.  Lets get the sane ones
> supported first.  That should be mostly easy.
> 
> For the insane ones we will need to figure something else out.  For
> example, it may be that we should just have oFono initiate the DHCP
> request itself for these devices.  The driver can then control both DHCP
> and context activation status and would be able to sanely tell the core
> what is going on.  We already have DHCP code available in ConnMan that
> could be ported to oFono, or more likely finish DHCP support in ell and
> use that.

While we have DHCP code in ConnMan I wouldn't recommend to port it as it
is. Patrik reimplemented DHCP for systemd-netword using ConnMan's
version as blueprint. That code looks much saner. Propably, it would
make sense to carve out a library (using ELL as support library) from
the systemd's version and make ConnMan and oFono depending on it.

Thanks,
Daniel
___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono


Re: Ofono LTE modems and connman services

2018-03-07 Thread Daniel Wagner

Hi,

On 03/02/2018 06:15 PM, Denis Kenzior wrote:

A lot of the above comes from my understanding of what connman is trying
to do:  if it sees the state as Attached and has no Active contexts then
it starts trying to activate the first context.  Ideally, it would never
see an inactive context for LTE, at least not in the Attached state.
However, I may be missing something in my understanding of how this is
intended to work, so any clarification would be appreciated.


Or it should give up if it sees the InProgress error, but yes it might
be that re-ordering messages is the right approach.  Daniel, Marcel?


I must admit, I am slightly confused. So we have a different behavior 
pattern between UMTS/GSM and LTE networks which expresses itself in the 
non ordering of Active and Attached?


Anyway, I don't have anything against ordering the events. Shouldn't be 
to hard to update the plugin.


Thanks,
Daniel
___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono


Re: Issue with service reporting on a 4G modem

2018-02-26 Thread Daniel Wagner
Hi Bassem,

On 26.02.2018 13:16, Bassem BOUBAKER wrote:
> Issue is fixed. Thank you for your help.

Glad to hear you could fix it.

> I used to have this:
> # cat /sys/class/net/usb0/uevent 
> INTERFACE=usb0
> IFINDEX=7
> 
> I changed my driver in the kernel to probe it as a wwan info device based on 
> vid and pid . 
> 
> Now I have the DEVTYPE correct:
> # cat /sys/class/net/wwan0/uevent 
> DEVTYPE=wwan
> INTERFACE=wwan0
> IFINDEX=7
> 
> 
> Below my kernel patch in case of anyone having the same issue.
> 
> PS: I'm using a Cinterion PLS8 modem.

Please also create a patch for Linux upstream. You are almost there.
Just add a commit message and send it to the right mailing list :)

Thanks,
Daniel
___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono


Re: Issue with service reporting on a 4G modem

2018-02-23 Thread Daniel Wagner

Check if the DEVTYPE is set correctly on the modem. If it is not
wwan ConnMan wont ignore it src/rntl.c:


s/wont ignore/wont handle it correctly/
___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono


Re: Issue with service reporting on a 4G modem

2018-02-23 Thread Daniel Wagner
Hi Bassem,

On 02/20/2018 10:44 AM, Bassem BOUBAKER wrote:
> Hello Daniel,
> 
> Exactly, my modem is creating an additional ethernet interface, and I don't 
> know why.
> 
> Please find in the link below the full log of connman.
> 
> https://ufile.io/dmgbw

Feb 20 08:52:21 pcm kernel: cdc_acm 1-1:1.4: ttyACM2: USB ACM device
Feb 20 08:52:21 pcm kernel: cdc_acm 1-1:1.6: ttyACM3: USB ACM device
Feb 20 08:52:21 pcm kernel: cdc_acm 1-1:1.8: This device cannot do calls on its 
own. It is not a modem.
Feb 20 08:52:21 pcm kernel: cdc_acm 1-1:1.8: ttyACM4: USB ACM device
Feb 20 08:52:21 pcm kernel: usbcore: registered new interface driver cdc_acm
Feb 20 08:52:21 pcm kernel: cdc_acm: USB Abstract Control Model driver for USB 
modems and ISDN adapters
Feb 20 08:52:21 pcm kernel[657]: cdc_acm 1-1:1.0: ttyACM0: USB ACM device
Feb 20 08:52:21 pcm kerncdc_ether 1-1:1.10 usb0: CDC: unexpected notification 
01!
el[657]: cdc_acm 1-1:1.2: ttyACM1: USB ACM device
Feb 20 08:52:21 pcm kernel[657]: cdc_acm 1-1:1.4: ttyACM2: USB ACM device
Feb 20 08:52:21 pcm kernel[657]: cdc_acm 1-1:1.6: ttyACM3: USB ACM device
Feb 20 08:52:21 pcm kernel[657]: cdc_acm 1-1:1.8: This device cannot do calls 
on its own. It is not a modem.
Feb 20 08:52:21 pcm kernel[657]: cdc_acm 1-1:1.8: ttyACM4: USB ACM device
Feb 20 08:52:21 pcm kernel[657]: usbcore: registered new interface driver 
cdc_acm
Feb 20 08:52:21 pcm kernel[657]: cdc_acm: USB Abstract Control Model driver for 
USB modems and ISDN adapters
Feb 20 08:52:21 pcm connmand[700]: src/rtnl.c:rtnl_message() buf 0x7eeffbf8 len 
1076
Feb 20 08:52:21 pcm connmand[cdc_ether 1-1:1.12 usb1: CDC: unexpected 
notification 01!
700]: src/rtnl.c:rtnl_message() NEWLINK len 1076 type 16 flags 0x seq 0 pid 0
Feb 20 08:52:21 pcm connmand[700]: src/ipconfig.c:__connman_ipconfig_newlink() 
index 7
Feb 20 08:52:21 pcm connmand[700]: usb0 {create} index 7 type 1 
Feb 20 08:52:21 pcm connmand[700]: usb0 {update} flags 4098 
Feb 20 08:52:21 pcm connmand[700]: usb0 {newlink} index 7 address 
XX:XX:XX:XX:00:00 mtu 1500
Feb 20 08:52:21 pcm connmand[700]: usb0 {newlink} index 7 operstate 2 


Check if the DEVTYPE is set correctly on the modem. If it is not
wwan ConnMan wont ignore it src/rntl.c:

static void read_uevent(struct interface_data *interface)
{
[...]

found_devtype = false;
while (fgets(line, sizeof(line), f)) {
char *pos;

pos = strchr(line, '\n');
if (!pos)
continue;
pos[0] = '\0';

if (strncmp(line, "DEVTYPE=", 8) != 0)
continue;

found_devtype = true;

if (strcmp(line + 8, "wlan") == 0) {
interface->service_type = CONNMAN_SERVICE_TYPE_WIFI;
interface->device_type = CONNMAN_DEVICE_TYPE_WIFI;
} else if (strcmp(line + 8, "wwan") == 0) {
interface->service_type = CONNMAN_SERVICE_TYPE_CELLULAR;
interface->device_type = CONNMAN_DEVICE_TYPE_CELLULAR;
} else if (strcmp(line + 8, "bluetooth") == 0) {
interface->service_type = 
CONNMAN_SERVICE_TYPE_BLUETOOTH;
interface->device_type = CONNMAN_DEVICE_TYPE_BLUETOOTH;
} else if (strcmp(line + 8, "gadget") == 0) {
interface->service_type = CONNMAN_SERVICE_TYPE_GADGET;
interface->device_type = CONNMAN_DEVICE_TYPE_GADGET;
} else if (strcmp(line + 8, "vlan") == 0) {
interface->service_type = CONNMAN_SERVICE_TYPE_ETHERNET;
interface->device_type = CONNMAN_DEVICE_TYPE_ETHERNET;
} else if (strcmp(line + 8, "bond") == 0) {
interface->service_type = CONNMAN_SERVICE_TYPE_ETHERNET;
interface->device_type = CONNMAN_DEVICE_TYPE_ETHERNET;
} else {
interface->service_type = CONNMAN_SERVICE_TYPE_UNKNOWN;
interface->device_type = CONNMAN_DEVICE_TYPE_UNKNOWN;
}
}

[...]
}

DEVTYPE=wwan in /sys/class/net//uevent.

HTH!

Thanks,
Daniel
___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono


Re: Issue with service reporting on a 4G modem

2018-02-19 Thread Daniel Wagner

Hi Bassem,

[added ofono mailing list]

On 02/16/2018 11:24 AM, Bassem BOUBAKER wrote:

Hello community,

I'm having connman version 1.31 along side with ofono running on my board.

When I activate a context on my 4G modem using ofono, connman creates two 
services: one is cellular and the other is ethernet.

*AR Wired ethernet_XX_cable
*AO XXX cellular_XXX_context1

In this case, the ideal state is that connman reports only one cellular 
technology related to the modem.

When digging into the logs, I feels like a new ethernet device is enumerated 
and connman creates the appropriate service for it.

Knowing that my modem net interface is using "cdc_ether" driver, does anyone 
have an idea about what could be the issue here?


From you description I understand that the modem creates an additional 
ethernet interface? Could you post the corresponding logs (or post a 
link to the logs)?


I am also not sure what the exact question is. I suspect you want to see 
only one interface and not two..


Thanks,
Daniel
___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono


Re: Huawei MS2131

2018-01-22 Thread Daniel Wagner
Hi,

So after some more playing around, oFono 1.21 works out
of the box. At my workplace there must be some
interference which made all modems go crazy. After
moving away all works fine. The only thing missing
was the APN config, which was easily fixed.

So many thanks for all the help.

During the testing I triggered two crashes(by removing
the device). 

Thanks,
Daniel





ofonod[25541]: plugins/udevng.c:remove_device() 
/sys/devices/pci:00/:00:14.0/usb1/1-1/1-1:1.0/ttyUSB0/tty/ttyUSB0
ofonod[25541]: plugins/udevng.c:destroy_modem() 
/sys/devices/pci:00/:00:14.0/usb1/1-1
ofonod[25541]: src/modem.c:ofono_modem_remove() 0xc8f800
ofonod[25541]: src/modem.c:modem_unregister() 0xc8f800
ofonod[25541]: src/modem.c:modem_change_state() old state: 3, new state: 0
ofonod[25541]: src/modem.c:flush_atoms() 
ofonod[25541]: src/message-waiting.c:mw_remove() atom: 0xc8d180
ofonod[25541]: src/call-barring.c:call_barring_remove() atom: 0xcc3f80
ofonod[25541]: src/call-settings.c:call_settings_remove() atom: 0xcc4660
ofonod[25541]: src/call-forwarding.c:call_forwarding_remove() atom: 0xcc4590
ofonod[25541]: src/ussd.c:ussd_remove() atom: 0xc97260
ofonod[25541]: src/network.c:__ofono_netreg_remove_status_watch() 0xc9f620
ofonod[25541]: src/cbs.c:cbs_remove() atom: 0xc71930
ofonod[25541]: drivers/atmodem/gprs-context.c:at_gprs_detach_shutdown() cid 1
ofonod[25541]: src/sim.c:ofono_sim_remove_spn_watch() 0xcc0d50
ofonod[25541]: src/network.c:netreg_remove() atom: 0xcb1c60
ofonod[25541]: Example Network Time Remove for modem: 0xc8f800
ofonod[25541]: Example History Remove for modem: 0xc8f800
ofonod[25541]: src/gprs.c:gprs_context_unregister() 0xcb1cd0, 0xc96120
ofonod[25541]: src/gprs.c:gprs_context_remove() atom: 0xcb1d10
ofonod[25541]: drivers/atmodem/gprs-context.c:at_gprs_context_remove() 
ofonod[25541]: Modem channel disconnected
ofonod[25541]: src/gprs.c:gprs_context_remove() atom: 0xcb1d10
ofonod[25541]: drivers/atmodem/gprs-context.c:at_gprs_context_remove() 

(ofonod:25541): GLib-CRITICAL **: g_queue_pop_head: assertion 'queue != NULL' 
failed

(ofonod:25541): GLib-CRITICAL **: g_queue_free: assertion 'queue != NULL' failed

(ofonod:25541): GLib-CRITICAL **: g_hash_table_destroy: assertion 'hash_table 
!= NULL' failed
ofonod[25541]: Modem channel disconnected
ofonod[25541]: src/gprs.c:gprs_context_remove() atom: 0xcb1d10
ofonod[25541]: drivers/atmodem/gprs-context.c:at_gprs_context_remove() 

(ofonod:25541): GLib-CRITICAL **: g_queue_pop_head: assertion 'queue != NULL' 
failed

(ofonod:25541): GLib-CRITICAL **: g_queue_free: assertion 'queue != NULL' failed

(ofonod:25541): GLib-CRITICAL **: g_hash_table_destroy: assertion 'hash_table 
!= NULL' failed
ofonod[25541]: Modem channel disconnected
ofonod[25541]: src/gprs.c:gprs_context_remove() atom: 0xcb1d10
ofonod[25541]: drivers/atmodem/gprs-context.c:at_gprs_context_remove() 

(ofonod:25541): GLib-CRITICAL **: g_queue_pop_head: assertion 'queue != NULL' 
failed

(ofonod:25541): GLib-CRITICAL **: g_queue_free: assertion 'queue != NULL' failed

(ofonod:25541): GLib-CRITICAL **: g_hash_table_destroy: assertion 'hash_table 
!= NULL' failed
ofonod[25541]: Modem channel disconnected
ofonod[25541]: src/gprs.c:gprs_context_remove() atom: 0xcb1d10
ofonod[25541]: drivers/atmodem/gprs-context.c:at_gprs_context_remove() 

(ofonod:25541): GLib-CRITICAL **: g_queue_pop_head: assertion 'queue != NULL' 
failed

(ofonod:25541): GLib-CRITICAL **: g_queue_free: assertion 'queue != NULL' failed

(ofonod:25541): GLib-CRITICAL **: g_hash_table_destroy: assertion 'hash_table 
!= NULL' failed
ofonod[25541]: Modem channel disconnected
ofonod[25541]: src/gprs.c:gprs_context_remove() atom: 0xcb1d10
ofonod[25541]: drivers/atmodem/gprs-context.c:at_gprs_context_remove() 

(ofonod:25541): GLib-CRITICAL **: g_queue_pop_head: assertion 'queue != NULL' 
failed

(ofonod:25541): GLib-CRITICAL **: g_queue_free: assertion 'queue != NULL' failed

(ofonod:25541): GLib-CRITICAL **: g_hash_table_destroy: assertion 'hash_table 
!= NULL' failed
ofonod[25541]: Modem channel disconnected
ofonod[25541]: src/gprs.c:gprs_context_remove() atom: 0xcb1d10
ofonod[25541]: drivers/atmodem/gprs-context.c:at_gprs_context_remove() 
[...]






ofonod[27950]: IP: 100.91.239.46
ofonod[27950]: DNS: 139.7.30.126, 139.7.30.125
ofonod[27950]: src/gprs.c:pri_activate_callback() 0x15feb20
ofonod[27950]: plugins/udevng.c:add_serial_device() Device is missing required 
OFONO_DRIVER property
ofonod[27950]: plugins/udevng.c:check_modem_list() 
ofonod[27950]: src/modem.c:modem_change_state() old state: 3, new state: 0
ofonod[27950]: src/modem.c:flush_atoms() 
ofonod[27950]: src/message-waiting.c:mw_remove() atom: 0x160d790
ofonod[27950]: src/call-barring.c:call_barring_remove() atom: 0x15f8790
ofonod[27950]: src/call-settings.c:call_settings_remove() atom: 0x15f8640
ofonod[27950]: src/call-forwarding.c:call_forwarding_remove() atom: 0x15f8500
ofonod[27950]: src/ussd.c:ussd_remove() atom: 0x15f8360
ofonod[27950]: 

Re: Huawei MS2131

2018-01-19 Thread Daniel Wagner

Hi Xingxing,

On 01/19/2018 03:27 PM, He, Xingxing wrote:

Hi Denis,

Applying usb-modeswith patch for switching MS2131 to PPP mode, without swapping 
ports(mdm<->pcui), the modem finally registered network successfully:
[ org.ofono.NetworkRegistration ]
 MobileCountryCode = 262
 MobileNetworkCode = 02
 Name = Vodafone.de
 Status = registered
 Technology = umts
 Strength = 83
 Mode = auto
   [ org.ofono.ConnectionManager ]
 Attached = 1
 Powered = 1
 Suspended = 0
 RoamingAllowed = 0
 Bearer = umts

However, when I tried "./activate-context", there was an error. The modem is 
still failed to access internet. :(
root@iot2000-ebs:/usr/lib/ofono/test# ./activate-context
Error activating /huawei_0/context1: org.ofono.Error.NotImplemented: 
Implementation not provided.


IIRC, the MCC (MobileContryCode) and MNC (MobileNetworkCode) are not in 
the mobile-broadband-provider-info and therefore there is no automatic 
provisioning of the context. Not sure what happens when the context is 
not setup correctly.


Thanks,
Daniel
___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono


Huawei MS2131

2018-01-18 Thread Daniel Wagner
Hi,

Xingxing and I am trying to get the Huawei MS2131 working. After 
swapping mdm with pcui interface, oFono starts to talk to the device.

--- a/plugins/udevng.c
+++ b/plugins/udevng.c
@@ -332,14 +332,14 @@ static gboolean setup_huawei(struct modem_info *modem)
g_strcmp0(info->interface, "255/2/1") == 0 ||
g_strcmp0(info->interface, "255/3/1") == 0 ||
g_strcmp0(info->interface, "255/1/49") == 0) {
-   mdm = info->devnode;
+   pcui = info->devnode;
} else if (g_strcmp0(info->label, "pcui") == 0 ||
g_strcmp0(info->interface, "255/1/2") == 0 ||
g_strcmp0(info->interface, "255/2/2") == 0 ||
g_strcmp0(info->interface, "255/2/18") == 0 ||
g_strcmp0(info->interface, "255/3/18") == 0 ||
g_strcmp0(info->interface, "255/1/50") == 0) {
-   pcui = info->devnode;
+   mdm = info->devnode;
} else if (g_strcmp0(info->label, "diag") == 0 ||
g_strcmp0(info->interface, "255/1/3") == 0 ||
g_strcmp0(info->interface, "255/2/3") == 0 ||


A enable-modem and online-modem later oFono gets stuck at netreg searching
for a network.

So to check if the modem and the SIM are working we played with wvdial:

root@iot2000-ebs:/etc# wvdial MS2131
--> WvDial: Internet dialer version 1.61
--> Initializing modem.
--> Sending: AT^NDISDUP=1,1
AT^NDISDUP=1,1
OK
--> Sending: AT+CGDCONT=1,"IP","web.vodafone.de"
AT+CGDCONT=1,"IP","web.vodafone.de"
OK
--> Modem initialized.
--> Configuration does not specify a valid phone number.


root@iot2000-ebs:/etc# ifup wwan0
udhcpc (v1.24.1) started
Sending discover...
Sending select for 100.92.86.33...
Lease of 100.92.86.33 obtained, lease time 518400
/etc/udhcpc.d/50default: Adding DNS 139.7.30.126
/etc/udhcpc.d/50default: Adding DNS 139.7.30.125

 

Stupid mode:
root@iot2000-ebs:/etc# wvdial MSSS
--> WvDial: Internet dialer version 1.61
--> Initializing modem.
--> Sending: ATZ
ATZ
OK
--> Sending: AT+CGDCONT=1,"IP","web.vodafone.de"
AT+CGDCONT=1,"IP","web.vodafone.de"
OK
--> Modem initialized.
--> Sending: ATDT*99***1#
--> Waiting for carrier.
ATDT*99***1#
CONNECT 2160
--> Carrier detected.  Starting PPP immediately.
--> Starting pppd at Thu Jan 18 08:51:33 2018
--> Pid of pppd: 942
PPP generic driver version 2.4.2
--> pppd: ▒e[07][08]
--> Using interface ppp0
--> pppd: ▒e[07][08]
--> pppd: ▒e[07][08]
--> pppd: ▒e[07][08]
--> pppd: ▒e[07][08]
PPP BSD Compression module registered
PPP Deflate Compression module registered
--> pppd: ▒e[07][08]
--> local  IP address 100.68.88.182
--> pppd: ▒e[07][08]
--> remote IP address 10.64.64.64
--> pppd: ▒e[07][08]
--> primary   DNS address 139.7.30.126
--> pppd: ▒e[07][08]
--> secondary DNS address 139.7.30.125
--> pppd: ▒e[07][08]
^CCaught signal 2:  Attempting to exit gracefully...
--> Terminating on signal 15
--> pppd: ▒e[07][08]
--> Connect time 5.4 minutes.
--> pppd: ▒e[07][08]
--> pppd: ▒e[07][08]
--> pppd: ▒e[07][08]
--> Disconnecting at Thu Jan 18 08:56:56 2018

 

Without stupid mode:

root@iot2000-ebs:/etc# wvdial MSSS
--> WvDial: Internet dialer version 1.61
--> Initializing modem.
--> Sending: ATZ
ATZ
OK
--> Sending: AT+CGDCONT=1,"IP","web.vodafone.de"
AT+CGDCONT=1,"IP","web.vodafone.de"
OK
--> Modem initialized.
--> Sending: ATDT*99***1#
--> Waiting for carrier.
ATDT*99***1#
CONNECT 2160
--> Carrier detected.  Waiting for prompt.
--> Don't know what to do!  Starting pppd and hoping for the best.
--> Starting pppd at Thu Jan 18 08:57:52 2018
--> Pid of pppd: 1021
--> pppd: �e[07][08]
--> Using interface ppp0
--> pppd: �e[07][08]
--> pppd: �e[07][08]
--> pppd: �e[07][08]
--> pppd: �e[07][08]
--> pppd: �e[07][08]
--> local  IP address 100.68.122.98
--> pppd: �e[07][08]
--> remote IP address 10.64.64.64
--> pppd: �e[07][08]
--> primary   DNS address 139.7.30.126
--> pppd: �e[07][08]
--> secondary DNS address 139.7.30.125
--> pppd: �e[07][08]


As you can see, when the netreg is just ignored and start
with pppd we get a connnection.

Just dumping the debug state. Mabye someone has some input on this.

Thanks,
Daniel
[16:18:12.800815] ofonod[3277]: oFono version 1.21
[16:18:12.800865] ofonod[3277]: src/plugin.c:__ofono_plugin_init() 
[16:18:12.800883] ofonod[3277]: src/gprs-provision.c:ofono_gprs_provision_driver_register() driver: 0x77dc40 name: GPRS context provisioning
[16:18:12.800896] ofonod[3277]: plugins/push-notification.c:push_notification_init() 
[16:18:12.800909] ofonod[3277]: plugins/smart-messaging.c:smart_messaging_init() 
[16:18:12.800919] ofonod[3277]: plugins/emulator_fuzz.c:emulator_fuzz_init() 
[16:18:12.800931] ofonod[3277]: src/modem.c:ofono_modem_driver_register() driver: 0x77de80, name: stktest

Re: connmand[186]: Online check failed but running dhclient manually fixes this issue

2017-09-06 Thread Daniel Wagner
Hi Denis,

Denis Kenzior <denk...@gmail.com> writes:
> On 09/05/2017 09:46 AM, Alexander Couzens wrote:
>> On Thu, 10 Aug 2017 12:47:28 +0200
>> Daniel Wagner <w...@monom.org> wrote:
>>
>>>> Bus 001 Device 003: ID 1bc7:1201 Telit Wireless Solutions
>>>
>>> Here is a compile tested 'fix'. I don't know if this works and\
>>> obviously it doesn't follow the coding guide lines for this
>>> project. If you could test this and report back the outcome
>>> that would be really helpful. Then I can create a proper
>>> patch for Denis.
>>
>> I can confirm this bug with an quectel ec20 using the firmware
>> EC20EQAR02A13E2G  1  [Jul  5 2017 10:49:17].
>>
>> To reproduce using ofono w/o connman. linux 4.12.8
>> - call ofono "../context1 Active true"
>> - set the ip by hand. No ping response.
>> - using dhcpcd. Ping responses.
>>
>> The `ip addr show` looks the same, except the interface has now an ipv6
>> link local address. Is this is problem of modern LTE cards?
>> Could be raw-ip or 802.3 encapsulations the problem?
>>
>
> Here's something Reinhard said in a different thread that might be
> applicable here:
>
> "Unfortunately the PLS8 seems to need DHCP to be used as a trigger to
> pass IPv4 traffic over the network interface even if the parameters
> could be obtained from AT commands.
>
> This restriction also holds for some other Qualcomm firmwares when the
> QMI network interface is used in Ethernet mode instead of Raw IP mode."
>
> If this is true, then falling back to DHCP would seem to be required
> for many Qualcomm based devices.  This seems to be a recently
> introduced 'bug' as older QMI devices did not need this workaround.

Do you think we should try to figure out which Qualcomm device is
misbehaving or should the feature just be reverted?

The other option is to add some fallback mechanism in ConnMan and print
a fat warning into the log. But I don't this idea.

Thanks,
Daniel
___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono


Re: AW: AW: AW: AW: connmand[186]: Online check failed but running dhclient manually fixes this issue

2017-08-10 Thread Daniel Wagner
>Bus 001 Device 003: ID 1bc7:1201 Telit Wireless Solutions

Here is a compile tested 'fix'. I don't know if this works and\
obviously it doesn't follow the coding guide lines for this
project. If you could test this and report back the outcome
that would be really helpful. Then I can create a proper
patch for Denis.


>From de165e84a0d58aabb0dcdd46cd77eba751a3b407 Mon Sep 17 00:00:00 2001
From: Daniel Wagner <w...@monom.org>
Date: Thu, 10 Aug 2017 12:40:39 +0200
Subject: [PATCH] qmimodem: Do not add IP config for Telit 910 EUG

This modem reports wrong IP configuration back. It's safer not to
report a bogus configuration because the user has no chance to know if
this is broken configuration or not. The user can still fall back to
DHCP. This was also the default behaviour till 475b789f3de9 ("qmi:
retrieve GPRS context parameters").
---
 drivers/qmimodem/gprs-context.c | 5 -
 plugins/udevng.c| 4 
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/qmimodem/gprs-context.c b/drivers/qmimodem/gprs-context.c
index 9a22b89f1e54..d7c3ceba41e6 100644
--- a/drivers/qmimodem/gprs-context.c
+++ b/drivers/qmimodem/gprs-context.c
@@ -91,6 +91,7 @@ static void get_settings_cb(struct qmi_result *result, void 
*user_data)
 
DBG("");
 
+   modem = ofono_gprs_context_get_modem(gc);
if (qmi_result_set_error(result, NULL))
goto done;
 
@@ -106,6 +107,9 @@ static void get_settings_cb(struct qmi_result *result, void 
*user_data)
if (qmi_result_get_uint8(result, QMI_WDS_RESULT_IP_FAMILY, _family))
DBG("IP family %d", ip_family);
 
+   if (ofono_modem_get_boolean(modem, "IgnoreIPConfig"))
+   goto done;
+
if (qmi_result_get_uint32(result,QMI_WDS_RESULT_IP_ADDRESS, _addr)) {
addr.s_addr = htonl(ip_addr);
straddr = inet_ntoa(addr);
@@ -146,7 +150,6 @@ static void get_settings_cb(struct qmi_result *result, void 
*user_data)
ofono_gprs_context_set_ipv4_dns_servers(gc, dns);
 
 done:
-   modem = ofono_gprs_context_get_modem(gc);
interface = ofono_modem_get_string(modem, "NetworkInterface");
 
ofono_gprs_context_set_interface(gc, interface);
diff --git a/plugins/udevng.c b/plugins/udevng.c
index aa28bcb8911e..460a6287367e 100644
--- a/plugins/udevng.c
+++ b/plugins/udevng.c
@@ -688,6 +688,10 @@ static gboolean setup_telitqmi(struct modem_info *modem)
 
ofono_modem_set_boolean(modem->modem, "ForceSimLegacy", TRUE);
ofono_modem_set_boolean(modem->modem, "AlwaysOnline", TRUE);
+
+   if (g_strcmp0(modem->model, "1012") == 0)
+   ofono_modem_set_boolean(modem->modem, "IgnoreIPConfig", TRUE);
+
ofono_modem_set_driver(modem->modem, "gobi");
 
return TRUE;
-- 
2.9.4
___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono


Re: AW: AW: AW: connmand[186]: Online check failed but running dhclient manually fixes this issue

2017-08-10 Thread Daniel Wagner

Hi Vinothkumar,

[sorry for the last mails where I got your last name mixed up...]

On 08/10/2017 07:03 AM, Eswaran Vinothkumar (BEG/PJ-IOT-EL) wrote:

Could you send me the exact modem description you are using? So that we can 
write quirk?

Hi,

I am using TELIT 910 EUG Modem.


Okay, maybe that is already enough. I saw that in drivers/telit.c there 
is already some code to handle variants of the modem. The matching is 
done on these strings.


Are there any vid/pid available fot his modem?

Thanks,
Daniel
___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono


Re: AW: AW: connmand[186]: Online check failed but running dhclient manually fixes this issue

2017-08-09 Thread Daniel Wagner

Hi Christophe and Eswaran,

I just discussed this problem with Denis on IRC. Denis is quite sure the 
modem is broken. To fix this, we need to add a quirk to the device 
driver in oFono code base which disables the IP configuration reporting. 
With this ConnMan will use DHCP in those cases.


Could you send me the exact modem description you are using? So that we 
can write quirk?


Thanks,
Daniel
___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono


Re: AW: AW: connmand[186]: Online check failed but running dhclient manually fixes this issue

2017-07-26 Thread Daniel Wagner
[added ofono mailing list]

Summery: The qmi modem returns since 475b789f3de9 ("qmi: retrieve GPRS
context parameters") the IP configuration which is sometimes incorrect.
If ConnMan gets the IP configuration it doesn't do any DHCP and applies
the not working IP configuration.

On 07/26/2017 10:11 AM, Eswaran Vinothkumar (BEG/PJ-IOT-EL) wrote:
> On 07/21/2017 09:31 AM, Daniel Wagner wrote:
>> The first thing I noticed, is that we do not extract the DNS settings 
>> correctly. oFono sends 10.105.16.254 and 10.105.144.254. I starred at 
>> the oFono code base and also at ConnMan and I don't see what's going 
>> wrong.
>>
>> Jul 21 05:47:02 alen-iot-gateway ofonod[176]: 
>> ../ofono-1.20/drivers/qmimodem/gprs-context.c:get_settings_cb()
>> Jul 21 05:47:02 alen-iot-gateway ofonod[176]: 
>> ../ofono-1.20/drivers/qmimodem/gprs-context.c:get_settings_cb() APN: 
>> internetd.gdsp Jul 21 05:47:02 alen-iot-gateway ofonod[176]: 
>> ../ofono-1.20/drivers/qmimodem/gprs-context.c:get_settings_cb() PDP 
>> type 0 Jul 21 05:47:02 alen-iot-gateway ofonod[176]: 
>> ../ofono-1.20/drivers/qmimodem/gprs-context.c:get_settings_cb() IP 
>> addr: 10.249.97.226 Jul 21 05:47:02 alen-iot-gateway ofonod[176]: 
>> ../ofono-1.20/drivers/qmimodem/gprs-context.c:get_settings_cb() 
>> Gateway: 10.249.97.225 Jul 21 05:47:02 alen-iot-gateway ofonod[176]: 
>> ../ofono-1.20/drivers/qmimodem/gprs-context.c:get_settings_cb() 
>> Gateway netmask: 255.255.255.252 Jul 21 05:47:02 alen-iot-gateway 
>> ofonod[176]: 
>> ../ofono-1.20/drivers/qmimodem/gprs-context.c:get_settings_cb() 
>> Primary DNS: 10.105.16.254 Jul 21 05:47:02 alen-iot-gateway 
>> ofonod[176]: 
>> ../ofono-1.20/drivers/qmimodem/gprs-context.c:get_settings_cb() 
>> Secondary DNS: 10.105.144.254
>>
>>
>> Jul 21 05:47:02 alen-iot-gateway connmand[175]: 
>> ../connman-1.34/plugins/ofono.c:extract_ipv4_settings() Interface 
>> wwan0 Jul 21 05:47:02 alen-iot-gateway connmand[175]: 
>> ../connman-1.34/plugins/ofono.c:extract_ipv4_settings() index 6 Jul 21 
>> 05:47:02 alen-iot-gateway connmand[175]: 
>> ../connman-1.34/plugins/ofono.c:extract_ipv4_settings() Method static 
>> Jul 21 05:47:02 alen-iot-gateway connmand[175]: 
>> ../connman-1.34/plugins/ofono.c:extract_ipv4_settings() Address 
>> 10.249.97.226 Jul 21 05:47:02 alen-iot-gateway connmand[175]: 
>> ../connman-1.34/plugins/ofono.c:extract_ipv4_settings() Netmask 
>> 255.255.255.252 Jul 21 05:47:02 alen-iot-gateway connmand[175]: 
>> ../connman-1.34/plugins/ofono.c:extract_ipv4_settings() Gateway 
>> 10.249.97.225 Jul 21 05:47:02 alen-iot-gateway connmand[175]: 
>> ../connman-1.34/plugins/ofono.c:extract_ipv4_settings() Nameservers 
>> 10.105.144.254 10.105.144.254
>>
>> Could you add some printfs to the extract_nameservers() in 
>> plugins/ofono.c? And you might also want to run 
>> ofono/test/monitor-ofono so that you can see what oFono sends to 
>> ConnMan.
>>
>>
>> Address:   10.249.97.226 1010.1001.0111.111000 10
>> Netmask:   255.255.255.252 = 30  ...11 00
>> Wildcard:  0.0.0.3   ...00 11
>> =>
>> Network:   10.249.97.224/30  1010.1001.0111.111000 00 (Class 
>> A)
>> Broadcast: 10.249.97.227 1010.1001.0111.111000 11
>> HostMin:   10.249.97.225 1010.1001.0111.111000 01
>> HostMax:   10.249.97.226 1010.1001.0111.111000 10
>> Hosts/Net: 2 (Private Internet)
>>
>> Looking through the log, it looks like ConnMan does all the math 
>> correctly.
>>
>> One thing which looks inconsistent in your first report is:
>>
>> ofono_start_gsm.sh[192]: Interface is wwan0
>> ofono_start_gsm.sh[192]: IP address is 10.249.29.20
>> ofono_start_gsm.sh[192]: Gateway is 10.249.29.21
>> ofono_start_gsm.sh[192]: Nameserver is 10.105.144.254
>>
>>
>> Destination   Gateway   Genmask   Flags
>> Metric   RefUse Iface
>> 0.0.0.0   10.166.199.10 0.0.0.0   UG   0 
>>00   wwan0
>> 10.105.144.25410.166.199.10 255.255.255.255   UGH  0 
>>00   wwan0
>> 10.166.199.8  0.0.0.0   255.255.255.252   U0 
>>00   wwan0
>> 10.166.199.10 0.0.0.0   255.255.255.255   UH   0 
>>00   wwan0
>>
>> The gateway

Re: Regarding multiple APN support in ofono/connman

2017-01-13 Thread Daniel Wagner
Hi Denis,

On 01/12/2017 12:26 AM, Denis Kenzior wrote:
> On 01/11/2017 01:39 PM, Naveen Kumar Danturi wrote:
>> Hi Ofono team,
>> Is there a support in ofono for multiple PDN connections in parallel ?
>> If so what interfaces/API's it exposes to connman to manage multiple
>> APN's ? If so, I have these 2 questions :
> 
> Yes, oFono can activate multiple active contexts, assuming the hardware
> & driver supports this.  See doc/connman-api.txt.  This is the same
> interface ConnMan is using currently.  However, ConnMan only manages a
> single context of type="internet".  I think there were some patches for
> ConnMan to support multiple active internet contexts, but I'm not sure
> if they ever were accepted upstream.

Just for the record, ConnMan supports multiple context of type
"internet" now. See 71cbf35ce180cfed27bea6f4b7d1e5792d58f52c in the
ConnMan repo.

cheers,
daniel
___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono


Re: [PATCH v2 1/2] configure: Bump glib dependecy to 2.32

2016-04-26 Thread Daniel Wagner
On 04/26/2016 08:19 AM, John Ernberg wrote:

> -PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.28, dummy=yes,
> - AC_MSG_ERROR(GLib >= 2.28 is required))
> +PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.32, dummy=yes,
> + AC_MSG_ERROR(GLib >= 2.32 is required))

Some time ago we had a discussion on the ConnMan mailing list doing the
same thing. IIRC, 2.32 has a larger memory footprint compared to 2.28.
That was an issue back than. Don't know if that is still relevant.

cheers,
daniel
___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono


Re: Ofono not recognizing some USB dongles

2014-04-01 Thread Daniel Wagner
On 03/31/2014 11:25 PM, Jerônimo Lopes wrote:
 Long story, I'm trying to setup a system using Buildroot, Beaglebone
 Black, Connman, Ofono, and 3G USB dongles to connect to the internet.
 
 I have 3 usb dongles (names showed at their plastic case):  
  - ZTE MF-190: not working
  - Huawei E173: not working 
  - Huawei E160: working
 
 I'm attaching some log information of the dongles.
 
 Both not working ones, are working at a PC with Ubuntu 13.10. Also they
 are recognized as the same device on Beaglebone and PC.
 
 I'm aware that it's probably not a 'Ofono problem'. I'm using buildroot
 default kernel for the Beaglebone and set some options myself, like USB
 Serial Converter (not enabled by default), so there is a big probability
 that something is missing.

FWIW, didn't look at the logs, but one common problem I am aware of is
the missing support of CONFIG_TUN in the kernel.

HTH,
daniel
___
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono


Re: [PATCH v3 00/13] Add support for BlueZ 5 Profile1 API to dundee

2013-04-02 Thread Daniel Wagner

Hi Paulo,

[sorry for the late response, was on vacation]

On 03/25/2013 03:43 PM, Paulo Borges wrote:

Hi Daniel,

On Sun, Mar 24, 2013 at 9:31 AM, Daniel Wagner w...@monom.org
mailto:w...@monom.org wrote:

Hi Paulo,

I have pushed all patches except patch #3. dun_gw: Add BlueZ 5
version from Frédéric just added recently the definition for
DUN_GW_UUID. Obviously, I needed to update your patches to use
DUN_GW_UUID instead of DUN_UUID. The bluez4.c file also uses
DUN_GW_UUID as identifier.

Thanks a lot,
daniel


Actually, DUN profile is asymmetric: it doesn't have an UUID for each
role, they share the same UUID [1]. The only way to distinguish the
current role is to specify it when registering the profile with
bt_register_profile_with_role function.

Specifying the role when registering a DUN profile is important because
only GW should expose a SDP record.

[1]
https://www.bluetooth.org/Technical/AssignedNumbers/service_discovery.htm


I see. The thing I wanted to avoid is to have twice a define for the 
same value. In the end the way how the define is used (as you have 
described above) is essential.


cheers,
daniel

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH v3 00/13] Add support for BlueZ 5 Profile1 API to dundee

2013-03-24 Thread Daniel Wagner

Hi Paulo,

I have pushed all patches except patch #3. dun_gw: Add BlueZ 5 version 
from Frédéric just added recently the definition for DUN_GW_UUID. 
Obviously, I needed to update your patches to use DUN_GW_UUID instead of 
DUN_UUID. The bluez4.c file also uses DUN_GW_UUID as identifier.


Thanks a lot,
daniel
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH v2 07/13] dundee: Listen to devices property changes

2013-03-19 Thread Daniel Wagner

Hi Paulo,

I talked to Denis and he pointed out that this property_changed() 
function looks suspicious.


On 03/14/2013 02:32 PM, Paulo Borges wrote:

When a bluetooth device property change and this property is Alias
or UUIDs, we need to refresh our representation of this device.
---
  dundee/bluez5.c |   28 +++-
  1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/dundee/bluez5.c b/dundee/bluez5.c
index ca44656..d48aadf 100644
--- a/dundee/bluez5.c
+++ b/dundee/bluez5.c
@@ -169,11 +169,37 @@ static void property_changed(GDBusProxy *proxy, const 
char *name,
  {
const char *path = g_dbus_proxy_get_path(proxy);
const char *interface = g_dbus_proxy_get_interface(proxy);
+   const char *alias;
+   struct bluetooth_device *bt_device;
+   gboolean uuid;

if (!g_str_equal(BLUEZ_DEVICE_INTERFACE, interface))
return;

-   DBG(%s %s.%s, path, interface, name);
+   bt_device = g_hash_table_lookup(registered_devices, path);
+
+   if (g_str_equal(name, Alias)) {
+   if (bt_device == NULL)
+   return;
+
+   dbus_message_iter_get_basic(iter, alias);
+
+   DBG(%s alias changed: %s, path, alias);
+
+   bt_device-name = g_strdup(alias);
+   } else if (g_str_equal(name, UUIDs)) {
+   DBG(%s uuids changed, path);
+
+   uuid = has_dun_uuid(iter);
+
+   if (uuid) {
+   if (bt_device == NULL)
+   bluetooth_device_register(proxy);
+   } else {
+   if (bt_device != NULL)
+   bluetooth_device_unregister(path);
+   }
+   }


So first thing, the nesting is should be avoided. Sorry, that's my bad.

if (uuid  bt_device == NULL) register

if (!uuid  bt_device) unregister

is what is an the ofono style.


  }

  static void connect_handler(DBusConnection *conn, void *user_data)



The next thing is why don't you use g_dbus_proxy_set_property_watch() 
for the property change. Then it might also be worth to split out the

the property handling into individual function. So one for Alias change
and one for UUID change.

See how Alias is handled in plugins/hfp_hf_bluez5.c

And there is the question came up, why it is necessary to handle UUID 
changes. Is this because a phone can enable/disable tethering?


cheers,
daniel

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH v2 11/13] dundee: Add support for driver connect

2013-03-18 Thread Daniel Wagner
Hi Paulo,

The series breaks to compile at this patch.

On 03/14/2013 02:32 PM, Paulo Borges wrote:
 This patch glues together the dundee driver interface with the
 D-Bus Profile1 interface.
 
 When the dundee driver requests a connection, it will call the
 Device1's ConnectProfile.
 ---
   dundee/bluez5.c |7 ++-
   1 file changed, 6 insertions(+), 1 deletion(-)
 
 diff --git a/dundee/bluez5.c b/dundee/bluez5.c
 index 82bb7aa..2d10e5a 100644
 --- a/dundee/bluez5.c
 +++ b/dundee/bluez5.c
 @@ -114,7 +114,12 @@ static void bluetooth_device_destroy(gpointer user_data)
   static void bluetooth_device_connect(struct dundee_device *device,
   dundee_device_connect_cb_t cb, void *data)
   {
 - DBG();
 + struct bluetooth_device *bt_device = dundee_device_get_data(device);
 +
 + DBG(%s, bt_device-path);
 +
 + bt_connect_profile(ofono_dbus_get_connection(), bt_device-path,
 + DUN_DT_UUID, NULL, NULL);
   }
   
   static void bluetooth_device_disconnect(struct dundee_device *device,
 

HEAD is now at 1198ace dundee: Add support for driver connect
make --no-print-directory all-am
  CC   dundee/bluez5.o
dundee/bluez5.c: In function ‘bluetooth_device_connect’:
dundee/bluez5.c:122:7: error: ‘DUN_DT_UUID’ undeclared (first use in this 
function)
dundee/bluez5.c:122:7: note: each undeclared identifier is reported only once 
for each function it appears in
make[1]: *** [dundee/bluez5.o] Error 1
make: *** [all] Error 2
Broke on 1198aceb147e2839a86b5f5c1cf65556d3d8fa2d


Should that be DUN_UUID?


cheers,
daniel
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH v2 00/13] Add support for BlueZ 5 Profile1 API to dundee

2013-03-18 Thread Daniel Wagner
Hi Paulo,

I have tested this version and it seems to work. I say 'seems' because I was 
not able
keep open the connection. All phones I have tested open the connection and close
them right after. I am not sure if just my setup is broken. Testing against 
bluez4
gave the same behaviour. So I don't think your patches are causing this.

If Denis or Marcel do not speak up now, I'll apply them (fixing the compile 
glitch on
on patch #13, no need to resend the series.)

cheers,
daniel


dundee[1081]: dundee/device.c:set_property_active() 0x1e78960 path /device0
dundee[1081]: dundee/bluez5.c:bluetooth_device_connect() 
/org/bluez/hci0/dev_A0_4E_04_F6_F5_05
dundee[1081]: plugins/bluez5.c:device_send_message() Bluetooth: sending 
ConnectProfile for 1103--1000-8000-00805f9b34fb on 
/org/bluez/hci0/dev_A0_4E_04_F6_F5_05
dundee[1081]: dundee/bluez5.c:profile_new_connection() 
/org/bluez/hci0/dev_A0_4E_04_F6_F5_05 8
dundee[1081]: dundee/device.c:connect_callback() 0x1e78960
dundee[1081]: dundee/device.c:debug() Control:  ATD*99#\r
dundee[1081]: dundee/bluez5.c:bluetooth_device_connect_callback() Success
dundee[1081]: dundee/device.c:debug() Control:  ATD*99#\r
dundee[1081]: dundee/device.c:debug() Control:  \r\nCONNECT\r\n
dundee[1081]: dundee/device.c:debug() PPP: lcp: pppcp_generate_event: current 
state 0:INITIAL
dundee[1081]: dundee/device.c:debug() PPP: event: 0 (Up), action: 2, new_state: 
2 (CLOSED)
dundee[1081]: dundee/device.c:debug() PPP: lcp: pppcp_generate_event: current 
state 2:CLOSED
dundee[1081]: dundee/device.c:debug() PPP: event: 2 (Open), action: 1026, 
new_state: 6 (REQSENT)
dundee[1081]: dundee/device.c:debug() PPP: lcp: pppcp_initialize_restart_count: 
current state 2:CLOSED
dundee[1081]: dundee/device.c:debug() PPP: lcp: pppcp_send_configure_request: 
current state 2:CLOSED
dundee[1081]: dundee/device.c:debug() PPP: gatchat/gatppp.c:ppp_enter_phase() 1
dundee[1081]: dundee/device.c:debug() PPP: lcp: 
pppcp_process_configure_request: current state 6:REQSENT
dundee[1081]: dundee/device.c:debug() PPP: lcp: pppcp_generate_event: current 
state 6:REQSENT
dundee[1081]: dundee/device.c:debug() PPP: event: 7 (RCR-), action: 4006, 
new_state: 6 (REQSENT)
dundee[1081]: dundee/device.c:debug() PPP: lcp: pppcp_send_configure_nak: 
current state 6:REQSENT
dundee[1081]: dundee/device.c:debug() PPP: lcp: pppcp_process_configure_ack: 
current state 6:REQSENT
dundee[1081]: dundee/device.c:debug() PPP: lcp: pppcp_generate_event: current 
state 6:REQSENT
dundee[1081]: dundee/device.c:debug() PPP: event: 8 (RCA), action: 27, 
new_state: 7 (ACKRCVD)
dundee[1081]: dundee/device.c:debug() PPP: lcp: pppcp_initialize_restart_count: 
current state 6:REQSENT
dundee[1081]: dundee/device.c:debug() PPP: lcp: 
pppcp_process_configure_request: current state 7:ACKRCVD
dundee[1081]: dundee/device.c:debug() PPP: lcp: pppcp_generate_event: current 
state 7:ACKRCVD
dundee[1081]: dundee/device.c:debug() PPP: event: 6 (RCR+), action: 2109, 
new_state: 9 (OPENED)
dundee[1081]: dundee/device.c:debug() PPP: lcp: pppcp_send_configure_ack: 
current state 7:ACKRCVD
dundee[1081]: dundee/device.c:debug() PPP: gatchat/gatppp.c:ppp_enter_phase() 2
dundee[1081]: dundee/device.c:debug() PPP: gatchat/gatppp.c:ppp_enter_phase() 3
dundee[1081]: dundee/device.c:debug() PPP: ipcp: pppcp_generate_event: current 
state 0:INITIAL
dundee[1081]: dundee/device.c:debug() PPP: event: 2 (Open), action: 401, 
new_state: 1 (STARTING)
dundee[1081]: dundee/device.c:debug() PPP: ipcp: pppcp_generate_event: current 
state 1:STARTING
dundee[1081]: dundee/device.c:debug() PPP: event: 0 (Up), action: 1026, 
new_state: 6 (REQSENT)
dundee[1081]: dundee/device.c:debug() PPP: ipcp: 
pppcp_initialize_restart_count: current state 1:STARTING
dundee[1081]: dundee/device.c:debug() PPP: ipcp: pppcp_send_configure_request: 
current state 1:STARTING
dundee[1081]: dundee/device.c:debug() PPP: ipcp: 
pppcp_process_configure_request: current state 6:REQSENT
dundee[1081]: dundee/device.c:debug() PPP: ipcp: pppcp_generate_event: current 
state 6:REQSENT
dundee[1081]: dundee/device.c:debug() PPP: event: 6 (RCR+), action: 2008, 
new_state: 8 (ACKSENT)
dundee[1081]: dundee/device.c:debug() PPP: ipcp: pppcp_send_configure_ack: 
current state 6:REQSENT
dundee[1081]: dundee/device.c:debug() PPP: ipcp: 
pppcp_process_configure_reject: current state 8:ACKSENT
dundee[1081]: dundee/device.c:debug() PPP: ipcp: pppcp_generate_event: current 
state 8:ACKSENT
dundee[1081]: dundee/device.c:debug() PPP: event: 9 (RCN), action: 1028, 
new_state: 8 (ACKSENT)
dundee[1081]: dundee/device.c:debug() PPP: ipcp: 
pppcp_initialize_restart_count: current state 8:ACKSENT
dundee[1081]: dundee/device.c:debug() PPP: ipcp: pppcp_send_configure_request: 
current state 8:ACKSENT
dundee[1081]: dundee/device.c:debug() PPP: ipcp: pppcp_process_configure_nak: 
current state 8:ACKSENT
dundee[1081]: dundee/device.c:debug() PPP: ipcp: pppcp_generate_event: current 
state 8:ACKSENT
dundee[1081]: 

Re: [PATCH 07/13] dundee: Listen to devices property changes

2013-03-12 Thread Daniel Wagner

+uuid = has_dun_uuid(iter);
+
+if (bt_device != NULL  uuid == FALSE)
+bluetooth_device_unregister(path);
+
+else if (bt_device == NULL  uuid == TRUE)
+bluetooth_device_register(proxy);
+}


I find this a bit hard to read. What about

 if (uuid)
 if (bt_device != NULL)
 bluetooth_device_unregister(path);
 else
 if (bt_device == NULL)
 bluetooth_device_regster(path);


Obviously, some braces are needed :)

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH 2/2] dun_gw: Add BlueZ 5 version

2013-03-12 Thread Daniel Wagner

diff --git a/plugins/dun_gw_bluez5.c b/plugins/dun_gw_bluez5.c
new file mode 100644
index 000..902df32
--- /dev/null
+++ b/plugins/dun_gw_bluez5.c
@@ -0,0 +1,235 @@
+/*
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2011  Intel Corporation. All rights reserved.


2013?
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH 02/13] dundee: Start BlueZ 5 support

2013-03-11 Thread Daniel Wagner

Hi Paulo,

I guess, I am in charge to review your patches. Let's start then :)

Just a nitpick in this one.

On 03/04/2013 08:33 PM, Paulo Borges wrote:

This patch adds the BlueZ 5 support file for dundee.
---
  Makefile.am |   16 ++--
  dundee/bluez5.c |   37 +
  2 files changed, 47 insertions(+), 6 deletions(-)
  create mode 100644 dundee/bluez5.c

diff --git a/Makefile.am b/Makefile.am
index ed35988..1748d06 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -756,24 +756,28 @@ endif
  endif

  if BLUETOOTH
-if BLUEZ4
  if DUNDEE
  sbin_PROGRAMS += dundee/dundee

-dundee_dundee_SOURCES = $(gdbus_sources) $(gatchat_sources) $(btio_sources) \
-   src/log.c src/dbus.c plugins/bluez4.c \
-   dundee/dundee.h dundee/main.c dundee/dbus.c \
-   dundee/manager.c dundee/device.c dundee/bluez4.c
+dundee_common_sources = $(gdbus_sources) $(gatchat_sources) \
+   src/log.c src/dbus.c dundee/dundee.h dundee/main.c \
+   dundee/dbus.c dundee/manager.c dundee/device.c

  dundee_dundee_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ -ldl

  if DATAFILES
  dist_dbusconf_DATA += dundee/dundee.conf
-
  if SYSTEMD
  systemdunit_DATA += dundee/dundee.service
  endif
  endif


The line removal seems not necessary.

cheers,
daniel
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH 04/13] dundee: Initial GDBusClient for BlueZ 5

2013-03-11 Thread Daniel Wagner

Hi Paulo,

On 03/04/2013 08:33 PM, Paulo Borges wrote:

This patch adds the callbacks to track additions and removals of
BlueZ related interfaces and property changes in these interfaces.
---
  dundee/bluez5.c |   60 +++
  dundee/dundee.h |2 ++
  2 files changed, 62 insertions(+)

diff --git a/dundee/bluez5.c b/dundee/bluez5.c
index 6685b4c..40df700 100644
--- a/dundee/bluez5.c
+++ b/dundee/bluez5.c
@@ -22,16 +22,76 @@
  #include config.h
  #endif

+#include stdint.h
+#include sys/socket.h
+#include gdbus.h
+
  #include dundee.h
+#include plugins/bluez5.h
+
+#define DUN_DT_PROFILE_PATH   /bluetooth/profile/dun_dt
+
+static GDBusClient *bluez;
+
+static void proxy_added(GDBusProxy *proxy, void *user_data)
+{
+   const char *path = g_dbus_proxy_get_path(proxy);
+   const char *interface = g_dbus_proxy_get_interface(proxy);
+
+   if (g_str_equal(BLUEZ_DEVICE_INTERFACE, interface) == FALSE)
+   return;


In oFono, just use let the '== FALSE' part away. The same applies for 
the rest of the series.



cheers,
daniel
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH 07/13] dundee: Listen to devices property changes

2013-03-11 Thread Daniel Wagner

Hi Paulo,

On 03/04/2013 08:33 PM, Paulo Borges wrote:

When a bluetooth device property change and this property is Alias
or UUIDs, we need to refresh our representation of this device.
---
  dundee/bluez5.c |   26 +-
  1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/dundee/bluez5.c b/dundee/bluez5.c
index 8d8e656..623201f 100644
--- a/dundee/bluez5.c
+++ b/dundee/bluez5.c
@@ -169,11 +169,35 @@ static void property_changed(GDBusProxy *proxy, const 
char *name,
  {
const char *path = g_dbus_proxy_get_path(proxy);
const char *interface = g_dbus_proxy_get_interface(proxy);
+   const char *alias;
+   struct bluetooth_device *bt_device;
+   gboolean uuid;

if (g_str_equal(BLUEZ_DEVICE_INTERFACE, interface) == FALSE)
return;

-   DBG(%s %s.%s, path, interface, name);
+   bt_device = g_hash_table_lookup(registered_devices, path);
+
+   if (g_str_equal(name, Alias) == TRUE) {
+   if (bt_device == NULL)
+   return;
+
+   dbus_message_iter_get_basic(iter, alias);
+
+   DBG(%s alias changed: %s, path, alias);
+
+   bt_device-name = g_strdup(alias);
+   } else if (g_str_equal(name, UUIDs) == TRUE) {
+   DBG(%s uuids changed, path);
+
+   uuid = has_dun_uuid(iter);
+
+   if (bt_device != NULL  uuid == FALSE)
+   bluetooth_device_unregister(path);
+
+   else if (bt_device == NULL  uuid == TRUE)
+   bluetooth_device_register(proxy);
+   }


I find this a bit hard to read. What about

if (uuid)
if (bt_device != NULL)
bluetooth_device_unregister(path);
else
if (bt_device == NULL)
bluetooth_device_regster(path);

? I am not sure if Denis or Marcel approves this :)

cheers,
daniel

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH 00/13] Add support for BlueZ 5 Profile1 API to dundee

2013-03-11 Thread Daniel Wagner

Hi Paulo,

On 03/04/2013 08:33 PM, Paulo Borges wrote:

This series implements support for BlueZ 5 to dundee. It uses the
org.bluez.Profile1 API to register an external profile.

While the interface between BlueZ and dundee has changed, the interfaces
org.ofono.dundee.Device and org.ofono.dundee.Manager remains
unchanged.


Thanks for your patches. They look pretty good to me. Let's see if Denis 
or Marcel have something to say.


cheer,
daniel

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


bluez5 support for dundee

2013-01-30 Thread Daniel Wagner

Hi,

Is someone working on bluez5 support for dundee?

cheers,
daniel
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: bluez5 support for dundee

2013-01-30 Thread Daniel Wagner

Hi Vinicius,

On 30.01.2013 13:31, Vinicius Gomes wrote:

On Wed, Jan 30, 2013 at 7:13 AM, Daniel Wagner w...@monom.org wrote:

Hi,

Is someone working on bluez5 support for dundee?


Our intern (Paulo Borges) is working on it.


Great, thanks for the heads up.

cheers,
daniel
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH] atutil: Remove unused macro

2012-12-10 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

With commit 6ee21a3fc18460cc12dbddb3b7ec70e941fa4bbc
the usage DECLARE_FAILURE was removed.
---
 drivers/atmodem/atutil.h | 5 -
 1 file changed, 5 deletions(-)

diff --git a/drivers/atmodem/atutil.h b/drivers/atmodem/atutil.h
index b17a4a5..48b9b0d 100644
--- a/drivers/atmodem/atutil.h
+++ b/drivers/atmodem/atutil.h
@@ -112,11 +112,6 @@ static inline int at_util_convert_signal_strength(int 
strength)
return result;
 }
 
-#define DECLARE_FAILURE(e) \
-   struct ofono_error e;   \
-   e.type = OFONO_ERROR_TYPE_FAILURE;  \
-   e.error = 0 \
-
 #define CALLBACK_WITH_FAILURE(cb, args...) \
do {\
struct ofono_error cb_e;\
-- 
1.8.0.rc0

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: Telit HE910 modem --- unable be put on line by Connman

2012-12-03 Thread Daniel Wagner

Hi Mingli,


On 30.11.2012 16:40, Ming Li Wu wrote:

Hello,

I am working on Telit HE910 modem.

I am using ofono 1.11, and the commit is
6e3a6156b34c52bde253b097976d0ba9dd575879.

For the Telit modem, AT+CFUN=4 is used to enable
the modem. According to Telit He910 AT Commands
Reference Guide, issuing AT+CFUN=4[,0] actually
causes the module to perform either a network
deregistration and a SIM deactivation.


Is rfkill enabled?

cheers,
daniel
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: Telit HE910 modem --- unable be put on line by Connman

2012-12-03 Thread Daniel Wagner

Hi Mingli

[please don't top post.]

On 03.12.2012 11:37, Ming Li Wu wrote:

Hi Daniel,

Thanks for your reply.

I am using an arm development board in which ofono is running.
rfkill is not installed. should I install it?


I wanted to ask you if the the interface is rfkilled (e.b. by ConnMan). 
The rfkill tool is able to show the current applied settings.


HTH,
daniel
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH v0 4/4] bluetooth: Fix Device PropertyChanged

2012-11-20 Thread Daniel Wagner

Hi Claudio,

On 20.11.2012 13:12, Claudio Takahasi wrote:

BlueZ PropertyChanged signal for Device objects was replaced by
PropertiesChanged emitted on org.freedesktop.DBus.Properties interface.


Do I understand this correctly, we will not support older BlueZ after 
this change? I would expect that we support 4.x and 5.x at the same time 
for a while.


cheers,
daniel

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH 00/11] Samsung IPC modem support

2012-09-19 Thread Daniel Wagner

Hi Simon,


On 18.09.2012 20:18, Simon Busch wrote:

Heyho,

the following patch series adds support for the Samsung IPC protocol which is 
implemented
in an external library called libsamsung-ipc (see [0]). The library contains the
implementation of the protocol used in most Samsung mobile handsets. As of 
right now the
implementation contains drivers for the devinfo, sim, voicecall, gprs and 
gprs-context
subsystems. Implementation for other subsystems like sms will follow.



The COPYING file from the libsamsung-ipc indicates that it is released 
under GPLv3. oFono is pure GPLv2. I fear this is a show stopper.


cheers,
daniel
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [RFC v1] gatchat: Print error message if opening tun failes

2012-09-09 Thread Daniel Wagner
Hi Denis,

On 08/31/2012 12:07 AM, Denis Kenzior wrote:
 On 08/24/2012 07:16 AM, Daniel Wagner wrote:
 From: Daniel Wagnerdaniel.wag...@bmw-carit.de

 This is a very common misstake. Let's help the users to
 configure their system correctly.
 ---
 Hi,

 I was not able to find out why the check in at_grps_context_prope() 
 does not
 hit when the tun module is not loaded. Therefore, this on gets only
 an RFC state...

 cheers,
 daniel

   gatchat/ppp_net.c | 6 +-
   1 file changed, 5 insertions(+), 1 deletion(-)

 
 I went ahead and applied this patch, thanks.

I wonder if we should do something like this here

http://git.kernel.org/?p=network/connman/connman.git;a=commitdiff;h=4fe07dfed4f720136ee142e56a9d43242c8c78dc

cheers,
daniel

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[RFC v1] gatchat: Print error message if opening tun failes

2012-08-24 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

This is a very common misstake. Let's help the users to
configure their system correctly.
---
Hi,

I was not able to find out why the check in at_grps_context_prope() does not
hit when the tun module is not loaded. Therefore, this on gets only
an RFC state...

cheers,
daniel

 gatchat/ppp_net.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gatchat/ppp_net.c b/gatchat/ppp_net.c
index 1609b99..813ed9b 100644
--- a/gatchat/ppp_net.c
+++ b/gatchat/ppp_net.c
@@ -155,8 +155,12 @@ struct ppp_net *ppp_net_new(GAtPPP *ppp, int fd)
if (fd  0) {
/* open a tun interface */
fd = open(/dev/net/tun, O_RDWR);
-   if (fd  0)
+   if (fd  0) {
+   ppp_debug(ppp, Couldn't open tun device. 
+   Do you run oFono as root and do you 
+   have the TUN module loaded?);
goto error;
+   }
 
ifr.ifr_flags = IFF_TUN | IFF_NO_PI;
strcpy(ifr.ifr_name, ppp%d);
-- 
1.7.12.rc1.16.g05a20c8

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[RFC] gatchat: Print error message if opening tun failes

2012-08-21 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

This is a very common misstake. Let's help the users to
configure their system correctly.
---
 gatchat/ppp_net.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gatchat/ppp_net.c b/gatchat/ppp_net.c
index 1609b99..7082de7 100644
--- a/gatchat/ppp_net.c
+++ b/gatchat/ppp_net.c
@@ -155,8 +155,12 @@ struct ppp_net *ppp_net_new(GAtPPP *ppp, int fd)
if (fd  0) {
/* open a tun interface */
fd = open(/dev/net/tun, O_RDWR);
-   if (fd  0)
+   if (fd  0) {
+   fprintf(stderr, Couldn't open tun device. 
+   Do you run oFono as root and do you 
+   have the TUN module loaded?);
goto error;
+   }
 
ifr.ifr_flags = IFF_TUN | IFF_NO_PI;
strcpy(ifr.ifr_name, ppp%d);
-- 
1.7.12.rc1.16.g05a20c8

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [RFC] gatchat: Print error message if opening tun failes

2012-08-21 Thread Daniel Wagner

Hi Marcel,

On 21.08.2012 15:00, Marcel Holtmann wrote:

This is a very common misstake. Let's help the users to
configure their system correctly.
---
  gatchat/ppp_net.c | 6 +-
  1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gatchat/ppp_net.c b/gatchat/ppp_net.c
index 1609b99..7082de7 100644
--- a/gatchat/ppp_net.c
+++ b/gatchat/ppp_net.c
@@ -155,8 +155,12 @@ struct ppp_net *ppp_net_new(GAtPPP *ppp, int fd)
if (fd  0) {
/* open a tun interface */
fd = open(/dev/net/tun, O_RDWR);
-   if (fd  0)
+   if (fd  0) {
+   fprintf(stderr, Couldn't open tun device. 
+   Do you run oFono as root and do you 
+   have the TUN module loaded?);


really, stderr?


I was not sure what 'channel' to use to report something from gatchat. 
Would g_print() be the right choice?



goto error;
+   }

ifr.ifr_flags = IFF_TUN | IFF_NO_PI;
strcpy(ifr.ifr_name, ppp%d);


Aren't the atom drivers checking this case for you?


I don't know, but I had the exactly the same problem and I am pretty 
sure that there was not log entry in any kind. If there is better place 
to add such a log entry, I happy to send a patch.


cheers,
daniel
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH] dundee: disconnect bluetooth link in case dial fails

2012-08-17 Thread Daniel Wagner
Hi Gustavo,

On Mon, Aug 13, 2012 at 06:52:06PM -0300, Gustavo Padovan wrote:
 From: Gustavo Padovan gustavo.pado...@collabora.co.uk
 
 If the ATD*99# dial fails for some reason, NO CARRIER, for example, we
 need to disconnect the bluetooth link and do further clean up on
 disconnect_callback().

Patch applied.

thanks,
daniel
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH 1/2] dundee: add timeout to close stalled ppp handshake

2012-08-17 Thread Daniel Wagner
Hi Gustavo,

On Tue, Aug 14, 2012 at 04:14:31AM -0300, Gustavo Padovan wrote:
 From: Gustavo Padovan gustavo.pado...@collabora.co.uk
 
 If something goes wrong the PPP handshake can stall, then we just add a
 timer to return an error after a certain timeout (15 seconds).

Both patches applied.

I also updated the documentation on the interface. The SetProperty() was 
missing.

Thanks,
Daniel
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v0 0/4] Add Serial and Type property to dundee

2012-06-05 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

Hi,

The first patch is fixes an obvious typo in the introspection.

The next three patches punch a whole through the DUN device
abstraction. If a Bluetooth device supports PAN and DUN at the same
time, there is no real good reason to offer both services to
user. ConnMan needs to figure out if a device supports both profile
(and then picking PAN). For this we need to provide an device
identifier. This API estension is modeled after the modem API, where
we have to do the same thing for HFP.

cheers,
daniel

Daniel Wagner (4):
  dundee: Fix signal name
  dundee: Add Serial and Type documantation
  dundee: Add Serial property
  dundee: Add Type property

 doc/dundee-api.txt |   12 
 dundee/bluetooth.c |   11 +++
 dundee/device.c|   27 +++
 dundee/dundee.h|9 +
 dundee/manager.c   |2 +-
 5 files changed, 60 insertions(+), 1 deletion(-)

-- 
1.7.10.130.g36e6c

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v0 1/4] dundee: Fix signal name

2012-06-05 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 dundee/manager.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dundee/manager.c b/dundee/manager.c
index d7374d6..e8a37bf 100644
--- a/dundee/manager.c
+++ b/dundee/manager.c
@@ -90,7 +90,7 @@ static const GDBusMethodTable manager_methods[] = {
 };
 
 static const GDBusSignalTable manager_signals[] = {
-   { GDBUS_SIGNAL(DevicesAdded,
+   { GDBUS_SIGNAL(DeviceAdded,
GDBUS_ARGS({ path, o},{ properties, a{sv} })) },
{ GDBUS_SIGNAL(DeviceRemoved,
GDBUS_ARGS({ path, o})) },
-- 
1.7.10.130.g36e6c

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v0 2/4] dundee: Add Serial and Type documantation

2012-06-05 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 doc/dundee-api.txt |   12 
 1 file changed, 12 insertions(+)

diff --git a/doc/dundee-api.txt b/doc/dundee-api.txt
index 9f4cfe6..8c79124 100644
--- a/doc/dundee-api.txt
+++ b/doc/dundee-api.txt
@@ -74,3 +74,15 @@ Properties   string Name [readonly]
 
Holds the list of domain name servers for this
connection.
+
+   string Serial [readonly, optional]
+
+   String represeting the serial number of the modem
+   device.
+
+   string Type [readonly]
+
+   Indicates whether the device is a Bluetooth or
+   USB based one.
+
+   Possible values are blueooth or usb.
-- 
1.7.10.130.g36e6c

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v0 3/4] dundee: Add Serial property

2012-06-05 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 dundee/bluetooth.c |   10 ++
 dundee/device.c|   10 ++
 dundee/dundee.h|3 +++
 3 files changed, 23 insertions(+)

diff --git a/dundee/bluetooth.c b/dundee/bluetooth.c
index e2e2bca..0fb00a4 100644
--- a/dundee/bluetooth.c
+++ b/dundee/bluetooth.c
@@ -126,10 +126,20 @@ static void bt_connect(struct dundee_device *device,
CALLBACK_WITH_FAILURE(cb, -1, cbd-data);
 }
 
+static const char *bt_serial(struct dundee_device *device)
+{
+   struct bluetooth_device *bt = dundee_device_get_data(device);
+
+   DBG(%p, bt);
+
+   return bt-address;
+}
+
 struct dundee_device_driver bluetooth_driver = {
.name = bluetooth,
.connect = bt_connect,
.disconnect = bt_disconnect,
+   .serial = bt_serial,
 };
 
 static int bt_probe(const char *path, const char *dev_addr,
diff --git a/dundee/device.c b/dundee/device.c
index 709919a..9733b09 100644
--- a/dundee/device.c
+++ b/dundee/device.c
@@ -129,6 +129,8 @@ static void settings_append_dict(struct dundee_device 
*device,
 void __dundee_device_append_properties(struct dundee_device *device,
DBusMessageIter *dict)
 {
+   const char *serial;
+
settings_append_dict(device, dict);
 
ofono_dbus_dict_append(dict, Name, DBUS_TYPE_STRING,
@@ -136,6 +138,14 @@ void __dundee_device_append_properties(struct 
dundee_device *device,
 
ofono_dbus_dict_append(dict, Active, DBUS_TYPE_BOOLEAN,
device-active);
+
+   if (device-driver == NULL)
+   return;
+
+   serial = device-driver-serial(device);
+   if (serial)
+   ofono_dbus_dict_append(dict, Serial, DBUS_TYPE_STRING,
+   serial);
 }
 
 void __dundee_device_foreach(dundee_device_foreach_func func, void *userdata)
diff --git a/dundee/dundee.h b/dundee/dundee.h
index 8866007..ca53c88 100644
--- a/dundee/dundee.h
+++ b/dundee/dundee.h
@@ -121,6 +121,9 @@ struct dundee_device_driver {
/* Hangup and disconnect */
void (*disconnect)(struct dundee_device *device,
dundee_device_disconnect_cb_t cb, void *data);
+
+   /* Get device information */
+   const char *(*serial)(struct dundee_device *device);
 };
 
 struct dundee_device *dundee_device_create(struct dundee_device_driver *d);
-- 
1.7.10.130.g36e6c

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v0 4/4] dundee: Add Type property

2012-06-05 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 dundee/bluetooth.c |1 +
 dundee/device.c|   17 +
 dundee/dundee.h|6 ++
 3 files changed, 24 insertions(+)

diff --git a/dundee/bluetooth.c b/dundee/bluetooth.c
index 0fb00a4..c124f60 100644
--- a/dundee/bluetooth.c
+++ b/dundee/bluetooth.c
@@ -137,6 +137,7 @@ static const char *bt_serial(struct dundee_device *device)
 
 struct dundee_device_driver bluetooth_driver = {
.name = bluetooth,
+   .type = DUNDEE_DEVICE_TYPE_BLUETOOTH,
.connect = bt_connect,
.disconnect = bt_disconnect,
.serial = bt_serial,
diff --git a/dundee/device.c b/dundee/device.c
index 9733b09..fa549e1 100644
--- a/dundee/device.c
+++ b/dundee/device.c
@@ -62,6 +62,18 @@ struct dundee_device {
void *data;
 };
 
+static const char *device_type_to_string(enum dundee_device_type type)
+{
+   switch (type) {
+   case DUNDEE_DEVICE_TYPE_BLUETOOTH:
+   return bluetooth;
+   case DUNDEE_DEVICE_TYPE_USB:
+   return usb;
+   }
+
+   return unknown;
+}
+
 const char *__dundee_device_get_path(struct dundee_device *device)
 {
return device-path;
@@ -130,6 +142,7 @@ void __dundee_device_append_properties(struct dundee_device 
*device,
DBusMessageIter *dict)
 {
const char *serial;
+   const char *type;
 
settings_append_dict(device, dict);
 
@@ -146,6 +159,10 @@ void __dundee_device_append_properties(struct 
dundee_device *device,
if (serial)
ofono_dbus_dict_append(dict, Serial, DBUS_TYPE_STRING,
serial);
+
+   type = device_type_to_string(device-driver-type);
+   ofono_dbus_dict_append(dict, Type, DBUS_TYPE_STRING,
+   type);
 }
 
 void __dundee_device_foreach(dundee_device_foreach_func func, void *userdata)
diff --git a/dundee/dundee.h b/dundee/dundee.h
index ca53c88..b954a91 100644
--- a/dundee/dundee.h
+++ b/dundee/dundee.h
@@ -33,6 +33,11 @@ enum dundee_error_type {
DUNDEE_ERROR_TYPE_FAILURE,
 };
 
+enum dundee_device_type {
+   DUNDEE_DEVICE_TYPE_BLUETOOTH = 0,
+   DUNDEE_DEVICE_TYPE_USB,
+};
+
 struct dundee_error {
enum dundee_error_type type;
int error;
@@ -113,6 +118,7 @@ typedef void (*dundee_device_disconnect_cb_t)(const struct 
dundee_error *error,
 
 struct dundee_device_driver {
const char *name;
+   enum dundee_device_type type;
 
/* Connect and dial */
void (*connect)(struct dundee_device *device,
-- 
1.7.10.130.g36e6c

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH v0 0/4] Add Serial and Type property to dundee

2012-06-05 Thread Daniel Wagner
 The next three patches punch a whole through the DUN device

s/whole/hole
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH v0 2/4] dundee: Add Serial and Type documantation

2012-06-05 Thread Daniel Wagner
 + Possible values are blueooth or usb.

s/blueooth/bluetooth/

(fixed in my repo)

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v0 0/3] Prefer PAN over DUN

2012-06-04 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

Hi,

So here is the first oFono version for the prefer pan over dun
feature. Since this is a policy thing, it makes sense to place this
inside dundee and not inside ConnMan or BlueZ.

I am not really happy to pass in the UUIDs but I found it a lot nicer
than adding a 'filter' callback to struct bluetooth_profile. 

Another idea how to implement it I had was, adding a blacklist when
registering the profile.

Let's start with the simplest possible solution.

cheers,
daniel

Daniel Wagner (3):
  bluetooth: Add list of UUIDs to probe function
  bluetooth: Add PAN UUID
  dundee: Ignore DUN device if PAN is present

 dundee/bluetooth.c  |   11 ++-
 plugins/bluetooth.c |8 +---
 plugins/bluetooth.h |3 ++-
 plugins/hfp_hf.c|2 +-
 plugins/sap.c   |2 +-
 5 files changed, 19 insertions(+), 7 deletions(-)

-- 
1.7.10.130.g36e6c

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v0 1/3] bluetooth: Add list of UUIDs to probe function

2012-06-04 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 dundee/bluetooth.c  |2 +-
 plugins/bluetooth.c |8 +---
 plugins/bluetooth.h |2 +-
 plugins/hfp_hf.c|2 +-
 plugins/sap.c   |2 +-
 5 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/dundee/bluetooth.c b/dundee/bluetooth.c
index e2e2bca..5a913cc 100644
--- a/dundee/bluetooth.c
+++ b/dundee/bluetooth.c
@@ -132,7 +132,7 @@ struct dundee_device_driver bluetooth_driver = {
.disconnect = bt_disconnect,
 };
 
-static int bt_probe(const char *path, const char *dev_addr,
+static int bt_probe(GSList *uuids, const char *path, const char *dev_addr,
const char *adapter_addr, const char *alias)
 {
struct bluetooth_device *bt;
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index dbf79eb..0be6000 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -265,16 +265,18 @@ static void bluetooth_probe(GSList *uuids, const char 
*path,
const char *device, const char *adapter,
const char *alias)
 {
-   for (; uuids; uuids = uuids-next) {
+   GSList *l;
+
+   for (l = uuids; l; l = l-next) {
struct bluetooth_profile *driver;
-   const char *uuid = uuids-data;
+   const char *uuid = l-data;
int err;
 
driver = g_hash_table_lookup(uuid_hash, uuid);
if (driver == NULL)
continue;
 
-   err = driver-probe(path, device, adapter, alias);
+   err = driver-probe(uuids, path, device, adapter, alias);
if (err == 0)
continue;
 
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index 4fc16ad..c06abf7 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -38,7 +38,7 @@
 
 struct bluetooth_profile {
const char *name;
-   int (*probe)(const char *device, const char *dev_addr,
+   int (*probe)(GSList *uuids, const char *device, const char *dev_addr,
const char *adapter_addr, const char *alias);
void (*remove)(const char *prefix);
void (*set_alias)(const char *device, const char *);
diff --git a/plugins/hfp_hf.c b/plugins/hfp_hf.c
index 7c500e3..74780b7 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -206,7 +206,7 @@ static const GDBusMethodTable agent_methods[] = {
{ }
 };
 
-static int hfp_hf_probe(const char *device, const char *dev_addr,
+static int hfp_hf_probe(GSList *uuids, const char *device, const char 
*dev_addr,
const char *adapter_addr, const char *alias)
 {
struct ofono_modem *modem;
diff --git a/plugins/sap.c b/plugins/sap.c
index d893bc1..7f728f9 100644
--- a/plugins/sap.c
+++ b/plugins/sap.c
@@ -235,7 +235,7 @@ static void sap_post_online(struct ofono_modem *modem)
data-sap_driver-post_online(data-hw_modem);
 }
 
-static int bluetooth_sap_probe(const char *device, const char *dev_addr,
+static int bluetooth_sap_probe(GSList *uuds, const char *device, const char 
*dev_addr,
const char *adapter_addr, const char *alias)
 {
struct ofono_modem *modem;
-- 
1.7.10.130.g36e6c

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v0 2/3] bluetooth: Add PAN UUID

2012-06-04 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 plugins/bluetooth.h |1 +
 1 file changed, 1 insertion(+)

diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index c06abf7..e801bfc 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -32,6 +32,7 @@
 #define DBUS_TIMEOUT 15
 
 #define DUN_GW_UUID1103--1000-8000-00805f9b34fb
+#define NAP_UUID   1116--1000-8000-00805f9b34fb
 #define HFP_AG_UUID111f--1000-8000-00805f9b34fb
 #define HFP_HS_UUID111e--1000-8000-00805f9b34fb
 #define SAP_UUID   112d--1000-8000-00805f9b34fb
-- 
1.7.10.130.g36e6c

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v0 3/3] dundee: Ignore DUN device if PAN is present

2012-06-04 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 dundee/bluetooth.c |9 +
 1 file changed, 9 insertions(+)

diff --git a/dundee/bluetooth.c b/dundee/bluetooth.c
index 5a913cc..8762f51 100644
--- a/dundee/bluetooth.c
+++ b/dundee/bluetooth.c
@@ -141,6 +141,15 @@ static int bt_probe(GSList *uuids, const char *path, const 
char *dev_addr,
 
DBG();
 
+   for (; uuids; uuids = uuids-next) {
+   const char *uuid = uuids-data;
+
+   if (g_strcmp0(uuid, NAP_UUID) == 0) {
+   ofono_info(Device %s supports DUN and PAN at the same 
time. DUN is ignored, path);
+   return -EUNATCH;
+   }
+   }
+
/* We already have this device in our hash, ignore */
if (g_hash_table_lookup(bluetooth_hash, path) != NULL)
return -EALREADY;
-- 
1.7.10.130.g36e6c

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v7 01/16] bluetooth: Add Serial interface definition

2012-05-22 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 plugins/bluetooth.h |1 +
 1 file changed, 1 insertion(+)

diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index daa1873..4fc16ad 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -27,6 +27,7 @@
 #defineBLUEZ_ADAPTER_INTERFACE BLUEZ_SERVICE .Adapter
 #defineBLUEZ_DEVICE_INTERFACE  BLUEZ_SERVICE .Device
 #defineBLUEZ_SERVICE_INTERFACE BLUEZ_SERVICE .Service
+#define BLUEZ_SERIAL_INTERFACE BLUEZ_SERVICE .Serial
 
 #define DBUS_TIMEOUT 15
 
-- 
1.7.10.130.g36e6c

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v7 03/16] dundee: Add test scripts

2012-05-22 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 test/dundee-connect|   20 +
 test/dundee-disconnect |   20 +
 test/monitor-dundee|  109 
 3 files changed, 149 insertions(+)
 create mode 100755 test/dundee-connect
 create mode 100755 test/dundee-disconnect
 create mode 100755 test/monitor-dundee

diff --git a/test/dundee-connect b/test/dundee-connect
new file mode 100755
index 000..0e1ae40
--- /dev/null
+++ b/test/dundee-connect
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+
+import dbus
+import sys
+
+bus = dbus.SystemBus()
+
+if len(sys.argv) == 2:
+   path = sys.argv[1]
+else:
+   manager = dbus.Interface(bus.get_object('org.ofono.dundee', '/'),
+   'org.ofono.dundee.Manager')
+   devices = manager.GetDevices()
+   path = devices[0][0]
+
+print Connect device %s... % path
+device = dbus.Interface(bus.get_object('org.ofono.dundee', path),
+   'org.ofono.dundee.Device')
+
+device.SetProperty(Active, True)
diff --git a/test/dundee-disconnect b/test/dundee-disconnect
new file mode 100755
index 000..5b3113e
--- /dev/null
+++ b/test/dundee-disconnect
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+
+import dbus
+import sys
+
+bus = dbus.SystemBus()
+
+if len(sys.argv) == 2:
+   path = sys.argv[1]
+else:
+   manager = dbus.Interface(bus.get_object('org.ofono.dundee', '/'),
+   'org.ofono.dundee.Manager')
+   devices = manager.GetDevices()
+   path = devices[0][0]
+
+print Disonnect device %s... % path
+device = dbus.Interface(bus.get_object('org.ofono.dundee', path),
+   'org.ofono.dundee.Device')
+
+device.SetProperty(Active, False)
diff --git a/test/monitor-dundee b/test/monitor-dundee
new file mode 100755
index 000..cf96ceb
--- /dev/null
+++ b/test/monitor-dundee
@@ -0,0 +1,109 @@
+#!/usr/bin/python
+
+import gobject
+
+import dbus
+import dbus.mainloop.glib
+
+_dbus2py = {
+   dbus.String : unicode,
+   dbus.UInt32 : int,
+   dbus.Int32 : int,
+   dbus.Int16 : int,
+   dbus.UInt16 : int,
+   dbus.UInt64 : int,
+   dbus.Int64 : int,
+   dbus.Byte : int,
+   dbus.Boolean : bool,
+   dbus.ByteArray : str,
+   dbus.ObjectPath : str
+}
+
+def dbus2py(d):
+   t = type(d)
+   if t in _dbus2py:
+   return _dbus2py[t](d)
+   if t is dbus.Dictionary:
+   return dict([(dbus2py(k), dbus2py(v)) for k, v in d.items()])
+   if t is dbus.Array and d.signature == y:
+   return .join([chr(b) for b in d])
+   if t is dbus.Array or t is list:
+   return [dbus2py(v) for v in d]
+   if t is dbus.Struct or t is tuple:
+   return tuple([dbus2py(v) for v in d])
+   return d
+
+def pretty(d):
+   d = dbus2py(d)
+   t = type(d)
+
+   if t in (dict, tuple, list) and len(d)  0:
+   if t is dict:
+   d = , .join([%s = %s % (k, pretty(v))
+   for k, v in d.items()])
+   return { %s } % d
+
+   d =  .join([pretty(e) for e in d])
+
+   if t is tuple:
+   return ( %s ) % d
+
+   return str(d)
+
+def property_changed(name, value, path, interface):
+   iface = interface[interface.rfind(.) + 1:]
+   print {%s} [%s] %s = %s % (iface, path, name, pretty(value))
+
+def added(name, value, member, path, interface):
+   iface = interface[interface.rfind(.) + 1:]
+   print {%s} [%s] %s %s % (iface, member, name, pretty(value))
+
+def removed(name, member, path, interface):
+   iface = interface[interface.rfind(.) + 1:]
+   print {%s} [%s] %s % (iface, member, name)
+
+def event(member, path, interface):
+   iface = interface[interface.rfind(.) + 1:]
+   print {%s} [%s] %s % (iface, path, member)
+
+def message(msg, args, member, path, interface):
+   iface = interface[interface.rfind(.) + 1:]
+   print {%s} [%s] %s %s (%s) % (iface, path, member,
+   str(msg), pretty(args))
+
+def ussd(msg, member, path, interface):
+   iface = interface[interface.rfind(.) + 1:]
+   print {%s} [%s] %s %s % (iface, path, member, str(msg))
+
+def value(value, member, path, interface):
+   iface = interface[interface.rfind(.) + 1:]
+   print {%s} [%s] %s %s % (iface, path, member, str(value))
+
+if __name__ == '__main__':
+   dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+
+   bus = dbus.SystemBus()
+
+   bus.add_signal_receiver(property_changed,
+   bus_name=org.ofono.dundee,
+   signal_name = PropertyChanged,
+   path_keyword=path,
+   interface_keyword=interface)
+
+   bus.add_signal_receiver

[PATCH v7 06/16] dundee: Add D-Bus configuration file

2012-05-22 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 Makefile.am|6 ++
 dundee/dundee.conf |   23 +++
 2 files changed, 29 insertions(+)
 create mode 100644 dundee/dundee.conf

diff --git a/Makefile.am b/Makefile.am
index 068e4e8..ee83faa 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -693,6 +693,12 @@ dundee_dundee_SOURCES = $(gdbus_sources) \
 
 dundee_dundee_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ 
-ldl
 
+if DATAFILES
+
+dist_dbusconf_DATA += dundee/dundee.conf
+
+endif
+
 endif
 
 noinst_PROGRAMS += gatchat/gsmdial gatchat/test-server gatchat/test-qcdm
diff --git a/dundee/dundee.conf b/dundee/dundee.conf
new file mode 100644
index 000..de79dd5
--- /dev/null
+++ b/dundee/dundee.conf
@@ -0,0 +1,23 @@
+!-- This configuration file specifies the required security policies
+ for oFono dundee (DUN) daemon to work. --
+
+!DOCTYPE busconfig PUBLIC -//freedesktop//DTD D-BUS Bus Configuration 
1.0//EN
+ http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd;
+busconfig
+
+  !-- ../system.conf have denied everything, so we just punch some holes --
+
+  policy user=root
+allow own=org.ofono.dundee/
+allow send_destination=org.ofono.dundee/
+  /policy
+
+  policy at_console=true
+allow send_destination=org.ofono.dundee/
+  /policy
+
+  policy context=default
+deny send_destination=org.ofono.dundee/
+  /policy
+
+/busconfig
-- 
1.7.10.130.g36e6c

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v7 05/16] dundee: Add D-Bus error messages

2012-05-22 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 Makefile.am |2 +-
 dundee/dbus.c   |   45 +
 dundee/dundee.h |3 +++
 3 files changed, 49 insertions(+), 1 deletion(-)
 create mode 100644 dundee/dbus.c

diff --git a/Makefile.am b/Makefile.am
index 9925435..068e4e8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -689,7 +689,7 @@ sbin_PROGRAMS += dundee/dundee
 
 dundee_dundee_SOURCES = $(gdbus_sources) \
src/log.c src/dbus.c \
-   dundee/dundee.h dundee/main.c
+   dundee/dundee.h dundee/main.c dundee/dbus.c
 
 dundee_dundee_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ 
-ldl
 
diff --git a/dundee/dbus.c b/dundee/dbus.c
new file mode 100644
index 000..c245eab
--- /dev/null
+++ b/dundee/dbus.c
@@ -0,0 +1,45 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2012  BMW Car IT GmbH. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include config.h
+#endif
+
+#include glib.h
+#include gdbus.h
+
+#include dundee.h
+
+#define DUNDEE_ERROR_INTERFACE org.ofono.dundee.Error
+
+DBusMessage *__dundee_error_invalid_args(DBusMessage *msg)
+{
+   return g_dbus_create_error(msg, DUNDEE_ERROR_INTERFACE
+   .InvalidArguments,
+   Invalid arguments in method call);
+}
+
+DBusMessage *__dundee_error_failed(DBusMessage *msg)
+{
+   return g_dbus_create_error(msg, DUNDEE_ERROR_INTERFACE
+   .Failed,
+   Operation failed);
+}
diff --git a/dundee/dundee.h b/dundee/dundee.h
index c4c9800..c972af0 100644
--- a/dundee/dundee.h
+++ b/dundee/dundee.h
@@ -44,3 +44,6 @@ int __ofono_dbus_init(DBusConnection *conn);
 void __ofono_dbus_cleanup(void);
 
 void __ofono_dbus_pending_reply(DBusMessage **msg, DBusMessage *reply);
+
+DBusMessage *__dundee_error_invalid_args(DBusMessage *msg);
+DBusMessage *__dundee_error_failed(DBusMessage *msg);
-- 
1.7.10.130.g36e6c

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v7 07/16] dundee: Add systemd configuration file

2012-05-22 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 Makefile.am  |6 ++
 configure.ac |3 ++-
 dundee/dundee.service.in |   11 +++
 3 files changed, 19 insertions(+), 1 deletion(-)
 create mode 100644 dundee/dundee.service.in

diff --git a/Makefile.am b/Makefile.am
index ee83faa..31e0110 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -697,6 +697,12 @@ if DATAFILES
 
 dist_dbusconf_DATA += dundee/dundee.conf
 
+if SYSTEMD
+
+systemdunit_DATA += dundee/dundee.service
+
+endif
+
 endif
 
 endif
diff --git a/configure.ac b/configure.ac
index 0377298..d2092b9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -242,4 +242,5 @@ fi
 AC_DEFINE_UNQUOTED(CONFIGDIR, ${configdir},
[Directory for the configuration files])
 
-AC_OUTPUT(Makefile include/version.h src/ofono.service ofono.pc)
+AC_OUTPUT(Makefile include/version.h src/ofono.service ofono.pc \
+  dundee/dundee.service)
diff --git a/dundee/dundee.service.in b/dundee/dundee.service.in
new file mode 100644
index 000..c57c618
--- /dev/null
+++ b/dundee/dundee.service.in
@@ -0,0 +1,11 @@
+[Unit]
+Description=DUN service
+After=syslog.target
+
+[Service]
+Type=dbus
+BusName=org.ofono.dundee
+ExecStart=@prefix@/sbin/dundee -n
+
+[Install]
+WantedBy=multi-user.target
-- 
1.7.10.130.g36e6c

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v7 08/16] dundee: Add Manager interface

2012-05-22 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 Makefile.am  |3 +-
 dundee/dundee.h  |6 
 dundee/main.c|9 ++---
 dundee/manager.c |  100 ++
 4 files changed, 111 insertions(+), 7 deletions(-)
 create mode 100644 dundee/manager.c

diff --git a/Makefile.am b/Makefile.am
index 31e0110..00e1118 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -689,7 +689,8 @@ sbin_PROGRAMS += dundee/dundee
 
 dundee_dundee_SOURCES = $(gdbus_sources) \
src/log.c src/dbus.c \
-   dundee/dundee.h dundee/main.c dundee/dbus.c
+   dundee/dundee.h dundee/main.c dundee/dbus.c \
+   dundee/manager.c
 
 dundee_dundee_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ 
-ldl
 
diff --git a/dundee/dundee.h b/dundee/dundee.h
index c972af0..3050baf 100644
--- a/dundee/dundee.h
+++ b/dundee/dundee.h
@@ -39,6 +39,8 @@ void __ofono_log_enable(struct ofono_debug_desc *start,
 #include ofono/dbus.h
 
 #define DUNDEE_SERVICE org.ofono.dundee
+#define DUNDEE_MANAGER_INTERFACE   org.ofono.dundee.Manager
+#define DUNDEE_MANAGER_PATH/
 
 int __ofono_dbus_init(DBusConnection *conn);
 void __ofono_dbus_cleanup(void);
@@ -47,3 +49,7 @@ void __ofono_dbus_pending_reply(DBusMessage **msg, 
DBusMessage *reply);
 
 DBusMessage *__dundee_error_invalid_args(DBusMessage *msg);
 DBusMessage *__dundee_error_failed(DBusMessage *msg);
+
+
+int __dundee_manager_init(void);
+void __dundee_manager_cleanup(void);
diff --git a/dundee/main.c b/dundee/main.c
index 95ee795..07b8501 100644
--- a/dundee/main.c
+++ b/dundee/main.c
@@ -232,15 +232,12 @@ int main(int argc, char **argv)
 
__ofono_dbus_init(conn);
 
-   /*
-* The reason why this DBG is here is that we have the __stop__debug,
-* __start__debug linking symbols in the object. As soon we
-* have real DBG we can remove this one again.
-*/
-   DBG();
+   __dundee_manager_init();
 
g_main_loop_run(event_loop);
 
+   __dundee_manager_cleanup();
+
__ofono_dbus_cleanup();
dbus_connection_unref(conn);
 
diff --git a/dundee/manager.c b/dundee/manager.c
new file mode 100644
index 000..61fa25e
--- /dev/null
+++ b/dundee/manager.c
@@ -0,0 +1,100 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2012  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2012  BMW Car IT GmbH. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include config.h
+#endif
+
+#include string.h
+#include glib.h
+#include gdbus.h
+
+#include dundee.h
+
+static DBusMessage *manager_get_devices(DBusConnection *conn,
+   DBusMessage *msg, void *data)
+{
+   DBusMessage *reply;
+   DBusMessageIter iter;
+   DBusMessageIter array;
+
+   DBG();
+
+   reply = dbus_message_new_method_return(msg);
+   if (reply == NULL)
+   return NULL;
+
+   dbus_message_iter_init_append(reply, iter);
+
+   dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
+   DBUS_STRUCT_BEGIN_CHAR_AS_STRING
+   DBUS_TYPE_OBJECT_PATH_AS_STRING
+   DBUS_TYPE_ARRAY_AS_STRING
+   DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+   DBUS_TYPE_STRING_AS_STRING
+   DBUS_TYPE_VARIANT_AS_STRING
+   DBUS_DICT_ENTRY_END_CHAR_AS_STRING
+   DBUS_STRUCT_END_CHAR_AS_STRING,
+   array);
+
+   dbus_message_iter_close_container(iter, array);
+
+   return reply;
+}
+
+static const GDBusMethodTable manager_methods[] = {
+   { GDBUS_METHOD(GetDevices, NULL,
+   GDBUS_ARGS({ devices, a(oa{sv}) }), manager_get_devices) },
+   { }
+};
+
+static const GDBusSignalTable manager_signals[] = {
+   { GDBUS_SIGNAL(DevicesAdded,
+   GDBUS_ARGS({ path, o},{ properties, a{sv} })) },
+   { GDBUS_SIGNAL(DeviceRemoved,
+   GDBUS_ARGS({ path, o})) },
+   { }
+};
+
+int __dundee_manager_init(void

[PATCH v7 09/16] dundee: Add skeleton implementation for device

2012-05-22 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 Makefile.am |2 +-
 dundee/device.c |  100 +++
 dundee/dundee.h |   15 +
 dundee/main.c   |4 ++-
 4 files changed, 119 insertions(+), 2 deletions(-)
 create mode 100644 dundee/device.c

diff --git a/Makefile.am b/Makefile.am
index 00e1118..1e0934d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -690,7 +690,7 @@ sbin_PROGRAMS += dundee/dundee
 dundee_dundee_SOURCES = $(gdbus_sources) \
src/log.c src/dbus.c \
dundee/dundee.h dundee/main.c dundee/dbus.c \
-   dundee/manager.c
+   dundee/manager.c dundee/device.c
 
 dundee_dundee_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ 
-ldl
 
diff --git a/dundee/device.c b/dundee/device.c
new file mode 100644
index 000..d9fc928
--- /dev/null
+++ b/dundee/device.c
@@ -0,0 +1,100 @@
+/*
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2012  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2012  BMW Car IT GmbH. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include config.h
+#endif
+
+#include errno.h
+#include string.h
+#include stdio.h
+#include netinet/ether.h
+
+#include glib.h
+#include gdbus.h
+
+#include dundee.h
+
+static GHashTable *device_hash;
+
+struct dundee_device {
+};
+
+const char *__dundee_device_get_path(struct dundee_device *device)
+{
+   return /;
+}
+
+void __dundee_device_append_properties(struct dundee_device *device,
+   DBusMessageIter *dict)
+{
+}
+
+void __dundee_device_foreach(dundee_device_foreach_func func, void *userdata)
+{
+   GHashTableIter iter;
+   gpointer key, value;
+
+   DBG();
+
+   g_hash_table_iter_init(iter, device_hash);
+
+   while (g_hash_table_iter_next(iter, key, value) == TRUE) {
+   struct dundee_device *device = value;
+
+   func(device, userdata);
+   }
+}
+
+static void destroy_device(gpointer user)
+{
+   struct dundee_device *device = user;
+
+   g_free(device);
+}
+
+static void device_shutdown(gpointer key, gpointer value, gpointer user_data)
+{
+}
+
+void __dundee_device_shutdown(void)
+{
+   g_hash_table_foreach(device_hash, device_shutdown, NULL);
+
+   __dundee_exit();
+}
+
+int __dundee_device_init(void)
+{
+   DBG();
+
+   device_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
+   g_free, destroy_device);
+
+   return 0;
+}
+
+void __dundee_device_cleanup(void)
+{
+   DBG();
+
+   g_hash_table_destroy(device_hash);
+}
diff --git a/dundee/dundee.h b/dundee/dundee.h
index 3050baf..4f8aa10 100644
--- a/dundee/dundee.h
+++ b/dundee/dundee.h
@@ -53,3 +53,18 @@ DBusMessage *__dundee_error_failed(DBusMessage *msg);
 
 int __dundee_manager_init(void);
 void __dundee_manager_cleanup(void);
+
+
+struct dundee_device;
+
+int __dundee_device_init(void);
+void __dundee_device_cleanup(void);
+void __dundee_device_shutdown(void);
+
+typedef void (*dundee_device_foreach_func)(struct dundee_device *device,
+   void *data);
+void __dundee_device_foreach(dundee_device_foreach_func cb, void *userdata);
+
+const char *__dundee_device_get_path(struct dundee_device *device);
+void __dundee_device_append_properties(struct dundee_device *device,
+   DBusMessageIter *dict);
diff --git a/dundee/main.c b/dundee/main.c
index 07b8501..2d3d75e 100644
--- a/dundee/main.c
+++ b/dundee/main.c
@@ -80,7 +80,7 @@ static gboolean signal_handler(GIOChannel *channel, 
GIOCondition cond,
g_timeout_add_seconds(SHUTDOWN_GRACE_SECONDS,
quit_eventloop, NULL);
 
-   quit_eventloop(NULL);
+   __dundee_device_shutdown();
}
 
__terminated = 1;
@@ -233,9 +233,11 @@ int main(int argc, char **argv)
__ofono_dbus_init(conn);
 
__dundee_manager_init();
+   __dundee_device_init();
 
g_main_loop_run(event_loop);
 
+   __dundee_device_cleanup();
__dundee_manager_cleanup();
 
__ofono_dbus_cleanup

[PATCH v7 10/16] dundee: Manager append devices

2012-05-22 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 dundee/manager.c |   22 ++
 1 file changed, 22 insertions(+)

diff --git a/dundee/manager.c b/dundee/manager.c
index 61fa25e..d7374d6 100644
--- a/dundee/manager.c
+++ b/dundee/manager.c
@@ -30,6 +30,26 @@
 
 #include dundee.h
 
+static void append_device(struct dundee_device *device, void *userdata)
+{
+   DBusMessageIter *array = userdata;
+   const char *path = __dundee_device_get_path(device);
+   DBusMessageIter entry, dict;
+
+   dbus_message_iter_open_container(array, DBUS_TYPE_STRUCT,
+   NULL, entry);
+   dbus_message_iter_append_basic(entry, DBUS_TYPE_OBJECT_PATH,
+   path);
+   dbus_message_iter_open_container(entry, DBUS_TYPE_ARRAY,
+   OFONO_PROPERTIES_ARRAY_SIGNATURE,
+   dict);
+
+   __dundee_device_append_properties(device, dict);
+
+   dbus_message_iter_close_container(entry, dict);
+   dbus_message_iter_close_container(array, entry);
+}
+
 static DBusMessage *manager_get_devices(DBusConnection *conn,
DBusMessage *msg, void *data)
 {
@@ -56,6 +76,8 @@ static DBusMessage *manager_get_devices(DBusConnection *conn,
DBUS_STRUCT_END_CHAR_AS_STRING,
array);
 
+   __dundee_device_foreach(append_device, array);
+
dbus_message_iter_close_container(iter, array);
 
return reply;
-- 
1.7.10.130.g36e6c

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v7 13/16] dundee: Add driver helper functions

2012-05-22 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 dundee/device.c |   18 ++
 dundee/dundee.h |5 +
 2 files changed, 23 insertions(+)

diff --git a/dundee/device.c b/dundee/device.c
index 9ed1687..1a83f76 100644
--- a/dundee/device.c
+++ b/dundee/device.c
@@ -41,6 +41,7 @@ struct dundee_device {
struct dundee_device_driver *driver;
gboolean registered;
 
+   void *data;
 };
 
 const char *__dundee_device_get_path(struct dundee_device *device)
@@ -135,6 +136,23 @@ void dundee_device_unregister(struct dundee_device *device)
g_hash_table_remove(device_hash, device-path);
 }
 
+void dundee_device_set_data(struct dundee_device *device, void *data)
+{
+   device-data = data;
+}
+
+void *dundee_device_get_data(struct dundee_device *device)
+{
+   return device-data;
+}
+
+int dundee_device_set_name(struct dundee_device *device, const char *name)
+{
+   DBG(%p name %s, device, name);
+
+   return 0;
+}
+
 static void device_shutdown(gpointer key, gpointer value, gpointer user_data)
 {
struct dundee_device *device = value;
diff --git a/dundee/dundee.h b/dundee/dundee.h
index ae14e01..cf0c36a 100644
--- a/dundee/dundee.h
+++ b/dundee/dundee.h
@@ -126,6 +126,11 @@ struct dundee_device *dundee_device_create(struct 
dundee_device_driver *d);
 int dundee_device_register(struct dundee_device *device);
 void dundee_device_unregister(struct dundee_device *device);
 
+void dundee_device_set_data(struct dundee_device *device, void *data);
+void *dundee_device_get_data(struct dundee_device *device);
+
+int dundee_device_set_name(struct dundee_device *device, const char *name);
+
 typedef void (*dundee_device_foreach_func)(struct dundee_device *device,
void *data);
 void __dundee_device_foreach(dundee_device_foreach_func cb, void *userdata);
-- 
1.7.10.130.g36e6c

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v7 16/16] dundee: Add Bluetooth DUN driver

2012-05-22 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 Makefile.am|6 +-
 dundee/bluetooth.c |  290 
 dundee/dundee.h|3 +
 dundee/main.c  |2 +
 4 files changed, 298 insertions(+), 3 deletions(-)
 create mode 100644 dundee/bluetooth.c

diff --git a/Makefile.am b/Makefile.am
index 19261ce..19844d9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -687,10 +687,10 @@ if DUNDEE
 
 sbin_PROGRAMS += dundee/dundee
 
-dundee_dundee_SOURCES = $(gdbus_sources) $(gatchat_sources) \
-   src/log.c src/dbus.c \
+dundee_dundee_SOURCES = $(gdbus_sources) $(gatchat_sources) $(btio_sources) \
+   src/log.c src/dbus.c plugins/bluetooth.c \
dundee/dundee.h dundee/main.c dundee/dbus.c \
-   dundee/manager.c dundee/device.c
+   dundee/manager.c dundee/device.c dundee/bluetooth.c
 
 dundee_dundee_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ 
-ldl
 
diff --git a/dundee/bluetooth.c b/dundee/bluetooth.c
new file mode 100644
index 000..e2e2bca
--- /dev/null
+++ b/dundee/bluetooth.c
@@ -0,0 +1,290 @@
+/*
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2012  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2012  BMW Car IT GmbH. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include config.h
+#endif
+
+#include sys/types.h
+#include sys/stat.h
+#include fcntl.h
+#include string.h
+#include errno.h
+
+#include glib.h
+
+#include plugins/bluetooth.h
+
+#include dundee.h
+
+static GHashTable *bluetooth_hash;
+
+struct bluetooth_device {
+   struct dundee_device *device;
+
+   char *path;
+   char *address;
+   char *name;
+
+   DBusPendingCall *call;
+};
+
+static void bt_disconnect(struct dundee_device *device,
+   dundee_device_disconnect_cb_t cb, void *data)
+{
+   struct bluetooth_device *bt = dundee_device_get_data(device);
+
+   DBG(%p, bt);
+
+   CALLBACK_WITH_SUCCESS(cb, data);
+}
+
+static void bt_connect_reply(DBusPendingCall *call, gpointer user_data)
+{
+   struct cb_data *cbd = user_data;
+   dundee_device_connect_cb_t cb = cbd-cb;
+   struct bluetooth_device *bt = cbd-user;
+   DBusMessage *reply;
+   DBusError derr;
+   int fd;
+
+   DBG(%p, bt);
+
+   reply = dbus_pending_call_steal_reply(call);
+
+   bt-call = NULL;
+
+   dbus_error_init(derr);
+   if (dbus_set_error_from_message(derr, reply)) {
+   DBG(Connection to bt serial returned with error: %s, %s,
+   derr.name, derr.message);
+
+   dbus_error_free(derr);
+
+   CALLBACK_WITH_FAILURE(cb, -1, cbd-data);
+   goto done;
+   }
+
+   dbus_message_get_args(reply, NULL, DBUS_TYPE_UNIX_FD, fd,
+   DBUS_TYPE_INVALID);
+
+   DBG(%p fd %d, bt, fd);
+
+   if (fd  0) {
+   CALLBACK_WITH_FAILURE(cb, -1, cbd-data);
+   goto done;
+   }
+
+   CALLBACK_WITH_SUCCESS(cb, fd, cbd-data);
+
+done:
+   dbus_message_unref(reply);
+   g_free(cbd);
+}
+
+static void bt_connect(struct dundee_device *device,
+   dundee_device_connect_cb_t cb, void *data)
+{
+   struct bluetooth_device *bt = dundee_device_get_data(device);
+   struct cb_data *cbd = cb_data_new(cb, data);
+   char *profile = dun;
+   int status;
+
+   DBG(%p, bt);
+
+   cbd-user = bt;
+
+   status = bluetooth_send_with_reply(bt-path,
+   BLUEZ_SERIAL_INTERFACE, ConnectFD,
+   bt-call, bt_connect_reply,
+   cbd, NULL, DBUS_TIMEOUT,
+   DBUS_TYPE_STRING, profile,
+   DBUS_TYPE_INVALID);
+   if (status == 0)
+   return;
+
+   g_free(cbd);
+
+   CALLBACK_WITH_FAILURE(cb, -1, cbd-data);
+}
+
+struct dundee_device_driver bluetooth_driver = {
+   .name = bluetooth,
+   .connect = bt_connect,
+   .disconnect = bt_disconnect,
+};
+
+static int bt_probe(const char *path, const char *dev_addr

Re: [PATCH v7 00/16] Add DUN support

2012-05-22 Thread Daniel Wagner
On 05/22/2012 06:33 PM, Daniel Wagner wrote:
 From: Daniel Wagner daniel.wag...@bmw-carit.de
 
 Hi,
 
 Changes v7:
  - Fixed test scripts
  - SetProperty(Active, True) will be deferred until PPP link is up 
or an error happens
  - GDBUS changes added
  - Fixed a crash in set_property_active: device-ppp can be NULL
  - Copyright year update and whitespace fixes

All patches applied.

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH v6 03/16] dundee: Add test scripts

2012-04-24 Thread Daniel Wagner

Hi Wu,

On 23.04.2012 12:13, Zheng, Wu wrote:

Hi Daniel,

I try to test your patches.


Thanks for giving them a try.


-Original Message-
From: ofono-boun...@ofono.org [mailto:ofono-boun...@ofono.org] On Behalf
Of Daniel Wagner
Sent: Tuesday, April 03, 2012 12:20 AM
To: ofono@ofono.org
Cc: Daniel Wagner
Subject: [PATCH v6 03/16] dundee: Add test scripts

From: Daniel Wagnerdaniel.wag...@bmw-carit.de

---
  test/dundee-connect|   20 +
  test/dundee-disconnect |   20 +
  test/monitor-dundee|  109

  3 files changed, 149 insertions(+)
  create mode 100755 test/dundee-connect
  create mode 100755 test/dundee-disconnect  create mode 100755
test/monitor-dundee

diff --git a/test/dundee-connect b/test/dundee-connect new file mode 100755
index 000..6cbc629
--- /dev/null
+++ b/test/dundee-connect
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+
+import dbus
+import sys
+
+bus = dbus.SystemBus()
+
+if len(sys.argv) == 2:
+   path = sys.argv[1]
+else:
+   manager = dbus.Interface(bus.get_object('org.ofono.dundee', '/'),
+   'org.ofono.dundee.Manager')
+   devices = manager.GetDevices()
+   path = devices[0][0]
+
+print Connect device %s... % path
+device = dbus.Interface(bus.get_object('org.ofono.dundee', path),
+   'org.ofono.dundee.Device')
+
+device.Connect()


The dbus method connect() does not exist on org.ofono.dundee.Device, it cannot 
be found in device.c and doc/dundee-api.txt.
Why?

Best regards


diff --git a/test/dundee-disconnect b/test/dundee-disconnect new file mode
100755 index 000..e67d8cd
--- /dev/null
+++ b/test/dundee-disconnect
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+
+import dbus
+import sys
+
+bus = dbus.SystemBus()
+
+if len(sys.argv) == 2:
+   path = sys.argv[1]
+else:
+   manager = dbus.Interface(bus.get_object('org.ofono.dundee', '/'),
+   'org.ofono.dundee.Manager')
+   devices = manager.GetDevices()
+   path = devices[0][0]
+
+print Disonnect device %s... % path
+device = dbus.Interface(bus.get_object('org.ofono.dundee', path),
+   'org.ofono.dundee.Device')
+
+device.Disconnect()


Change this line to

device.SetProperty(Active, True)

That should do the trick.


The dbus method Disconnect() does not exist on org.ofono.dundee.Device, it 
cannot be found in device.c and doc/dundee-api.txt.
Why?


The documentation and the script are not in sync with the 
implementation. I'll fix that.


Documentation change:

Methods
SetProperty()

Test script change:

device.SetProperty(Active, True)

cheers,
daniel
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v6 02/16] dundee: Add documentation

2012-04-02 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 doc/dundee-api.txt |   76 
 1 file changed, 76 insertions(+)
 create mode 100644 doc/dundee-api.txt

diff --git a/doc/dundee-api.txt b/doc/dundee-api.txt
new file mode 100644
index 000..9f4cfe6
--- /dev/null
+++ b/doc/dundee-api.txt
@@ -0,0 +1,76 @@
+
+Manager hierarchy
+=
+
+Serviceorg.ofono.dundee
+Interface  org.ofono.dundee.Manager
+Object path/
+
+Methodsarray{object,dict} GetDevices()
+
+   Get an array of device objects and properties
+   that represent the currently attached devices.
+
+   This method call should only be used once when an
+   application starts up. Further device additions
+   and removal shall be monitored via DeviceAdded and
+   DeviceRemoved signals.
+
+SignalsDeviceAdded(object path, dict properties)
+
+   Signal that is sent when a new device is added.  It
+   contains the object path of new device and its
+   properties.
+
+   DeviceRemoved(object path)
+
+   Signal that is sent when a device has been removed.
+   The object path is no longer accessible after this
+   signal and only emitted for reference.
+
+
+Device hierarchy
+
+
+Serviceorg.ofono.dundee
+Interface  org.ofono.dundee.Device
+Object path/{device0,device1,...}
+
+Methodsdict GetProperties()
+
+   Returns properties for the device object. See
+   the properties section for available properties.
+
+SignalsPropertyChanged(string name, variant value)
+
+   This signal indicates a changed value of the given
+   property.
+
+Properties string Name [readonly]
+
+   Friendly name of the device.
+
+   boolean Active [readwrite]
+
+   Holds whether the device is connected. A
+   connection will be established when this value
+   is set to true. A existing connection will be
+   teared down when set to false.
+
+   dict Settings [readonly]
+
+   Holds all the IP network settings.
+
+   string Interface [readonly, optional]
+
+   Holds the interface of the network interface
+   used by this connection (e.g. ppp0 usb0)
+
+   string Address [readonly, optional]
+
+   Holds the IP address for this connection.
+
+   array{string} DomainNameServers [readonly, optional]
+
+   Holds the list of domain name servers for this
+   connection.
-- 
1.7.10.rc3.1.gb3065

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v6 04/16] dundee: Add skeleton implementation

2012-04-02 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 Makefile.am |   12 +++
 bootstrap-configure |1 +
 configure.ac|4 +
 dundee/dundee.h |   46 ++
 dundee/main.c   |  255 +++
 5 files changed, 318 insertions(+)
 create mode 100644 dundee/dundee.h
 create mode 100644 dundee/main.c

diff --git a/Makefile.am b/Makefile.am
index af3c5a2..36ad8e0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -667,6 +667,18 @@ tools_lookup_provider_name_SOURCES = plugins/mbpi.c 
plugins/mbpi.h \
 tools_lookup_provider_name_LDADD = @GLIB_LIBS@
 endif
 
+if DUNDEE
+
+sbin_PROGRAMS += dundee/dundee
+
+dundee_dundee_SOURCES = $(gdbus_sources) \
+   src/log.c src/dbus.c \
+   dundee/dundee.h dundee/main.c
+
+dundee_dundee_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ 
-ldl
+
+endif
+
 noinst_PROGRAMS += gatchat/gsmdial gatchat/test-server gatchat/test-qcdm
 
 gatchat_gsmdial_SOURCES = gatchat/gsmdial.c $(gatchat_sources)
diff --git a/bootstrap-configure b/bootstrap-configure
index db70c66..1fae158 100755
--- a/bootstrap-configure
+++ b/bootstrap-configure
@@ -14,4 +14,5 @@ fi
--localstatedir=/var \
--enable-capng \
--enable-tools \
+   --enable-dundee \
--disable-datafiles $*
diff --git a/configure.ac b/configure.ac
index 5ed78ea..1e21cc4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -165,6 +165,10 @@ if (test ${enable_tools} = yes); then
 fi
 AM_CONDITIONAL(TOOLS, test ${enable_tools} = yes)
 
+AC_ARG_ENABLE(dundee, AC_HELP_STRING([--enable-dundee],
+   [enable DUN deamon support]), [enable_dundee=${enableval}])
+AM_CONDITIONAL(DUNDEE, test ${enable_dundee} = yes)
+
 AC_ARG_ENABLE(atmodem, AC_HELP_STRING([--disable-atmodem],
[disable ETSI AT modem support]),
[enable_atmodem=${enableval}])
diff --git a/dundee/dundee.h b/dundee/dundee.h
new file mode 100644
index 000..83d8969
--- /dev/null
+++ b/dundee/dundee.h
@@ -0,0 +1,46 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2011  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2012  BMW Car IT GmbH. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#include glib.h
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+
+#include ofono/types.h
+
+void __dundee_exit(void);
+
+#include ofono/log.h
+
+int __ofono_log_init(const char *program, const char *debug,
+   ofono_bool_t detach);
+void __ofono_log_cleanup(void);
+void __ofono_log_enable(struct ofono_debug_desc *start,
+   struct ofono_debug_desc *stop);
+
+#include ofono/dbus.h
+
+#define DUNDEE_SERVICE org.ofono.dundee
+
+int __ofono_dbus_init(DBusConnection *conn);
+void __ofono_dbus_cleanup(void);
+
+void __ofono_dbus_pending_reply(DBusMessage **msg, DBusMessage *reply);
diff --git a/dundee/main.c b/dundee/main.c
new file mode 100644
index 000..0bee690
--- /dev/null
+++ b/dundee/main.c
@@ -0,0 +1,255 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2011  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2012  BMW Car IT GmbH. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include config.h
+#endif
+
+#include stdio.h
+#include stdlib.h
+#include unistd.h
+#include string.h
+#include signal.h
+#include sys/signalfd.h
+
+#include gdbus.h
+
+#ifdef HAVE_CAPNG
+#include cap-ng.h
+#endif
+
+#include dundee.h
+
+#define SHUTDOWN_GRACE_SECONDS 10
+
+static GMainLoop

[PATCH v6 03/16] dundee: Add test scripts

2012-04-02 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 test/dundee-connect|   20 +
 test/dundee-disconnect |   20 +
 test/monitor-dundee|  109 
 3 files changed, 149 insertions(+)
 create mode 100755 test/dundee-connect
 create mode 100755 test/dundee-disconnect
 create mode 100755 test/monitor-dundee

diff --git a/test/dundee-connect b/test/dundee-connect
new file mode 100755
index 000..6cbc629
--- /dev/null
+++ b/test/dundee-connect
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+
+import dbus
+import sys
+
+bus = dbus.SystemBus()
+
+if len(sys.argv) == 2:
+   path = sys.argv[1]
+else:
+   manager = dbus.Interface(bus.get_object('org.ofono.dundee', '/'),
+   'org.ofono.dundee.Manager')
+   devices = manager.GetDevices()
+   path = devices[0][0]
+
+print Connect device %s... % path
+device = dbus.Interface(bus.get_object('org.ofono.dundee', path),
+   'org.ofono.dundee.Device')
+
+device.Connect()
diff --git a/test/dundee-disconnect b/test/dundee-disconnect
new file mode 100755
index 000..e67d8cd
--- /dev/null
+++ b/test/dundee-disconnect
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+
+import dbus
+import sys
+
+bus = dbus.SystemBus()
+
+if len(sys.argv) == 2:
+   path = sys.argv[1]
+else:
+   manager = dbus.Interface(bus.get_object('org.ofono.dundee', '/'),
+   'org.ofono.dundee.Manager')
+   devices = manager.GetDevices()
+   path = devices[0][0]
+
+print Disonnect device %s... % path
+device = dbus.Interface(bus.get_object('org.ofono.dundee', path),
+   'org.ofono.dundee.Device')
+
+device.Disconnect()
diff --git a/test/monitor-dundee b/test/monitor-dundee
new file mode 100755
index 000..cf96ceb
--- /dev/null
+++ b/test/monitor-dundee
@@ -0,0 +1,109 @@
+#!/usr/bin/python
+
+import gobject
+
+import dbus
+import dbus.mainloop.glib
+
+_dbus2py = {
+   dbus.String : unicode,
+   dbus.UInt32 : int,
+   dbus.Int32 : int,
+   dbus.Int16 : int,
+   dbus.UInt16 : int,
+   dbus.UInt64 : int,
+   dbus.Int64 : int,
+   dbus.Byte : int,
+   dbus.Boolean : bool,
+   dbus.ByteArray : str,
+   dbus.ObjectPath : str
+}
+
+def dbus2py(d):
+   t = type(d)
+   if t in _dbus2py:
+   return _dbus2py[t](d)
+   if t is dbus.Dictionary:
+   return dict([(dbus2py(k), dbus2py(v)) for k, v in d.items()])
+   if t is dbus.Array and d.signature == y:
+   return .join([chr(b) for b in d])
+   if t is dbus.Array or t is list:
+   return [dbus2py(v) for v in d]
+   if t is dbus.Struct or t is tuple:
+   return tuple([dbus2py(v) for v in d])
+   return d
+
+def pretty(d):
+   d = dbus2py(d)
+   t = type(d)
+
+   if t in (dict, tuple, list) and len(d)  0:
+   if t is dict:
+   d = , .join([%s = %s % (k, pretty(v))
+   for k, v in d.items()])
+   return { %s } % d
+
+   d =  .join([pretty(e) for e in d])
+
+   if t is tuple:
+   return ( %s ) % d
+
+   return str(d)
+
+def property_changed(name, value, path, interface):
+   iface = interface[interface.rfind(.) + 1:]
+   print {%s} [%s] %s = %s % (iface, path, name, pretty(value))
+
+def added(name, value, member, path, interface):
+   iface = interface[interface.rfind(.) + 1:]
+   print {%s} [%s] %s %s % (iface, member, name, pretty(value))
+
+def removed(name, member, path, interface):
+   iface = interface[interface.rfind(.) + 1:]
+   print {%s} [%s] %s % (iface, member, name)
+
+def event(member, path, interface):
+   iface = interface[interface.rfind(.) + 1:]
+   print {%s} [%s] %s % (iface, path, member)
+
+def message(msg, args, member, path, interface):
+   iface = interface[interface.rfind(.) + 1:]
+   print {%s} [%s] %s %s (%s) % (iface, path, member,
+   str(msg), pretty(args))
+
+def ussd(msg, member, path, interface):
+   iface = interface[interface.rfind(.) + 1:]
+   print {%s} [%s] %s %s % (iface, path, member, str(msg))
+
+def value(value, member, path, interface):
+   iface = interface[interface.rfind(.) + 1:]
+   print {%s} [%s] %s %s % (iface, path, member, str(value))
+
+if __name__ == '__main__':
+   dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+
+   bus = dbus.SystemBus()
+
+   bus.add_signal_receiver(property_changed,
+   bus_name=org.ofono.dundee,
+   signal_name = PropertyChanged,
+   path_keyword=path,
+   interface_keyword=interface)
+
+   bus.add_signal_receiver(added

[PATCH v6 06/16] dundee: Add D-Bus configuration file

2012-04-02 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 Makefile.am|6 ++
 dundee/dundee.conf |   23 +++
 2 files changed, 29 insertions(+)
 create mode 100644 dundee/dundee.conf

diff --git a/Makefile.am b/Makefile.am
index fb0de75..ad61106 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -677,6 +677,12 @@ dundee_dundee_SOURCES = $(gdbus_sources) \
 
 dundee_dundee_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ 
-ldl
 
+if DATAFILES
+
+dist_dbusconf_DATA += dundee/dundee.conf
+
+endif
+
 endif
 
 noinst_PROGRAMS += gatchat/gsmdial gatchat/test-server gatchat/test-qcdm
diff --git a/dundee/dundee.conf b/dundee/dundee.conf
new file mode 100644
index 000..de79dd5
--- /dev/null
+++ b/dundee/dundee.conf
@@ -0,0 +1,23 @@
+!-- This configuration file specifies the required security policies
+ for oFono dundee (DUN) daemon to work. --
+
+!DOCTYPE busconfig PUBLIC -//freedesktop//DTD D-BUS Bus Configuration 
1.0//EN
+ http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd;
+busconfig
+
+  !-- ../system.conf have denied everything, so we just punch some holes --
+
+  policy user=root
+allow own=org.ofono.dundee/
+allow send_destination=org.ofono.dundee/
+  /policy
+
+  policy at_console=true
+allow send_destination=org.ofono.dundee/
+  /policy
+
+  policy context=default
+deny send_destination=org.ofono.dundee/
+  /policy
+
+/busconfig
-- 
1.7.10.rc3.1.gb3065

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v6 10/16] dundee: Manager append devices

2012-04-02 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 dundee/manager.c |   22 ++
 1 file changed, 22 insertions(+)

diff --git a/dundee/manager.c b/dundee/manager.c
index 9ffe5c0..58a5804 100644
--- a/dundee/manager.c
+++ b/dundee/manager.c
@@ -30,6 +30,26 @@
 
 #include dundee.h
 
+static void append_device(struct dundee_device *device, void *userdata)
+{
+   DBusMessageIter *array = userdata;
+   const char *path = __dundee_device_get_path(device);
+   DBusMessageIter entry, dict;
+
+   dbus_message_iter_open_container(array, DBUS_TYPE_STRUCT,
+   NULL, entry);
+   dbus_message_iter_append_basic(entry, DBUS_TYPE_OBJECT_PATH,
+   path);
+   dbus_message_iter_open_container(entry, DBUS_TYPE_ARRAY,
+   OFONO_PROPERTIES_ARRAY_SIGNATURE,
+   dict);
+
+   __dundee_device_append_properties(device, dict);
+
+   dbus_message_iter_close_container(entry, dict);
+   dbus_message_iter_close_container(array, entry);
+}
+
 static DBusMessage *manager_get_devices(DBusConnection *conn,
DBusMessage *msg, void *data)
 {
@@ -56,6 +76,8 @@ static DBusMessage *manager_get_devices(DBusConnection *conn,
DBUS_STRUCT_END_CHAR_AS_STRING,
array);
 
+   __dundee_device_foreach(append_device, array);
+
dbus_message_iter_close_container(iter, array);
 
return reply;
-- 
1.7.10.rc3.1.gb3065

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v6 11/16] dundee: Add callback helpers

2012-04-02 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 dundee/dundee.h |   44 
 1 file changed, 44 insertions(+)

diff --git a/dundee/dundee.h b/dundee/dundee.h
index 4fe801b..01edd53 100644
--- a/dundee/dundee.h
+++ b/dundee/dundee.h
@@ -28,6 +28,50 @@
 
 void __dundee_exit(void);
 
+enum dundee_error_type {
+   DUNDEE_ERROR_TYPE_NO_ERROR = 0,
+   DUNDEE_ERROR_TYPE_FAILURE,
+};
+
+struct dundee_error {
+   enum dundee_error_type type;
+   int error;
+};
+
+struct cb_data {
+   void *cb;
+   void *data;
+   void *user;
+};
+
+static inline struct cb_data *cb_data_new(void *cb, void *data)
+{
+   struct cb_data *ret;
+
+   ret = g_new0(struct cb_data, 1);
+   ret-cb = cb;
+   ret-data = data;
+
+   return ret;
+}
+
+#define CALLBACK_WITH_FAILURE(cb, args...) \
+   do {\
+   struct dundee_error cb_e;   \
+   cb_e.type = DUNDEE_ERROR_TYPE_FAILURE;  \
+   cb_e.error = 0; \
+   \
+   cb(cb_e, ##args);  \
+   } while (0) \
+
+#define CALLBACK_WITH_SUCCESS(f, args...)  \
+   do {\
+   struct dundee_error e;  \
+   e.type = DUNDEE_ERROR_TYPE_NO_ERROR;\
+   e.error = 0;\
+   f(e, ##args);  \
+   } while(0)  \
+
 #include ofono/log.h
 
 int __ofono_log_init(const char *program, const char *debug,
-- 
1.7.10.rc3.1.gb3065

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v6 12/16] dundee: Add device un/register

2012-04-02 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 dundee/device.c |   69 ++-
 dundee/dundee.h |   21 +
 2 files changed, 89 insertions(+), 1 deletion(-)

diff --git a/dundee/device.c b/dundee/device.c
index 1b89e97..bac8ead 100644
--- a/dundee/device.c
+++ b/dundee/device.c
@@ -33,14 +33,19 @@
 
 #include dundee.h
 
+static int next_device_id = 0;
 static GHashTable *device_hash;
 
 struct dundee_device {
+   char *path;
+   struct dundee_device_driver *driver;
+   gboolean registered;
+
 };
 
 const char *__dundee_device_get_path(struct dundee_device *device)
 {
-   return /;
+   return device-path;
 }
 
 void __dundee_device_append_properties(struct dundee_device *device,
@@ -64,15 +69,77 @@ void __dundee_device_foreach(dundee_device_foreach_func 
func, void *userdata)
}
 }
 
+static int register_device(struct dundee_device *device)
+{
+   return 0;
+}
+
+static int unregister_device(struct dundee_device *device)
+{
+   return 0;
+}
+
 static void destroy_device(gpointer user)
 {
struct dundee_device *device = user;
 
+   g_free(device-path);
+
g_free(device);
 }
 
+struct dundee_device *dundee_device_create(struct dundee_device_driver *d)
+{
+   struct dundee_device *device;
+
+   device = g_try_new0(struct dundee_device, 1);
+   if (device == NULL)
+   return NULL;
+
+   device-driver = d;
+
+   device-path = g_strdup_printf(/device%d, next_device_id);
+   if (device-path == NULL) {
+   g_free(device);
+   return NULL;
+   }
+
+   next_device_id += 1;
+
+   return device;
+}
+
+int dundee_device_register(struct dundee_device *device)
+{
+   int err;
+
+   err = register_device(device);
+   if (err  0)
+   return err;
+
+   device-registered = TRUE;
+
+   g_hash_table_insert(device_hash, g_strdup(device-path), device);
+
+   return 0;
+}
+
+void dundee_device_unregister(struct dundee_device *device)
+{
+   DBG(%p, device);
+
+   unregister_device(device);
+
+   device-registered = FALSE;
+
+   g_hash_table_remove(device_hash, device-path);
+}
+
 static void device_shutdown(gpointer key, gpointer value, gpointer user_data)
 {
+   struct dundee_device *device = value;
+
+   unregister_device(device);
 }
 
 void __dundee_device_shutdown(void)
diff --git a/dundee/dundee.h b/dundee/dundee.h
index 01edd53..a32eebf 100644
--- a/dundee/dundee.h
+++ b/dundee/dundee.h
@@ -105,6 +105,27 @@ int __dundee_device_init(void);
 void __dundee_device_cleanup(void);
 void __dundee_device_shutdown(void);
 
+typedef void (*dundee_device_connect_cb_t)(const struct dundee_error *error,
+   int fd, void *data);
+typedef void (*dundee_device_disconnect_cb_t)(const struct dundee_error *error,
+   void *data);
+
+struct dundee_device_driver {
+   const char *name;
+
+   /* Connect and dial */
+   void (*connect)(struct dundee_device *device,
+   dundee_device_connect_cb_t cb, void *data);
+
+   /* Hangup and disconnect */
+   void (*disconnect)(struct dundee_device *device,
+   dundee_device_disconnect_cb_t cb, void *data);
+};
+
+struct dundee_device *dundee_device_create(struct dundee_device_driver *d);
+int dundee_device_register(struct dundee_device *device);
+void dundee_device_unregister(struct dundee_device *device);
+
 typedef void (*dundee_device_foreach_func)(struct dundee_device *device,
void *data);
 void __dundee_device_foreach(dundee_device_foreach_func cb, void *userdata);
-- 
1.7.10.rc3.1.gb3065

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v6 13/16] dundee: Add driver helper functions

2012-04-02 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 dundee/device.c |   18 ++
 dundee/dundee.h |5 +
 2 files changed, 23 insertions(+)

diff --git a/dundee/device.c b/dundee/device.c
index bac8ead..6f2a7ea 100644
--- a/dundee/device.c
+++ b/dundee/device.c
@@ -41,6 +41,7 @@ struct dundee_device {
struct dundee_device_driver *driver;
gboolean registered;
 
+   void *data;
 };
 
 const char *__dundee_device_get_path(struct dundee_device *device)
@@ -135,6 +136,23 @@ void dundee_device_unregister(struct dundee_device *device)
g_hash_table_remove(device_hash, device-path);
 }
 
+void dundee_device_set_data(struct dundee_device *device, void *data)
+{
+   device-data = data;
+}
+
+void *dundee_device_get_data(struct dundee_device *device)
+{
+   return device-data;
+}
+
+int dundee_device_set_name(struct dundee_device *device, const char *name)
+{
+   DBG(%p name %s, device, name);
+
+   return 0;
+}
+
 static void device_shutdown(gpointer key, gpointer value, gpointer user_data)
 {
struct dundee_device *device = value;
diff --git a/dundee/dundee.h b/dundee/dundee.h
index a32eebf..5149f8b 100644
--- a/dundee/dundee.h
+++ b/dundee/dundee.h
@@ -126,6 +126,11 @@ struct dundee_device *dundee_device_create(struct 
dundee_device_driver *d);
 int dundee_device_register(struct dundee_device *device);
 void dundee_device_unregister(struct dundee_device *device);
 
+void dundee_device_set_data(struct dundee_device *device, void *data);
+void *dundee_device_get_data(struct dundee_device *device);
+
+int dundee_device_set_name(struct dundee_device *device, const char *name);
+
 typedef void (*dundee_device_foreach_func)(struct dundee_device *device,
void *data);
 void __dundee_device_foreach(dundee_device_foreach_func cb, void *userdata);
-- 
1.7.10.rc3.1.gb3065

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v6 14/16] dundee: Add device D-Bus interface

2012-04-02 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 dundee/device.c |  221 +++
 dundee/dundee.h |1 +
 2 files changed, 222 insertions(+)

diff --git a/dundee/device.c b/dundee/device.c
index 6f2a7ea..038bcc2 100644
--- a/dundee/device.c
+++ b/dundee/device.c
@@ -36,11 +36,21 @@
 static int next_device_id = 0;
 static GHashTable *device_hash;
 
+struct ipv4_settings {
+   char *interface;
+   char *ip;
+   char **nameservers;
+};
+
 struct dundee_device {
char *path;
struct dundee_device_driver *driver;
gboolean registered;
 
+   char *name;
+   gboolean active;
+   struct ipv4_settings settings;
+
void *data;
 };
 
@@ -49,9 +59,75 @@ const char *__dundee_device_get_path(struct dundee_device 
*device)
return device-path;
 }
 
+static void settings_append(struct dundee_device *device,
+   DBusMessageIter *iter)
+{
+   DBusMessageIter variant;
+   DBusMessageIter array;
+   char typesig[5];
+   char arraysig[6];
+
+   arraysig[0] = DBUS_TYPE_ARRAY;
+   arraysig[1] = typesig[0] = DBUS_DICT_ENTRY_BEGIN_CHAR;
+   arraysig[2] = typesig[1] = DBUS_TYPE_STRING;
+   arraysig[3] = typesig[2] = DBUS_TYPE_VARIANT;
+   arraysig[4] = typesig[3] = DBUS_DICT_ENTRY_END_CHAR;
+   arraysig[5] = typesig[4] = '\0';
+
+   dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
+   arraysig, variant);
+
+   dbus_message_iter_open_container(variant, DBUS_TYPE_ARRAY,
+   typesig, array);
+
+   if (device-active == FALSE)
+   goto out;
+
+   if (device-settings.interface)
+   ofono_dbus_dict_append(array, Interface,
+   DBUS_TYPE_STRING, device-settings.interface);
+
+   if (device-settings.ip)
+   ofono_dbus_dict_append(array, Address, DBUS_TYPE_STRING,
+   device-settings.ip);
+
+   if (device-settings.nameservers)
+   ofono_dbus_dict_append_array(array, DomainNameServers,
+   DBUS_TYPE_STRING,
+   device-settings.nameservers);
+
+out:
+   dbus_message_iter_close_container(variant, array);
+
+   dbus_message_iter_close_container(iter, variant);
+}
+
+static void settings_append_dict(struct dundee_device *device,
+   DBusMessageIter *dict)
+{
+   DBusMessageIter entry;
+   const char *key = Settings;
+
+   dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
+   NULL, entry);
+
+   dbus_message_iter_append_basic(entry, DBUS_TYPE_STRING, key);
+
+   settings_append(device, entry);
+
+   dbus_message_iter_close_container(dict, entry);
+}
+
 void __dundee_device_append_properties(struct dundee_device *device,
DBusMessageIter *dict)
 {
+   settings_append_dict(device, dict);
+
+   ofono_dbus_dict_append(dict, Name, DBUS_TYPE_STRING,
+   device-name);
+
+   ofono_dbus_dict_append(dict, Active, DBUS_TYPE_BOOLEAN,
+   device-active);
 }
 
 void __dundee_device_foreach(dundee_device_foreach_func func, void *userdata)
@@ -70,13 +146,141 @@ void __dundee_device_foreach(dundee_device_foreach_func 
func, void *userdata)
}
 }
 
+static DBusMessage *device_get_properties(DBusConnection *conn,
+   DBusMessage *msg, void *data)
+{
+   struct dundee_device *device = data;
+   DBusMessage *reply;
+   DBusMessageIter iter;
+   DBusMessageIter dict;
+
+   reply = dbus_message_new_method_return(msg);
+   if (reply == NULL)
+   return NULL;
+
+   dbus_message_iter_init_append(reply, iter);
+
+   dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
+   OFONO_PROPERTIES_ARRAY_SIGNATURE,
+   dict);
+
+   __dundee_device_append_properties(device, dict);
+
+   dbus_message_iter_close_container(iter, dict);
+
+   return reply;
+}
+
+static DBusMessage *set_property_active(struct dundee_device *device,
+   DBusMessage *msg,
+   DBusMessageIter *var)
+{
+   ofono_bool_t active;
+
+   DBG(%p path %s, device, device-path);
+
+   if (dbus_message_iter_get_arg_type(var) != DBUS_TYPE_BOOLEAN)
+   return __dundee_error_invalid_args(msg);
+
+   dbus_message_iter_get_basic(var, active);
+
+   device-active = active;
+
+   return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+}
+
+static DBusMessage *device_set_property(DBusConnection *conn

[PATCH v6 15/16] dundee: Add PPP handling code to device

2012-04-02 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 Makefile.am |2 +-
 dundee/device.c |  244 ++-
 2 files changed, 243 insertions(+), 3 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 20026d2..b2487ff 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -671,7 +671,7 @@ if DUNDEE
 
 sbin_PROGRAMS += dundee/dundee
 
-dundee_dundee_SOURCES = $(gdbus_sources) \
+dundee_dundee_SOURCES = $(gdbus_sources) $(gatchat_sources) \
src/log.c src/dbus.c \
dundee/dundee.h dundee/main.c dundee/dbus.c \
dundee/manager.c dundee/device.c
diff --git a/dundee/device.c b/dundee/device.c
index 038bcc2..9a25ac1 100644
--- a/dundee/device.c
+++ b/dundee/device.c
@@ -30,12 +30,16 @@
 
 #include glib.h
 #include gdbus.h
+#include gatchat.h
+#include gatppp.h
 
 #include dundee.h
 
 static int next_device_id = 0;
 static GHashTable *device_hash;
 
+static const char *none_prefix[] = { NULL };
+
 struct ipv4_settings {
char *interface;
char *ip;
@@ -47,10 +51,14 @@ struct dundee_device {
struct dundee_device_driver *driver;
gboolean registered;
 
+   GAtPPP *ppp;
+   GAtChat *chat;
+
char *name;
gboolean active;
struct ipv4_settings settings;
 
+   DBusMessage *pending;
void *data;
 };
 
@@ -146,6 +154,27 @@ void __dundee_device_foreach(dundee_device_foreach_func 
func, void *userdata)
}
 }
 
+static void settings_changed(struct dundee_device *device)
+{
+   DBusConnection *conn = ofono_dbus_get_connection();
+   DBusMessage *signal;
+   DBusMessageIter iter;
+   const char *key = Settings;
+
+   signal = dbus_message_new_signal(device-path,
+   DUNDEE_DEVICE_INTERFACE,
+   PropertyChanged);
+
+   if (signal == NULL)
+   return;
+   dbus_message_iter_init_append(signal, iter);
+   dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, key);
+
+   settings_append(device, iter);
+
+   g_dbus_send_message(conn, signal);
+}
+
 static DBusMessage *device_get_properties(DBusConnection *conn,
DBusMessage *msg, void *data)
 {
@@ -171,6 +200,203 @@ static DBusMessage *device_get_properties(DBusConnection 
*conn,
return reply;
 }
 
+
+static void debug(const char *str, void *data)
+{
+   DBG(%s: %s\n, (const char *) data, str);
+}
+
+static void ppp_connect(const char *iface, const char *local, const char *peer,
+   const char *dns1, const char *dns2,
+   gpointer user_data)
+{
+   DBusConnection *conn = ofono_dbus_get_connection();
+   struct dundee_device *device = user_data;
+   const char *dns[3] = { dns1, dns2, 0 };
+
+   DBG(%p, device);
+   DBG(Network Device: %s\n, iface);
+   DBG(IP Address: %s\n, local);
+   DBG(Peer IP Address: %s\n, peer);
+   DBG(Primary DNS Server: %s\n, dns1);
+   DBG(Secondary DNS Server: %s\n, dns2);
+
+   g_free(device-settings.interface);
+   device-settings.interface = g_strdup(iface);
+   if (device-settings.interface == NULL)
+   goto err;
+
+   g_free(device-settings.ip);
+   device-settings.ip = g_strdup(local);
+   if (device-settings.ip == NULL)
+   goto err;
+
+   g_strfreev(device-settings.nameservers);
+   device-settings.nameservers = g_strdupv((gchar **)dns);
+   if (device-settings.nameservers == NULL)
+   goto err;
+
+   device-active = TRUE;
+
+   settings_changed(device);
+   ofono_dbus_signal_property_changed(conn, device-path,
+   DUNDEE_DEVICE_INTERFACE, Active,
+   DBUS_TYPE_BOOLEAN, device-active);
+
+   return;
+
+err:
+   g_free(device-settings.interface);
+   g_free(device-settings.ip);
+   g_strfreev(device-settings.nameservers);
+   device-settings.interface = NULL;
+   device-settings.ip = NULL;
+   device-settings.nameservers = NULL;
+}
+
+static void disconnect_callback(const struct dundee_error *error, void *data)
+{
+   struct dundee_device *device = data;
+
+   DBG(%p, device);
+
+   g_at_chat_unref(device-chat);
+   device-chat = NULL;
+
+   if (device-pending == NULL)
+   return;
+
+   if (error-type != DUNDEE_ERROR_TYPE_NO_ERROR) {
+   __ofono_dbus_pending_reply(device-pending,
+   __dundee_error_failed(device-pending));
+   goto out;
+   }
+
+   __ofono_dbus_pending_reply(device-pending,
+   dbus_message_new_method_return(device-pending));
+
+out:
+   device-pending = NULL;
+}
+
+static void ppp_disconnect(GAtPPPDisconnectReason reason, gpointer user_data)
+{
+   DBusConnection *conn

[PATCH v6 16/16] dundee: Add Bluetooth DUN driver

2012-04-02 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 Makefile.am|6 +-
 dundee/bluetooth.c |  290 
 dundee/dundee.h|4 +
 dundee/main.c  |2 +
 4 files changed, 299 insertions(+), 3 deletions(-)
 create mode 100644 dundee/bluetooth.c

diff --git a/Makefile.am b/Makefile.am
index b2487ff..2361950 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -671,10 +671,10 @@ if DUNDEE
 
 sbin_PROGRAMS += dundee/dundee
 
-dundee_dundee_SOURCES = $(gdbus_sources) $(gatchat_sources) \
-   src/log.c src/dbus.c \
+dundee_dundee_SOURCES = $(gdbus_sources) $(gatchat_sources) $(btio_sources) \
+   src/log.c src/dbus.c plugins/bluetooth.c \
dundee/dundee.h dundee/main.c dundee/dbus.c \
-   dundee/manager.c dundee/device.c
+   dundee/manager.c dundee/device.c dundee/bluetooth.c
 
 dundee_dundee_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ 
-ldl
 
diff --git a/dundee/bluetooth.c b/dundee/bluetooth.c
new file mode 100644
index 000..4ca3617
--- /dev/null
+++ b/dundee/bluetooth.c
@@ -0,0 +1,290 @@
+/*
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2011  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2012  BMW Car IT GmbH. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include config.h
+#endif
+
+#include sys/types.h
+#include sys/stat.h
+#include fcntl.h
+#include string.h
+#include errno.h
+
+#include glib.h
+
+#include plugins/bluetooth.h
+
+#include dundee.h
+
+static GHashTable *bluetooth_hash;
+
+struct bluetooth_device {
+   struct dundee_device *device;
+
+   char *path;
+   char *address;
+   char *name;
+
+   DBusPendingCall *call;
+};
+
+static void bt_disconnect(struct dundee_device *device,
+   dundee_device_disconnect_cb_t cb, void *data)
+{
+   struct bluetooth_device *bt = dundee_device_get_data(device);
+
+   DBG(%p, bt);
+
+   CALLBACK_WITH_SUCCESS(cb, data);
+}
+
+static void bt_connect_reply(DBusPendingCall *call, gpointer user_data)
+{
+   struct cb_data *cbd = user_data;
+   dundee_device_connect_cb_t cb = cbd-cb;
+   struct bluetooth_device *bt = cbd-user;
+   DBusMessage *reply;
+   DBusError derr;
+   int fd;
+
+   DBG(%p, bt);
+
+   reply = dbus_pending_call_steal_reply(call);
+
+   bt-call = NULL;
+
+   dbus_error_init(derr);
+   if (dbus_set_error_from_message(derr, reply)) {
+   DBG(Connection to bt serial returned with error: %s, %s,
+   derr.name, derr.message);
+
+   dbus_error_free(derr);
+
+   CALLBACK_WITH_FAILURE(cb, -1, cbd-data);
+   goto done;
+   }
+
+   dbus_message_get_args(reply, NULL, DBUS_TYPE_UNIX_FD, fd,
+   DBUS_TYPE_INVALID);
+
+   DBG(%p fd %d, bt, fd);
+
+   if (fd  0) {
+   CALLBACK_WITH_FAILURE(cb, -1, cbd-data);
+   goto done;
+   }
+
+   CALLBACK_WITH_SUCCESS(cb, fd, cbd-data);
+
+done:
+   dbus_message_unref(reply);
+   g_free(cbd);
+}
+
+static void bt_connect(struct dundee_device *device,
+   dundee_device_connect_cb_t cb, void *data)
+{
+   struct bluetooth_device *bt = dundee_device_get_data(device);
+   struct cb_data *cbd = cb_data_new(cb, data);
+   char *profile = dun;
+   int status;
+
+   DBG(%p, bt);
+
+   cbd-user = bt;
+
+   status = bluetooth_send_with_reply(bt-path,
+   BLUEZ_SERIAL_INTERFACE, ConnectFD,
+   bt-call, bt_connect_reply,
+   cbd, NULL, DBUS_TIMEOUT,
+   DBUS_TYPE_STRING, profile,
+   DBUS_TYPE_INVALID);
+   if (status == 0)
+   return;
+
+   g_free(cbd);
+
+   CALLBACK_WITH_FAILURE(cb, -1, cbd-data);
+}
+
+struct dundee_device_driver bluetooth_driver = {
+   .name = bluetooth,
+   .connect = bt_connect,
+   .disconnect = bt_disconnect,
+};
+
+static int bt_probe(const char *path, const char *dev_addr

[RFC v0] ofono: Only register network when APN is set

2012-02-28 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

We should now show a network without an APN.
---
I have not tested this one. But something like this should do
the trick. Maybe someone with deeper knowledge on the APN
behavior could explain under which circumstances the APN is set, e.g.
see the netreg vs apn setting in this patch. Not sure if this is correct.

cheers,
daniel

 plugins/ofono.c |   25 +
 1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/plugins/ofono.c b/plugins/ofono.c
index d87d7b6..c92c3cc 100644
--- a/plugins/ofono.c
+++ b/plugins/ofono.c
@@ -105,6 +105,9 @@ enum ofono_api {
  * the plugin about IP configuration through the updating the context's
  * properties.
  *
+ * The network is only registered at the core when the AccessPointName
+ * has been set.
+ *
  * CDMA working flow:
  *
  * When a new modem appears, the plugin always powers it up. This
@@ -172,6 +175,7 @@ struct modem_data {
/* ConnectionContext Interface */
connman_bool_t active;
connman_bool_t set_active;
+   char *apn;
 
/* SimManager Interface */
char *imsi;
@@ -1105,6 +1109,10 @@ static int add_cm_context(struct modem_data *modem, 
const char *context_path,
dbus_message_iter_get_basic(value, active);
 
DBG(%s Active %d, modem-path, active);
+   } else if (g_str_equal(key, AccessPointName) == TRUE) {
+   dbus_message_iter_get_basic(value, modem-apn);
+
+   DBG(%s AccessPointName %s, modem-path, modem-apn);
}
 
dbus_message_iter_next(dict);
@@ -1180,6 +1188,19 @@ static gboolean context_changed(DBusConnection 
*connection,
set_connected(modem);
else
set_disconnected(modem);
+   } else if (g_str_equal(key, AccessPointName) == TRUE) {
+   g_free(modem-apn);
+
+   dbus_message_iter_get_basic(value, modem-apn);
+
+   DBG(%s AccessPointName %s, modem-path, modem-apn);
+
+   if (has_interface(modem-interfaces,
+   OFONO_API_NETREG) == TRUE 
+   modem-network != NULL) {
+   DBG(Register network at core);
+   add_network(modem);
+   }
}
 
return TRUE;
@@ -1518,6 +1539,9 @@ static void netreg_properties_reply(struct modem_data 
*modem,
return;
}
 
+   if (modem-apn == NULL)
+   return;
+
add_network(modem);
 
if (modem-active == TRUE)
@@ -2187,6 +2211,7 @@ static void remove_modem(gpointer data)
g_free(modem-serial);
g_free(modem-name);
g_free(modem-imsi);
+   g_free(modem-apn);
g_free(modem-path);
 
g_free(modem);
-- 
1.7.9.48.g85da4d

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [RFC v0] ofono: Only register network when APN is set

2012-02-28 Thread Daniel Wagner
O  dbus_message_iter_next(dict);
 @@ -1180,6 +1188,19 @@ static gboolean context_changed(DBusConnection 
 *connection,
   set_connected(modem);
   else
   set_disconnected(modem);
 + } else if (g_str_equal(key, AccessPointName) == TRUE) {
 + g_free(modem-apn);
 +
 + dbus_message_iter_get_basic(value, modem-apn);
 +
 + DBG(%s AccessPointName %s, modem-path, modem-apn);
 +
 + if (has_interface(modem-interfaces,
 + OFONO_API_NETREG) == TRUE 
 + modem-network != NULL) {
 + DBG(Register network at core);
 + add_network(modem);
 + }

that should be a modem-network == NULL of course.
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: bug: NULL pointer access?

2012-01-16 Thread Daniel Wagner
Hi Denis,

On 05.01.2012 16:40, Denis Kenzior wrote:
 Hi Daniel,
 
 On 01/05/2012 08:59 AM, Daniel Wagner wrote:
 Hi,

 I just managed to get this backtrace:

 ofonod[1808]:  backtrace 
 ofonod[1808]: #0  0x3366c0f500 in /lib64/libpthread.so.0
 ofonod[1808]: #1  0x3366836285 in /lib64/libc.so.6
 ofonod[1808]: #2  0x3366837b9b in /lib64/libc.so.6
 ofonod[1808]: #3  0x336982fd85 in /lib64/libdbus-1.so.3
 ofonod[1808]: #4  0x3369826e31 in /lib64/libdbus-1.so.3
 ofonod[1808]: #5  0x336981b806 in /lib64/libdbus-1.so.3
 ofonod[1808]: #6  0x4db083 in pri_activate_callback() at src/gprs.c:871
 ofonod[1808]: #7  0x4611cf in ppp_connect() at 
 drivers/atmodem/gprs-context.c:101
 ofonod[1808]: #8  0x447fdd in ppp_ipcp_up_notify() at gatchat/gatppp.c:415
 ofonod[1808]: #9  0x44bdbc in ipcp_up() at gatchat/ppp_ipcp.c:173
 ofonod[1808]: #10 0x44911d in pppcp_this_layer_up() at gatchat/ppp_cp.c:322
 ofonod[1808]: #11 0x449e5e in pppcp_generate_event() at gatchat/ppp_cp.c:690
 ofonod[1808]: #12 0x44a68b in pppcp_process_packet() at gatchat/ppp_cp.c:967
 ofonod[1808]: #13 0x447905 in ppp_receive() at gatchat/gatppp.c:224
 ofonod[1808]: #14 0x446994 in new_bytes() at gatchat/gathdlc.c:301
 ofonod[1808]: #15 0x43edf3 in received_data() at gatchat/gatio.c:124
 ofonod[1808]: #16 0x3368844a7d in /lib64/libglib-2.0.so.0
 ofonod[1808]: #17 0x3368845278 in /lib64/libglib-2.0.so.0
 ofonod[1808]: #18 0x33688457c5 in /lib64/libglib-2.0.so.0
 ofonod[1808]: #19 0x496c4e in main() at src/main.c:262
 ofonod[1808]: #20 0x336682169d in /lib64/libc.so.6
 ofonod[1808]: +++


 static void pri_activate_callback(const struct ofono_error *error, void 
 *data)
 {
  [...]

  __ofono_dbus_pending_reply(ctx-pending,
  dbus_message_new_method_return(ctx-pending));

  [...]
 }

 I guess ctx-pending is NULL. 

 
 Sounds like it, but this makes no sense; pending is set right above the
 single instance of the driver operation with pri_activate_callback as
 the callback.  The only way for this to happen is if the callback is
 being called twice or some other interesting circumstance...
 
 Can you duplicate this reliably?

No, not really. I was playing around with a new USB stick and I somehow
managed to trigger this one. Unfortunately, I can't remember what I did.
The only thing I remember was I restarted both daemon a few times.

I guess we can't much about this one then.

cheers,
daniel
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH v5 00/16] Add DUN support

2012-01-05 Thread Daniel Wagner
Hi Rémi,

On 05.01.2012 13:07, Rémi Denis-Courmont wrote:
 Le Mercredi 4 Janvier 2012 18:17:34 ext Daniel Wagner a écrit :
 From: Daniel Wagner daniel.wag...@bmw-carit.de
 I think this series is ready to be considered to be merged *hint* :)
 
 I may be missing something obvious, but why is this a new daemon instead of a 
 driver or plugin inside oFono?

There are a few reasons why a modem plugin is not really good. Here an
summary from my original posting on the ConnMan mailing list:


This is the 3rd attempt to get DUN done (pun!). The first and second
attempt was to expose DUN devices through the oFono API. While this
sounds like a reasonable way to go it has some - let's put it
this way - ugliness involved. 

 - No SIM interface: This is not so bad but still we have to hack around
   this problem. Since we need some uniqueness to distinguish between
   services, the Serial property of the Modem interface has to be
   abused for this.
 - No NetworkRegistration interface: DUN only specifies ATD*99# AT command.
   All other AT commands might be supported (such as AT+COPS=?) but are not
   necessarily there. That means we might not get a name for a network. Whereas
   you can rely to get this name for a regular modem you can't on DUN ones.
   And guess what you cannot distinguish between real hardware modems and
   virtual ones unless...
 - Abuse Modem.Type: ... add 'dun' type and adapt the oFono plugin. That
   _is_ though a very bad idea. We just introduce a mighty switch for 
   different oFono API behavior. Denis used strong words against this
   approach.
 - oFono internal design: oFono is not designed to handle this kind
   of modems. The dunmodem implementation is rather obscure. The result
   of this is that, as soon as a DUN device pops up, an Serial channel is
   opened (rfcomm) and kept alive. Unfortunately, there are phones outside
   in the wild which like to close the serial link after PPP stops.
   With oFono's separation of concerns this is not easy to get working.
 - Technology mess: In order to get DUN modems working you have to enable 
Cellular
   and Bluetooth technology. This is really really bad because we expose
   the implementation details to the user. Sure, DUN is kind of dying etc.
   but then, I don't think our standards are so low.

(http://www.mail-archive.com/connman@connman.net/msg06971.html)

cheers,
daniel
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


bug: NULL pointer access?

2012-01-05 Thread Daniel Wagner
Hi,

I just managed to get this backtrace:

ofonod[1808]:  backtrace 
ofonod[1808]: #0  0x3366c0f500 in /lib64/libpthread.so.0
ofonod[1808]: #1  0x3366836285 in /lib64/libc.so.6
ofonod[1808]: #2  0x3366837b9b in /lib64/libc.so.6
ofonod[1808]: #3  0x336982fd85 in /lib64/libdbus-1.so.3
ofonod[1808]: #4  0x3369826e31 in /lib64/libdbus-1.so.3
ofonod[1808]: #5  0x336981b806 in /lib64/libdbus-1.so.3
ofonod[1808]: #6  0x4db083 in pri_activate_callback() at src/gprs.c:871
ofonod[1808]: #7  0x4611cf in ppp_connect() at 
drivers/atmodem/gprs-context.c:101
ofonod[1808]: #8  0x447fdd in ppp_ipcp_up_notify() at gatchat/gatppp.c:415
ofonod[1808]: #9  0x44bdbc in ipcp_up() at gatchat/ppp_ipcp.c:173
ofonod[1808]: #10 0x44911d in pppcp_this_layer_up() at gatchat/ppp_cp.c:322
ofonod[1808]: #11 0x449e5e in pppcp_generate_event() at gatchat/ppp_cp.c:690
ofonod[1808]: #12 0x44a68b in pppcp_process_packet() at gatchat/ppp_cp.c:967
ofonod[1808]: #13 0x447905 in ppp_receive() at gatchat/gatppp.c:224
ofonod[1808]: #14 0x446994 in new_bytes() at gatchat/gathdlc.c:301
ofonod[1808]: #15 0x43edf3 in received_data() at gatchat/gatio.c:124
ofonod[1808]: #16 0x3368844a7d in /lib64/libglib-2.0.so.0
ofonod[1808]: #17 0x3368845278 in /lib64/libglib-2.0.so.0
ofonod[1808]: #18 0x33688457c5 in /lib64/libglib-2.0.so.0
ofonod[1808]: #19 0x496c4e in main() at src/main.c:262
ofonod[1808]: #20 0x336682169d in /lib64/libc.so.6
ofonod[1808]: +++


static void pri_activate_callback(const struct ofono_error *error, void *data)
{
[...]

__ofono_dbus_pending_reply(ctx-pending,
dbus_message_new_method_return(ctx-pending));

[...]
}

I guess ctx-pending is NULL. 

cheers,
daniel
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v5 01/16] bluetooth: Add Serial interface definition

2012-01-04 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 plugins/bluetooth.h |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index daa1873..4fc16ad 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -27,6 +27,7 @@
 #defineBLUEZ_ADAPTER_INTERFACE BLUEZ_SERVICE .Adapter
 #defineBLUEZ_DEVICE_INTERFACE  BLUEZ_SERVICE .Device
 #defineBLUEZ_SERVICE_INTERFACE BLUEZ_SERVICE .Service
+#define BLUEZ_SERIAL_INTERFACE BLUEZ_SERVICE .Serial
 
 #define DBUS_TIMEOUT 15
 
-- 
1.7.8.2.302.g17b4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v5 00/16] Add DUN support

2012-01-04 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

Hi,

I think this series is ready to be considered to be merged *hint* :)

Changes v5:
 - Use Serial.ConnectFD() instead of Serial.Connect()
 - Small bug fix in disconnect callback

cheers,
daniel

Daniel Wagner (16):
  bluetooth: Add Serial interface definition
  dundee: Add documentation
  dundee: Add test scripts
  dundee: Add skeleton implementation
  dundee: Add D-Bus error messages
  dundee: Add D-Bus configuration file
  dundee: Add systemd configuration file
  dundee: Add Manager interface
  dundee: Add skeleton implementation for device
  dundee: Manager append devices
  dundee: Add callback helpers
  dundee: Add device un/register
  dundee: Add driver helper functions
  dundee: Add device D-Bus interface
  dundee: Add PPP handling code to device
  dundee: Add Bluetooth DUN driver

 Makefile.am|   25 ++
 bootstrap-configure|1 +
 configure.ac   |4 +
 doc/dundee-api.txt |   76 ++
 dundee/bluetooth.c |  290 ++
 dundee/dbus.c  |   45 
 dundee/device.c|  646 
 dundee/dundee.conf |   23 ++
 dundee/dundee.h|  145 +++
 dundee/dundee.service  |   11 +
 dundee/main.c  |  256 +++
 dundee/manager.c   |  119 +
 plugins/bluetooth.h|1 +
 test/dundee-connect|   20 ++
 test/dundee-disconnect |   20 ++
 test/monitor-dundee|  109 
 16 files changed, 1791 insertions(+), 0 deletions(-)
 create mode 100644 doc/dundee-api.txt
 create mode 100644 dundee/bluetooth.c
 create mode 100644 dundee/dbus.c
 create mode 100644 dundee/device.c
 create mode 100644 dundee/dundee.conf
 create mode 100644 dundee/dundee.h
 create mode 100644 dundee/dundee.service
 create mode 100644 dundee/main.c
 create mode 100644 dundee/manager.c
 create mode 100755 test/dundee-connect
 create mode 100755 test/dundee-disconnect
 create mode 100755 test/monitor-dundee

-- 
1.7.8.2.302.g17b4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v5 02/16] dundee: Add documentation

2012-01-04 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 doc/dundee-api.txt |   76 
 1 files changed, 76 insertions(+), 0 deletions(-)
 create mode 100644 doc/dundee-api.txt

diff --git a/doc/dundee-api.txt b/doc/dundee-api.txt
new file mode 100644
index 000..9f4cfe6
--- /dev/null
+++ b/doc/dundee-api.txt
@@ -0,0 +1,76 @@
+
+Manager hierarchy
+=
+
+Serviceorg.ofono.dundee
+Interface  org.ofono.dundee.Manager
+Object path/
+
+Methodsarray{object,dict} GetDevices()
+
+   Get an array of device objects and properties
+   that represent the currently attached devices.
+
+   This method call should only be used once when an
+   application starts up. Further device additions
+   and removal shall be monitored via DeviceAdded and
+   DeviceRemoved signals.
+
+SignalsDeviceAdded(object path, dict properties)
+
+   Signal that is sent when a new device is added.  It
+   contains the object path of new device and its
+   properties.
+
+   DeviceRemoved(object path)
+
+   Signal that is sent when a device has been removed.
+   The object path is no longer accessible after this
+   signal and only emitted for reference.
+
+
+Device hierarchy
+
+
+Serviceorg.ofono.dundee
+Interface  org.ofono.dundee.Device
+Object path/{device0,device1,...}
+
+Methodsdict GetProperties()
+
+   Returns properties for the device object. See
+   the properties section for available properties.
+
+SignalsPropertyChanged(string name, variant value)
+
+   This signal indicates a changed value of the given
+   property.
+
+Properties string Name [readonly]
+
+   Friendly name of the device.
+
+   boolean Active [readwrite]
+
+   Holds whether the device is connected. A
+   connection will be established when this value
+   is set to true. A existing connection will be
+   teared down when set to false.
+
+   dict Settings [readonly]
+
+   Holds all the IP network settings.
+
+   string Interface [readonly, optional]
+
+   Holds the interface of the network interface
+   used by this connection (e.g. ppp0 usb0)
+
+   string Address [readonly, optional]
+
+   Holds the IP address for this connection.
+
+   array{string} DomainNameServers [readonly, optional]
+
+   Holds the list of domain name servers for this
+   connection.
-- 
1.7.8.2.302.g17b4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v5 03/16] dundee: Add test scripts

2012-01-04 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 test/dundee-connect|   20 +
 test/dundee-disconnect |   20 +
 test/monitor-dundee|  109 
 3 files changed, 149 insertions(+), 0 deletions(-)
 create mode 100755 test/dundee-connect
 create mode 100755 test/dundee-disconnect
 create mode 100755 test/monitor-dundee

diff --git a/test/dundee-connect b/test/dundee-connect
new file mode 100755
index 000..6cbc629
--- /dev/null
+++ b/test/dundee-connect
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+
+import dbus
+import sys
+
+bus = dbus.SystemBus()
+
+if len(sys.argv) == 2:
+   path = sys.argv[1]
+else:
+   manager = dbus.Interface(bus.get_object('org.ofono.dundee', '/'),
+   'org.ofono.dundee.Manager')
+   devices = manager.GetDevices()
+   path = devices[0][0]
+
+print Connect device %s... % path
+device = dbus.Interface(bus.get_object('org.ofono.dundee', path),
+   'org.ofono.dundee.Device')
+
+device.Connect()
diff --git a/test/dundee-disconnect b/test/dundee-disconnect
new file mode 100755
index 000..76ff74c
--- /dev/null
+++ b/test/dundee-disconnect
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+
+import dbus
+import sys
+
+bus = dbus.SystemBus()
+
+if len(sys.argv) == 2:
+   path = sys.argv[1]
+else:
+   manager = dbus.Interface(bus.get_object('org.ofono.elect', '/'),
+   'org.ofono.elect.Manager')
+   devices = manager.GetDevices()
+   path = devices[0][0]
+
+print Disonnect device %s... % path
+device = dbus.Interface(bus.get_object('org.ofono.elect', path),
+   'org.ofono.elect.Device')
+
+device.Disconnect()
diff --git a/test/monitor-dundee b/test/monitor-dundee
new file mode 100755
index 000..cf96ceb
--- /dev/null
+++ b/test/monitor-dundee
@@ -0,0 +1,109 @@
+#!/usr/bin/python
+
+import gobject
+
+import dbus
+import dbus.mainloop.glib
+
+_dbus2py = {
+   dbus.String : unicode,
+   dbus.UInt32 : int,
+   dbus.Int32 : int,
+   dbus.Int16 : int,
+   dbus.UInt16 : int,
+   dbus.UInt64 : int,
+   dbus.Int64 : int,
+   dbus.Byte : int,
+   dbus.Boolean : bool,
+   dbus.ByteArray : str,
+   dbus.ObjectPath : str
+}
+
+def dbus2py(d):
+   t = type(d)
+   if t in _dbus2py:
+   return _dbus2py[t](d)
+   if t is dbus.Dictionary:
+   return dict([(dbus2py(k), dbus2py(v)) for k, v in d.items()])
+   if t is dbus.Array and d.signature == y:
+   return .join([chr(b) for b in d])
+   if t is dbus.Array or t is list:
+   return [dbus2py(v) for v in d]
+   if t is dbus.Struct or t is tuple:
+   return tuple([dbus2py(v) for v in d])
+   return d
+
+def pretty(d):
+   d = dbus2py(d)
+   t = type(d)
+
+   if t in (dict, tuple, list) and len(d)  0:
+   if t is dict:
+   d = , .join([%s = %s % (k, pretty(v))
+   for k, v in d.items()])
+   return { %s } % d
+
+   d =  .join([pretty(e) for e in d])
+
+   if t is tuple:
+   return ( %s ) % d
+
+   return str(d)
+
+def property_changed(name, value, path, interface):
+   iface = interface[interface.rfind(.) + 1:]
+   print {%s} [%s] %s = %s % (iface, path, name, pretty(value))
+
+def added(name, value, member, path, interface):
+   iface = interface[interface.rfind(.) + 1:]
+   print {%s} [%s] %s %s % (iface, member, name, pretty(value))
+
+def removed(name, member, path, interface):
+   iface = interface[interface.rfind(.) + 1:]
+   print {%s} [%s] %s % (iface, member, name)
+
+def event(member, path, interface):
+   iface = interface[interface.rfind(.) + 1:]
+   print {%s} [%s] %s % (iface, path, member)
+
+def message(msg, args, member, path, interface):
+   iface = interface[interface.rfind(.) + 1:]
+   print {%s} [%s] %s %s (%s) % (iface, path, member,
+   str(msg), pretty(args))
+
+def ussd(msg, member, path, interface):
+   iface = interface[interface.rfind(.) + 1:]
+   print {%s} [%s] %s %s % (iface, path, member, str(msg))
+
+def value(value, member, path, interface):
+   iface = interface[interface.rfind(.) + 1:]
+   print {%s} [%s] %s %s % (iface, path, member, str(value))
+
+if __name__ == '__main__':
+   dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+
+   bus = dbus.SystemBus()
+
+   bus.add_signal_receiver(property_changed,
+   bus_name=org.ofono.dundee,
+   signal_name = PropertyChanged,
+   path_keyword=path,
+   interface_keyword=interface)
+
+   bus.add_signal_receiver(added

[PATCH v5 04/16] dundee: Add skeleton implementation

2012-01-04 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 Makefile.am |   12 +++
 bootstrap-configure |1 +
 configure.ac|4 +
 dundee/dundee.h |   46 +
 dundee/main.c   |  255 +++
 5 files changed, 318 insertions(+), 0 deletions(-)
 create mode 100644 dundee/dundee.h
 create mode 100644 dundee/main.c

diff --git a/Makefile.am b/Makefile.am
index 9831924..a4ced4a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -649,6 +649,18 @@ tools_lookup_provider_name_SOURCES = plugins/mbpi.c 
plugins/mbpi.h \
 tools_lookup_provider_name_LDADD = @GLIB_LIBS@
 endif
 
+if DUNDEE
+
+sbin_PROGRAMS += dundee/dundee
+
+dundee_dundee_SOURCES = $(gdbus_sources) \
+   src/log.c src/dbus.c \
+   dundee/main.c
+
+dundee_dundee_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ 
-ldl
+
+endif
+
 noinst_PROGRAMS += gatchat/gsmdial gatchat/test-server gatchat/test-qcdm
 
 gatchat_gsmdial_SOURCES = gatchat/gsmdial.c $(gatchat_sources)
diff --git a/bootstrap-configure b/bootstrap-configure
index db70c66..1fae158 100755
--- a/bootstrap-configure
+++ b/bootstrap-configure
@@ -14,4 +14,5 @@ fi
--localstatedir=/var \
--enable-capng \
--enable-tools \
+   --enable-dundee \
--disable-datafiles $*
diff --git a/configure.ac b/configure.ac
index 4e93a3c..ef42794 100644
--- a/configure.ac
+++ b/configure.ac
@@ -165,6 +165,10 @@ if (test ${enable_tools} = yes); then
 fi
 AM_CONDITIONAL(TOOLS, test ${enable_tools} = yes)
 
+AC_ARG_ENABLE(dundee, AC_HELP_STRING([--enable-dundee],
+   [enable DUN deamon support]), [enable_dundee=${enableval}])
+AM_CONDITIONAL(DUNDEE, test ${enable_dundee} = yes)
+
 AC_ARG_ENABLE(atmodem, AC_HELP_STRING([--disable-atmodem],
[disable ETSI AT modem support]),
[enable_atmodem=${enableval}])
diff --git a/dundee/dundee.h b/dundee/dundee.h
new file mode 100644
index 000..83d8969
--- /dev/null
+++ b/dundee/dundee.h
@@ -0,0 +1,46 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2011  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2012  BMW Car IT GmbH. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#include glib.h
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+
+#include ofono/types.h
+
+void __dundee_exit(void);
+
+#include ofono/log.h
+
+int __ofono_log_init(const char *program, const char *debug,
+   ofono_bool_t detach);
+void __ofono_log_cleanup(void);
+void __ofono_log_enable(struct ofono_debug_desc *start,
+   struct ofono_debug_desc *stop);
+
+#include ofono/dbus.h
+
+#define DUNDEE_SERVICE org.ofono.dundee
+
+int __ofono_dbus_init(DBusConnection *conn);
+void __ofono_dbus_cleanup(void);
+
+void __ofono_dbus_pending_reply(DBusMessage **msg, DBusMessage *reply);
diff --git a/dundee/main.c b/dundee/main.c
new file mode 100644
index 000..0bee690
--- /dev/null
+++ b/dundee/main.c
@@ -0,0 +1,255 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2011  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2012  BMW Car IT GmbH. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include config.h
+#endif
+
+#include stdio.h
+#include stdlib.h
+#include unistd.h
+#include string.h
+#include signal.h
+#include sys/signalfd.h
+
+#include gdbus.h
+
+#ifdef HAVE_CAPNG
+#include cap-ng.h
+#endif
+
+#include dundee.h
+
+#define SHUTDOWN_GRACE_SECONDS 10
+
+static GMainLoop

[PATCH v5 05/16] dundee: Add D-Bus error messages

2012-01-04 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 Makefile.am |2 +-
 dundee/dbus.c   |   45 +
 dundee/dundee.h |3 +++
 3 files changed, 49 insertions(+), 1 deletions(-)
 create mode 100644 dundee/dbus.c

diff --git a/Makefile.am b/Makefile.am
index a4ced4a..da456ed 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -655,7 +655,7 @@ sbin_PROGRAMS += dundee/dundee
 
 dundee_dundee_SOURCES = $(gdbus_sources) \
src/log.c src/dbus.c \
-   dundee/main.c
+   dundee/main.c dundee/dbus.c
 
 dundee_dundee_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ 
-ldl
 
diff --git a/dundee/dbus.c b/dundee/dbus.c
new file mode 100644
index 000..f15a2fc
--- /dev/null
+++ b/dundee/dbus.c
@@ -0,0 +1,45 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2011  BMW Car IT GmbH. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include config.h
+#endif
+
+#include glib.h
+#include gdbus.h
+
+#include dundee.h
+
+#define DUNDEE_ERROR_INTERFACE org.ofono.dundee.Error
+
+DBusMessage *__dundee_error_invalid_args(DBusMessage *msg)
+{
+   return g_dbus_create_error(msg, DUNDEE_ERROR_INTERFACE
+   .InvalidArguments,
+   Invalid arguments in method call);
+}
+
+DBusMessage *__dundee_error_failed(DBusMessage *msg)
+{
+   return g_dbus_create_error(msg, DUNDEE_ERROR_INTERFACE
+   .Failed,
+   Operation failed);
+}
diff --git a/dundee/dundee.h b/dundee/dundee.h
index 83d8969..a56de9a 100644
--- a/dundee/dundee.h
+++ b/dundee/dundee.h
@@ -44,3 +44,6 @@ int __ofono_dbus_init(DBusConnection *conn);
 void __ofono_dbus_cleanup(void);
 
 void __ofono_dbus_pending_reply(DBusMessage **msg, DBusMessage *reply);
+
+DBusMessage *__dundee_error_invalid_args(DBusMessage *msg);
+DBusMessage *__dundee_error_failed(DBusMessage *msg);
-- 
1.7.8.2.302.g17b4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v5 06/16] dundee: Add D-Bus configuration file

2012-01-04 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 Makefile.am|6 ++
 dundee/dundee.conf |   23 +++
 2 files changed, 29 insertions(+), 0 deletions(-)
 create mode 100644 dundee/dundee.conf

diff --git a/Makefile.am b/Makefile.am
index da456ed..742bde9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -659,6 +659,12 @@ dundee_dundee_SOURCES = $(gdbus_sources) \
 
 dundee_dundee_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ 
-ldl
 
+if DATAFILES
+
+dist_dbusconf_DATA += dundee/dundee.conf
+
+endif
+
 endif
 
 noinst_PROGRAMS += gatchat/gsmdial gatchat/test-server gatchat/test-qcdm
diff --git a/dundee/dundee.conf b/dundee/dundee.conf
new file mode 100644
index 000..de79dd5
--- /dev/null
+++ b/dundee/dundee.conf
@@ -0,0 +1,23 @@
+!-- This configuration file specifies the required security policies
+ for oFono dundee (DUN) daemon to work. --
+
+!DOCTYPE busconfig PUBLIC -//freedesktop//DTD D-BUS Bus Configuration 
1.0//EN
+ http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd;
+busconfig
+
+  !-- ../system.conf have denied everything, so we just punch some holes --
+
+  policy user=root
+allow own=org.ofono.dundee/
+allow send_destination=org.ofono.dundee/
+  /policy
+
+  policy at_console=true
+allow send_destination=org.ofono.dundee/
+  /policy
+
+  policy context=default
+deny send_destination=org.ofono.dundee/
+  /policy
+
+/busconfig
-- 
1.7.8.2.302.g17b4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v5 07/16] dundee: Add systemd configuration file

2012-01-04 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 Makefile.am   |6 ++
 dundee/dundee.service |   11 +++
 2 files changed, 17 insertions(+), 0 deletions(-)
 create mode 100644 dundee/dundee.service

diff --git a/Makefile.am b/Makefile.am
index 742bde9..b335caa 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -663,6 +663,12 @@ if DATAFILES
 
 dist_dbusconf_DATA += dundee/dundee.conf
 
+if SYSTEMD
+systemdunitdir += @SYSTEMD_UNITDIR@
+
+systemdunit_DATA += dundee/dundee.service
+endif
+
 endif
 
 endif
diff --git a/dundee/dundee.service b/dundee/dundee.service
new file mode 100644
index 000..1b8f323
--- /dev/null
+++ b/dundee/dundee.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=DUN service
+After=syslog.target
+
+[Service]
+Type=dbus
+BusName=org.ofono.dundee
+ExecStart=/usr/sbin/dundee -n
+
+[Install]
+WantedBy=multi-user.target
-- 
1.7.8.2.302.g17b4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v5 08/16] dundee: Add Manager interface

2012-01-04 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 Makefile.am  |2 +-
 dundee/dundee.h  |6 +++
 dundee/main.c|9 ++---
 dundee/manager.c |   97 ++
 4 files changed, 107 insertions(+), 7 deletions(-)
 create mode 100644 dundee/manager.c

diff --git a/Makefile.am b/Makefile.am
index b335caa..9b36970 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -655,7 +655,7 @@ sbin_PROGRAMS += dundee/dundee
 
 dundee_dundee_SOURCES = $(gdbus_sources) \
src/log.c src/dbus.c \
-   dundee/main.c dundee/dbus.c
+   dundee/main.c dundee/dbus.c dundee/manager.c
 
 dundee_dundee_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ 
-ldl
 
diff --git a/dundee/dundee.h b/dundee/dundee.h
index a56de9a..82ab5f8 100644
--- a/dundee/dundee.h
+++ b/dundee/dundee.h
@@ -39,6 +39,8 @@ void __ofono_log_enable(struct ofono_debug_desc *start,
 #include ofono/dbus.h
 
 #define DUNDEE_SERVICE org.ofono.dundee
+#define DUNDEE_MANAGER_INTERFACE   org.ofono.dundee.Manager
+#define DUNDEE_MANAGER_PATH/
 
 int __ofono_dbus_init(DBusConnection *conn);
 void __ofono_dbus_cleanup(void);
@@ -47,3 +49,7 @@ void __ofono_dbus_pending_reply(DBusMessage **msg, 
DBusMessage *reply);
 
 DBusMessage *__dundee_error_invalid_args(DBusMessage *msg);
 DBusMessage *__dundee_error_failed(DBusMessage *msg);
+
+
+int __dundee_manager_init(void);
+void __dundee_manager_cleanup(void);
diff --git a/dundee/main.c b/dundee/main.c
index 0bee690..bb7800b 100644
--- a/dundee/main.c
+++ b/dundee/main.c
@@ -232,15 +232,12 @@ int main(int argc, char **argv)
 
__ofono_dbus_init(conn);
 
-   /*
-* The reason why this DBG is here is that we have the __stop__debug,
-* __start__debug linking symbols in the object. As soon we
-* have real DBG we can remove this one again.
-*/
-   DBG();
+   __dundee_manager_init();
 
g_main_loop_run(event_loop);
 
+   __dundee_manager_cleanup();
+
__ofono_dbus_cleanup();
dbus_connection_unref(conn);
 
diff --git a/dundee/manager.c b/dundee/manager.c
new file mode 100644
index 000..9ffe5c0
--- /dev/null
+++ b/dundee/manager.c
@@ -0,0 +1,97 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2011  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2012  BMW Car IT GmbH. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include config.h
+#endif
+
+#include string.h
+#include glib.h
+#include gdbus.h
+
+#include dundee.h
+
+static DBusMessage *manager_get_devices(DBusConnection *conn,
+   DBusMessage *msg, void *data)
+{
+   DBusMessage *reply;
+   DBusMessageIter iter;
+   DBusMessageIter array;
+
+   DBG();
+
+   reply = dbus_message_new_method_return(msg);
+   if (reply == NULL)
+   return NULL;
+
+   dbus_message_iter_init_append(reply, iter);
+
+   dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
+   DBUS_STRUCT_BEGIN_CHAR_AS_STRING
+   DBUS_TYPE_OBJECT_PATH_AS_STRING
+   DBUS_TYPE_ARRAY_AS_STRING
+   DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+   DBUS_TYPE_STRING_AS_STRING
+   DBUS_TYPE_VARIANT_AS_STRING
+   DBUS_DICT_ENTRY_END_CHAR_AS_STRING
+   DBUS_STRUCT_END_CHAR_AS_STRING,
+   array);
+
+   dbus_message_iter_close_container(iter, array);
+
+   return reply;
+}
+
+static GDBusMethodTable manager_methods[] = {
+   { GetDevices,  ,a(oa{sv}),  manager_get_devices },
+   { }
+};
+
+static GDBusSignalTable manager_signals[] = {
+   { DeviceAdded,oa{sv} },
+   { DeviceRemoved,  o },
+   { }
+};
+
+int __dundee_manager_init(void)
+{
+   DBusConnection *conn = ofono_dbus_get_connection();
+   gboolean ret;
+
+   ret = g_dbus_register_interface(conn, DUNDEE_MANAGER_PATH,
+   DUNDEE_MANAGER_INTERFACE

[PATCH v5 09/16] dundee: Add skeleton implementation for device

2012-01-04 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 Makefile.am |3 +-
 dundee/device.c |  100 +++
 dundee/dundee.h |   15 
 dundee/main.c   |4 ++-
 4 files changed, 120 insertions(+), 2 deletions(-)
 create mode 100644 dundee/device.c

diff --git a/Makefile.am b/Makefile.am
index 9b36970..5c3f6a2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -655,7 +655,8 @@ sbin_PROGRAMS += dundee/dundee
 
 dundee_dundee_SOURCES = $(gdbus_sources) \
src/log.c src/dbus.c \
-   dundee/main.c dundee/dbus.c dundee/manager.c
+   dundee/main.c dundee/dbus.c dundee/manager.c \
+   dundee/device.c
 
 dundee_dundee_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ 
-ldl
 
diff --git a/dundee/device.c b/dundee/device.c
new file mode 100644
index 000..1b89e97
--- /dev/null
+++ b/dundee/device.c
@@ -0,0 +1,100 @@
+/*
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2011  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2012  BMW Car IT GmbH. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include config.h
+#endif
+
+#include errno.h
+#include string.h
+#include stdio.h
+#include netinet/ether.h
+
+#include glib.h
+#include gdbus.h
+
+#include dundee.h
+
+static GHashTable *device_hash;
+
+struct dundee_device {
+};
+
+const char *__dundee_device_get_path(struct dundee_device *device)
+{
+   return /;
+}
+
+void __dundee_device_append_properties(struct dundee_device *device,
+   DBusMessageIter *dict)
+{
+}
+
+void __dundee_device_foreach(dundee_device_foreach_func func, void *userdata)
+{
+   GHashTableIter iter;
+   gpointer key, value;
+
+   DBG();
+
+   g_hash_table_iter_init(iter, device_hash);
+
+   while (g_hash_table_iter_next(iter, key, value) == TRUE) {
+   struct dundee_device *device = value;
+
+   func(device, userdata);
+   }
+}
+
+static void destroy_device(gpointer user)
+{
+   struct dundee_device *device = user;
+
+   g_free(device);
+}
+
+static void device_shutdown(gpointer key, gpointer value, gpointer user_data)
+{
+}
+
+void __dundee_device_shutdown(void)
+{
+   g_hash_table_foreach(device_hash, device_shutdown, NULL);
+
+   __dundee_exit();
+}
+
+int __dundee_device_init(void)
+{
+   DBG();
+
+   device_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
+   g_free, destroy_device);
+
+   return 0;
+}
+
+void __dundee_device_cleanup(void)
+{
+   DBG();
+
+   g_hash_table_destroy(device_hash);
+}
diff --git a/dundee/dundee.h b/dundee/dundee.h
index 82ab5f8..4fe801b 100644
--- a/dundee/dundee.h
+++ b/dundee/dundee.h
@@ -53,3 +53,18 @@ DBusMessage *__dundee_error_failed(DBusMessage *msg);
 
 int __dundee_manager_init(void);
 void __dundee_manager_cleanup(void);
+
+
+struct dundee_device;
+
+int __dundee_device_init(void);
+void __dundee_device_cleanup(void);
+void __dundee_device_shutdown(void);
+
+typedef void (*dundee_device_foreach_func)(struct dundee_device *device,
+   void *data);
+void __dundee_device_foreach(dundee_device_foreach_func cb, void *userdata);
+
+const char *__dundee_device_get_path(struct dundee_device *device);
+void __dundee_device_append_properties(struct dundee_device *device,
+   DBusMessageIter *dict);
diff --git a/dundee/main.c b/dundee/main.c
index bb7800b..c74a94d 100644
--- a/dundee/main.c
+++ b/dundee/main.c
@@ -80,7 +80,7 @@ static gboolean signal_handler(GIOChannel *channel, 
GIOCondition cond,
g_timeout_add_seconds(SHUTDOWN_GRACE_SECONDS,
quit_eventloop, NULL);
 
-   quit_eventloop(NULL);
+   __dundee_device_shutdown();
}
 
__terminated = 1;
@@ -233,9 +233,11 @@ int main(int argc, char **argv)
__ofono_dbus_init(conn);
 
__dundee_manager_init();
+   __dundee_device_init();
 
g_main_loop_run(event_loop);
 
+   __dundee_device_cleanup();
__dundee_manager_cleanup

[PATCH v5 10/16] dundee: Manager append devices

2012-01-04 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 dundee/manager.c |   22 ++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/dundee/manager.c b/dundee/manager.c
index 9ffe5c0..58a5804 100644
--- a/dundee/manager.c
+++ b/dundee/manager.c
@@ -30,6 +30,26 @@
 
 #include dundee.h
 
+static void append_device(struct dundee_device *device, void *userdata)
+{
+   DBusMessageIter *array = userdata;
+   const char *path = __dundee_device_get_path(device);
+   DBusMessageIter entry, dict;
+
+   dbus_message_iter_open_container(array, DBUS_TYPE_STRUCT,
+   NULL, entry);
+   dbus_message_iter_append_basic(entry, DBUS_TYPE_OBJECT_PATH,
+   path);
+   dbus_message_iter_open_container(entry, DBUS_TYPE_ARRAY,
+   OFONO_PROPERTIES_ARRAY_SIGNATURE,
+   dict);
+
+   __dundee_device_append_properties(device, dict);
+
+   dbus_message_iter_close_container(entry, dict);
+   dbus_message_iter_close_container(array, entry);
+}
+
 static DBusMessage *manager_get_devices(DBusConnection *conn,
DBusMessage *msg, void *data)
 {
@@ -56,6 +76,8 @@ static DBusMessage *manager_get_devices(DBusConnection *conn,
DBUS_STRUCT_END_CHAR_AS_STRING,
array);
 
+   __dundee_device_foreach(append_device, array);
+
dbus_message_iter_close_container(iter, array);
 
return reply;
-- 
1.7.8.2.302.g17b4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v5 11/16] dundee: Add callback helpers

2012-01-04 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 dundee/dundee.h |   44 
 1 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/dundee/dundee.h b/dundee/dundee.h
index 4fe801b..01edd53 100644
--- a/dundee/dundee.h
+++ b/dundee/dundee.h
@@ -28,6 +28,50 @@
 
 void __dundee_exit(void);
 
+enum dundee_error_type {
+   DUNDEE_ERROR_TYPE_NO_ERROR = 0,
+   DUNDEE_ERROR_TYPE_FAILURE,
+};
+
+struct dundee_error {
+   enum dundee_error_type type;
+   int error;
+};
+
+struct cb_data {
+   void *cb;
+   void *data;
+   void *user;
+};
+
+static inline struct cb_data *cb_data_new(void *cb, void *data)
+{
+   struct cb_data *ret;
+
+   ret = g_new0(struct cb_data, 1);
+   ret-cb = cb;
+   ret-data = data;
+
+   return ret;
+}
+
+#define CALLBACK_WITH_FAILURE(cb, args...) \
+   do {\
+   struct dundee_error cb_e;   \
+   cb_e.type = DUNDEE_ERROR_TYPE_FAILURE;  \
+   cb_e.error = 0; \
+   \
+   cb(cb_e, ##args);  \
+   } while (0) \
+
+#define CALLBACK_WITH_SUCCESS(f, args...)  \
+   do {\
+   struct dundee_error e;  \
+   e.type = DUNDEE_ERROR_TYPE_NO_ERROR;\
+   e.error = 0;\
+   f(e, ##args);  \
+   } while(0)  \
+
 #include ofono/log.h
 
 int __ofono_log_init(const char *program, const char *debug,
-- 
1.7.8.2.302.g17b4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v5 12/16] dundee: Add device un/register

2012-01-04 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 dundee/device.c |   69 ++-
 dundee/dundee.h |   21 
 2 files changed, 89 insertions(+), 1 deletions(-)

diff --git a/dundee/device.c b/dundee/device.c
index 1b89e97..bac8ead 100644
--- a/dundee/device.c
+++ b/dundee/device.c
@@ -33,14 +33,19 @@
 
 #include dundee.h
 
+static int next_device_id = 0;
 static GHashTable *device_hash;
 
 struct dundee_device {
+   char *path;
+   struct dundee_device_driver *driver;
+   gboolean registered;
+
 };
 
 const char *__dundee_device_get_path(struct dundee_device *device)
 {
-   return /;
+   return device-path;
 }
 
 void __dundee_device_append_properties(struct dundee_device *device,
@@ -64,15 +69,77 @@ void __dundee_device_foreach(dundee_device_foreach_func 
func, void *userdata)
}
 }
 
+static int register_device(struct dundee_device *device)
+{
+   return 0;
+}
+
+static int unregister_device(struct dundee_device *device)
+{
+   return 0;
+}
+
 static void destroy_device(gpointer user)
 {
struct dundee_device *device = user;
 
+   g_free(device-path);
+
g_free(device);
 }
 
+struct dundee_device *dundee_device_create(struct dundee_device_driver *d)
+{
+   struct dundee_device *device;
+
+   device = g_try_new0(struct dundee_device, 1);
+   if (device == NULL)
+   return NULL;
+
+   device-driver = d;
+
+   device-path = g_strdup_printf(/device%d, next_device_id);
+   if (device-path == NULL) {
+   g_free(device);
+   return NULL;
+   }
+
+   next_device_id += 1;
+
+   return device;
+}
+
+int dundee_device_register(struct dundee_device *device)
+{
+   int err;
+
+   err = register_device(device);
+   if (err  0)
+   return err;
+
+   device-registered = TRUE;
+
+   g_hash_table_insert(device_hash, g_strdup(device-path), device);
+
+   return 0;
+}
+
+void dundee_device_unregister(struct dundee_device *device)
+{
+   DBG(%p, device);
+
+   unregister_device(device);
+
+   device-registered = FALSE;
+
+   g_hash_table_remove(device_hash, device-path);
+}
+
 static void device_shutdown(gpointer key, gpointer value, gpointer user_data)
 {
+   struct dundee_device *device = value;
+
+   unregister_device(device);
 }
 
 void __dundee_device_shutdown(void)
diff --git a/dundee/dundee.h b/dundee/dundee.h
index 01edd53..a32eebf 100644
--- a/dundee/dundee.h
+++ b/dundee/dundee.h
@@ -105,6 +105,27 @@ int __dundee_device_init(void);
 void __dundee_device_cleanup(void);
 void __dundee_device_shutdown(void);
 
+typedef void (*dundee_device_connect_cb_t)(const struct dundee_error *error,
+   int fd, void *data);
+typedef void (*dundee_device_disconnect_cb_t)(const struct dundee_error *error,
+   void *data);
+
+struct dundee_device_driver {
+   const char *name;
+
+   /* Connect and dial */
+   void (*connect)(struct dundee_device *device,
+   dundee_device_connect_cb_t cb, void *data);
+
+   /* Hangup and disconnect */
+   void (*disconnect)(struct dundee_device *device,
+   dundee_device_disconnect_cb_t cb, void *data);
+};
+
+struct dundee_device *dundee_device_create(struct dundee_device_driver *d);
+int dundee_device_register(struct dundee_device *device);
+void dundee_device_unregister(struct dundee_device *device);
+
 typedef void (*dundee_device_foreach_func)(struct dundee_device *device,
void *data);
 void __dundee_device_foreach(dundee_device_foreach_func cb, void *userdata);
-- 
1.7.8.2.302.g17b4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v5 13/16] dundee: Add driver helper functions

2012-01-04 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 dundee/device.c |   18 ++
 dundee/dundee.h |5 +
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/dundee/device.c b/dundee/device.c
index bac8ead..6f2a7ea 100644
--- a/dundee/device.c
+++ b/dundee/device.c
@@ -41,6 +41,7 @@ struct dundee_device {
struct dundee_device_driver *driver;
gboolean registered;
 
+   void *data;
 };
 
 const char *__dundee_device_get_path(struct dundee_device *device)
@@ -135,6 +136,23 @@ void dundee_device_unregister(struct dundee_device *device)
g_hash_table_remove(device_hash, device-path);
 }
 
+void dundee_device_set_data(struct dundee_device *device, void *data)
+{
+   device-data = data;
+}
+
+void *dundee_device_get_data(struct dundee_device *device)
+{
+   return device-data;
+}
+
+int dundee_device_set_name(struct dundee_device *device, const char *name)
+{
+   DBG(%p name %s, device, name);
+
+   return 0;
+}
+
 static void device_shutdown(gpointer key, gpointer value, gpointer user_data)
 {
struct dundee_device *device = value;
diff --git a/dundee/dundee.h b/dundee/dundee.h
index a32eebf..5149f8b 100644
--- a/dundee/dundee.h
+++ b/dundee/dundee.h
@@ -126,6 +126,11 @@ struct dundee_device *dundee_device_create(struct 
dundee_device_driver *d);
 int dundee_device_register(struct dundee_device *device);
 void dundee_device_unregister(struct dundee_device *device);
 
+void dundee_device_set_data(struct dundee_device *device, void *data);
+void *dundee_device_get_data(struct dundee_device *device);
+
+int dundee_device_set_name(struct dundee_device *device, const char *name);
+
 typedef void (*dundee_device_foreach_func)(struct dundee_device *device,
void *data);
 void __dundee_device_foreach(dundee_device_foreach_func cb, void *userdata);
-- 
1.7.8.2.302.g17b4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v5 14/16] dundee: Add device D-Bus interface

2012-01-04 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 dundee/device.c |  221 +++
 dundee/dundee.h |1 +
 2 files changed, 222 insertions(+), 0 deletions(-)

diff --git a/dundee/device.c b/dundee/device.c
index 6f2a7ea..038bcc2 100644
--- a/dundee/device.c
+++ b/dundee/device.c
@@ -36,11 +36,21 @@
 static int next_device_id = 0;
 static GHashTable *device_hash;
 
+struct ipv4_settings {
+   char *interface;
+   char *ip;
+   char **nameservers;
+};
+
 struct dundee_device {
char *path;
struct dundee_device_driver *driver;
gboolean registered;
 
+   char *name;
+   gboolean active;
+   struct ipv4_settings settings;
+
void *data;
 };
 
@@ -49,9 +59,75 @@ const char *__dundee_device_get_path(struct dundee_device 
*device)
return device-path;
 }
 
+static void settings_append(struct dundee_device *device,
+   DBusMessageIter *iter)
+{
+   DBusMessageIter variant;
+   DBusMessageIter array;
+   char typesig[5];
+   char arraysig[6];
+
+   arraysig[0] = DBUS_TYPE_ARRAY;
+   arraysig[1] = typesig[0] = DBUS_DICT_ENTRY_BEGIN_CHAR;
+   arraysig[2] = typesig[1] = DBUS_TYPE_STRING;
+   arraysig[3] = typesig[2] = DBUS_TYPE_VARIANT;
+   arraysig[4] = typesig[3] = DBUS_DICT_ENTRY_END_CHAR;
+   arraysig[5] = typesig[4] = '\0';
+
+   dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
+   arraysig, variant);
+
+   dbus_message_iter_open_container(variant, DBUS_TYPE_ARRAY,
+   typesig, array);
+
+   if (device-active == FALSE)
+   goto out;
+
+   if (device-settings.interface)
+   ofono_dbus_dict_append(array, Interface,
+   DBUS_TYPE_STRING, device-settings.interface);
+
+   if (device-settings.ip)
+   ofono_dbus_dict_append(array, Address, DBUS_TYPE_STRING,
+   device-settings.ip);
+
+   if (device-settings.nameservers)
+   ofono_dbus_dict_append_array(array, DomainNameServers,
+   DBUS_TYPE_STRING,
+   device-settings.nameservers);
+
+out:
+   dbus_message_iter_close_container(variant, array);
+
+   dbus_message_iter_close_container(iter, variant);
+}
+
+static void settings_append_dict(struct dundee_device *device,
+   DBusMessageIter *dict)
+{
+   DBusMessageIter entry;
+   const char *key = Settings;
+
+   dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
+   NULL, entry);
+
+   dbus_message_iter_append_basic(entry, DBUS_TYPE_STRING, key);
+
+   settings_append(device, entry);
+
+   dbus_message_iter_close_container(dict, entry);
+}
+
 void __dundee_device_append_properties(struct dundee_device *device,
DBusMessageIter *dict)
 {
+   settings_append_dict(device, dict);
+
+   ofono_dbus_dict_append(dict, Name, DBUS_TYPE_STRING,
+   device-name);
+
+   ofono_dbus_dict_append(dict, Active, DBUS_TYPE_BOOLEAN,
+   device-active);
 }
 
 void __dundee_device_foreach(dundee_device_foreach_func func, void *userdata)
@@ -70,13 +146,141 @@ void __dundee_device_foreach(dundee_device_foreach_func 
func, void *userdata)
}
 }
 
+static DBusMessage *device_get_properties(DBusConnection *conn,
+   DBusMessage *msg, void *data)
+{
+   struct dundee_device *device = data;
+   DBusMessage *reply;
+   DBusMessageIter iter;
+   DBusMessageIter dict;
+
+   reply = dbus_message_new_method_return(msg);
+   if (reply == NULL)
+   return NULL;
+
+   dbus_message_iter_init_append(reply, iter);
+
+   dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
+   OFONO_PROPERTIES_ARRAY_SIGNATURE,
+   dict);
+
+   __dundee_device_append_properties(device, dict);
+
+   dbus_message_iter_close_container(iter, dict);
+
+   return reply;
+}
+
+static DBusMessage *set_property_active(struct dundee_device *device,
+   DBusMessage *msg,
+   DBusMessageIter *var)
+{
+   ofono_bool_t active;
+
+   DBG(%p path %s, device, device-path);
+
+   if (dbus_message_iter_get_arg_type(var) != DBUS_TYPE_BOOLEAN)
+   return __dundee_error_invalid_args(msg);
+
+   dbus_message_iter_get_basic(var, active);
+
+   device-active = active;
+
+   return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+}
+
+static DBusMessage *device_set_property(DBusConnection *conn

[PATCH v5 15/16] dundee: Add PPP handling code to device

2012-01-04 Thread Daniel Wagner
From: Daniel Wagner daniel.wag...@bmw-carit.de

---
 Makefile.am |2 +-
 dundee/device.c |  244 ++-
 2 files changed, 243 insertions(+), 3 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 5c3f6a2..6bc5d2b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -653,7 +653,7 @@ if DUNDEE
 
 sbin_PROGRAMS += dundee/dundee
 
-dundee_dundee_SOURCES = $(gdbus_sources) \
+dundee_dundee_SOURCES = $(gdbus_sources) $(gatchat_sources) \
src/log.c src/dbus.c \
dundee/main.c dundee/dbus.c dundee/manager.c \
dundee/device.c
diff --git a/dundee/device.c b/dundee/device.c
index 038bcc2..9a25ac1 100644
--- a/dundee/device.c
+++ b/dundee/device.c
@@ -30,12 +30,16 @@
 
 #include glib.h
 #include gdbus.h
+#include gatchat.h
+#include gatppp.h
 
 #include dundee.h
 
 static int next_device_id = 0;
 static GHashTable *device_hash;
 
+static const char *none_prefix[] = { NULL };
+
 struct ipv4_settings {
char *interface;
char *ip;
@@ -47,10 +51,14 @@ struct dundee_device {
struct dundee_device_driver *driver;
gboolean registered;
 
+   GAtPPP *ppp;
+   GAtChat *chat;
+
char *name;
gboolean active;
struct ipv4_settings settings;
 
+   DBusMessage *pending;
void *data;
 };
 
@@ -146,6 +154,27 @@ void __dundee_device_foreach(dundee_device_foreach_func 
func, void *userdata)
}
 }
 
+static void settings_changed(struct dundee_device *device)
+{
+   DBusConnection *conn = ofono_dbus_get_connection();
+   DBusMessage *signal;
+   DBusMessageIter iter;
+   const char *key = Settings;
+
+   signal = dbus_message_new_signal(device-path,
+   DUNDEE_DEVICE_INTERFACE,
+   PropertyChanged);
+
+   if (signal == NULL)
+   return;
+   dbus_message_iter_init_append(signal, iter);
+   dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, key);
+
+   settings_append(device, iter);
+
+   g_dbus_send_message(conn, signal);
+}
+
 static DBusMessage *device_get_properties(DBusConnection *conn,
DBusMessage *msg, void *data)
 {
@@ -171,6 +200,203 @@ static DBusMessage *device_get_properties(DBusConnection 
*conn,
return reply;
 }
 
+
+static void debug(const char *str, void *data)
+{
+   DBG(%s: %s\n, (const char *) data, str);
+}
+
+static void ppp_connect(const char *iface, const char *local, const char *peer,
+   const char *dns1, const char *dns2,
+   gpointer user_data)
+{
+   DBusConnection *conn = ofono_dbus_get_connection();
+   struct dundee_device *device = user_data;
+   const char *dns[3] = { dns1, dns2, 0 };
+
+   DBG(%p, device);
+   DBG(Network Device: %s\n, iface);
+   DBG(IP Address: %s\n, local);
+   DBG(Peer IP Address: %s\n, peer);
+   DBG(Primary DNS Server: %s\n, dns1);
+   DBG(Secondary DNS Server: %s\n, dns2);
+
+   g_free(device-settings.interface);
+   device-settings.interface = g_strdup(iface);
+   if (device-settings.interface == NULL)
+   goto err;
+
+   g_free(device-settings.ip);
+   device-settings.ip = g_strdup(local);
+   if (device-settings.ip == NULL)
+   goto err;
+
+   g_strfreev(device-settings.nameservers);
+   device-settings.nameservers = g_strdupv((gchar **)dns);
+   if (device-settings.nameservers == NULL)
+   goto err;
+
+   device-active = TRUE;
+
+   settings_changed(device);
+   ofono_dbus_signal_property_changed(conn, device-path,
+   DUNDEE_DEVICE_INTERFACE, Active,
+   DBUS_TYPE_BOOLEAN, device-active);
+
+   return;
+
+err:
+   g_free(device-settings.interface);
+   g_free(device-settings.ip);
+   g_strfreev(device-settings.nameservers);
+   device-settings.interface = NULL;
+   device-settings.ip = NULL;
+   device-settings.nameservers = NULL;
+}
+
+static void disconnect_callback(const struct dundee_error *error, void *data)
+{
+   struct dundee_device *device = data;
+
+   DBG(%p, device);
+
+   g_at_chat_unref(device-chat);
+   device-chat = NULL;
+
+   if (device-pending == NULL)
+   return;
+
+   if (error-type != DUNDEE_ERROR_TYPE_NO_ERROR) {
+   __ofono_dbus_pending_reply(device-pending,
+   __dundee_error_failed(device-pending));
+   goto out;
+   }
+
+   __ofono_dbus_pending_reply(device-pending,
+   dbus_message_new_method_return(device-pending));
+
+out:
+   device-pending = NULL;
+}
+
+static void ppp_disconnect(GAtPPPDisconnectReason reason, gpointer user_data)
+{
+   DBusConnection *conn = ofono_dbus_get_connection

  1   2   3   >