diff --git a/dund/dun.c b/dund/dun.c index 0593cb854..d5724cfbe 100644 --- a/dund/dun.c +++ b/dund/dun.c @@ -3,7 +3,7 @@ * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2002-2003 Maxim Krasnyansky - * Copyright (C) 2002-2004 Marcel Holtmann + * Copyright (C) 2002-2005 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify diff --git a/dund/dund.1 b/dund/dund.1 index 2056b145c..895fc97a4 100644 --- a/dund/dund.1 +++ b/dund/dund.1 @@ -62,6 +62,8 @@ Location of the PPP daemon (pppd) \fB\-\-msdun\fR \fB\-X\fR [timeo] Enable Microsoft dialup networking support .TP +\fB\-\-activesync\fR \fB\-a\fR +Enable Microsoft ActiveSync networking +.TP \fB\-\-cache\fR \fB\-C\fR [valid] Enable address cache - diff --git a/dund/dund.h b/dund/dund.h index 97c541747..f2a9b026f 100644 --- a/dund/dund.h +++ b/dund/dund.h @@ -3,7 +3,7 @@ * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2002-2003 Maxim Krasnyansky - * Copyright (C) 2002-2004 Marcel Holtmann + * Copyright (C) 2002-2005 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify @@ -28,11 +28,16 @@ */ /* DUN scripts & commands */ -#define DUN_CONFIG_DIR "/etc/bluetooth/dun" +#define DUN_CONFIG_DIR "/etc/bluetooth/dun" -#define DUN_DEFAULT_CHANNEL 1 +#define DUN_DEFAULT_CHANNEL 1 -#define DUN_MAX_PPP_OPTS 40 +#define DUN_MAX_PPP_OPTS 40 + +/* DUN types */ +#define LANACCESS 0 +#define MROUTER 1 +#define ACTIVESYNC 2 /* DUN functions */ int dun_init(void); @@ -45,6 +50,6 @@ int dun_kill_all_connections(void); int dun_open_connection(int sk, char *pppd, char **pppd_opts, int wait); /* SDP functions */ -int dun_sdp_register(bdaddr_t *device, uint8_t channel, int mrouter); +int dun_sdp_register(bdaddr_t *device, uint8_t channel, int type); void dun_sdp_unregister(void); -int dun_sdp_search(bdaddr_t *src, bdaddr_t *dst, int *channel, int mrouter); +int dun_sdp_search(bdaddr_t *src, bdaddr_t *dst, int *channel, int type); diff --git a/dund/lib.h b/dund/lib.h index 3835d41c3..c9b0f0a43 100644 --- a/dund/lib.h +++ b/dund/lib.h @@ -3,7 +3,7 @@ * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2002-2003 Maxim Krasnyansky - * Copyright (C) 2002-2004 Marcel Holtmann + * Copyright (C) 2002-2005 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify diff --git a/dund/main.c b/dund/main.c index 83be167c6..e58e382b6 100644 --- a/dund/main.c +++ b/dund/main.c @@ -3,7 +3,7 @@ * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2002-2003 Maxim Krasnyansky - * Copyright (C) 2002-2004 Marcel Holtmann + * Copyright (C) 2002-2005 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify @@ -74,7 +74,7 @@ static int auth; static int encrypt; static int secure; static int master; -static int mrouter; +static int type = LANACCESS; static int search_duration = 10; static uint use_cache; @@ -107,11 +107,11 @@ static int do_listen(void) struct sockaddr_rc sa; int sk, lm; - if (mrouter) { + if (type == MROUTER) { if (!cache.valid) return -1; - if (create_connection(cache.dst, &cache.bdaddr, mrouter) < 0) { + if (create_connection(cache.dst, &cache.bdaddr, type) < 0) { syslog(LOG_ERR, "Cannot connect to mRouter device. %s(%d)", strerror(errno), errno); return -1; @@ -122,9 +122,9 @@ static int do_listen(void) channel = DUN_DEFAULT_CHANNEL; if (use_sdp) - dun_sdp_register(&src_addr, channel, mrouter); + dun_sdp_register(&src_addr, channel, type); - if (mrouter) + if (type == MROUTER) syslog(LOG_INFO, "Waiting for mRouter callback on channel %d", channel); /* Create RFCOMM socket */ @@ -181,7 +181,7 @@ static int do_listen(void) syslog(LOG_ERR, "Fork failed. %s(%d)", strerror(errno), errno); default: close(nsk); - if (mrouter) { + if (type == MROUTER) { close(sk); terminate = 1; } @@ -381,31 +381,32 @@ void sig_term(int sig) } static struct option main_lopts[] = { - { "help", 0, 0, 'h' }, - { "listen", 0, 0, 's' }, - { "connect", 1, 0, 'c' }, - { "search", 2, 0, 'Q' }, - { "kill", 1, 0, 'k' }, - { "killall", 0, 0, 'K' }, - { "channel", 1, 0, 'P' }, - { "device", 1, 0, 'i' }, - { "nosdp", 0, 0, 'D' }, - { "list", 0, 0, 'l' }, - { "show", 0, 0, 'l' }, - { "nodetach", 0, 0, 'n' }, - { "persist", 2, 0, 'p' }, - { "auth", 0, 0, 'A' }, - { "encrypt", 0, 0, 'E' }, - { "secure", 0, 0, 'S' }, - { "master", 0, 0, 'M' }, - { "cache", 0, 0, 'C' }, - { "pppd", 1, 0, 'd' }, - { "msdun", 2, 0, 'X' }, - { "mrouter", 1, 0, 'm' }, + { "help", 0, 0, 'h' }, + { "listen", 0, 0, 's' }, + { "connect", 1, 0, 'c' }, + { "search", 2, 0, 'Q' }, + { "kill", 1, 0, 'k' }, + { "killall", 0, 0, 'K' }, + { "channel", 1, 0, 'P' }, + { "device", 1, 0, 'i' }, + { "nosdp", 0, 0, 'D' }, + { "list", 0, 0, 'l' }, + { "show", 0, 0, 'l' }, + { "nodetach", 0, 0, 'n' }, + { "persist", 2, 0, 'p' }, + { "auth", 0, 0, 'A' }, + { "encrypt", 0, 0, 'E' }, + { "secure", 0, 0, 'S' }, + { "master", 0, 0, 'M' }, + { "cache", 0, 0, 'C' }, + { "pppd", 1, 0, 'd' }, + { "msdun", 2, 0, 'X' }, + { "activesync", 0, 0, 'a' }, + { "mrouter", 1, 0, 'm' }, { 0, 0, 0, 0 } }; -static char main_sopts[] = "hsc:k:Kr:i:lnp::DQ::AESMP:C::P:X"; +static char main_sopts[] = "hsc:k:Kr:i:lnp::DQ::AESMP:C::P:Xa"; static char main_help[] = "Bluetooth LAP (LAN Access over PPP) daemon version " VERSION " \n" @@ -430,6 +431,7 @@ static char main_help[] = "\t--persist -p[interval] Persist mode\n" "\t--pppd -d Location of the PPP daemon (pppd)\n" "\t--msdun -X[timeo] Enable Microsoft dialup networking support\n" + "\t--activesync -a Enable Microsoft ActiveSync networking\n" "\t--cache -C[valid] Enable address cache\n"; int main(int argc, char **argv) @@ -531,10 +533,15 @@ int main(int argc, char **argv) msdun = 10; break; + case 'a': + msdun = 10; + type = ACTIVESYNC; + break; + case 'm': mode = LISTEN; dst = strdup(optarg); - mrouter = 1; + type = MROUTER; break; case 'h': diff --git a/dund/msdun.c b/dund/msdun.c index 207497609..f035971b1 100644 --- a/dund/msdun.c +++ b/dund/msdun.c @@ -3,7 +3,7 @@ * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2002-2003 Maxim Krasnyansky - * Copyright (C) 2002-2004 Marcel Holtmann + * Copyright (C) 2002-2005 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify diff --git a/dund/sdp.c b/dund/sdp.c index 16ef09f43..74cafb555 100644 --- a/dund/sdp.c +++ b/dund/sdp.c @@ -3,7 +3,7 @@ * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2002-2003 Maxim Krasnyansky - * Copyright (C) 2002-2004 Marcel Holtmann + * Copyright (C) 2002-2005 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify @@ -46,6 +46,9 @@ #include "dund.h" +static unsigned char async_uuid[] = { 0x03, 0x50, 0x27, 0x8F, 0x3D, 0xCA, 0x4E, 0x62, + 0x83, 0x1D, 0xA4, 0x11, 0x65, 0xFF, 0x90, 0x6C }; + static sdp_record_t *record; static sdp_session_t *session; @@ -56,7 +59,7 @@ void dun_sdp_unregister(void) sdp_close(session); } -int dun_sdp_register(bdaddr_t *device, uint8_t channel, int mrouter) +int dun_sdp_register(bdaddr_t *device, uint8_t channel, int type) { sdp_list_t *svclass, *pfseq, *apseq, *root, *aproto; uuid_t root_uuid, l2cap, rfcomm, dun; @@ -93,27 +96,51 @@ int dun_sdp_register(bdaddr_t *device, uint8_t channel, int mrouter) aproto = sdp_list_append(NULL, apseq); sdp_set_access_protos(record, aproto); - sdp_uuid16_create(&dun, mrouter ? SERIAL_PORT_SVCLASS_ID : LAN_ACCESS_SVCLASS_ID); + switch (type) { + case MROUTER: + sdp_uuid16_create(&dun, SERIAL_PORT_SVCLASS_ID); + break; + case ACTIVESYNC: + sdp_uuid128_create(&dun, (void *) async_uuid); + break; + default: + sdp_uuid16_create(&dun, LAN_ACCESS_SVCLASS_ID); + break; + } + svclass = sdp_list_append(NULL, &dun); sdp_set_service_classes(record, svclass); - sdp_uuid16_create(&profile[0].uuid, mrouter ? SERIAL_PORT_PROFILE_ID : LAN_ACCESS_PROFILE_ID); - profile[0].version = 0x0100; - pfseq = sdp_list_append(NULL, &profile[0]); - sdp_set_profile_descs(record, pfseq); - - sdp_set_info_attr(record, mrouter ? "mRouter" : "LAN Access Point", NULL, NULL); + if (type == LANACCESS) { + sdp_uuid16_create(&profile[0].uuid, LAN_ACCESS_PROFILE_ID); + profile[0].version = 0x0100; + pfseq = sdp_list_append(NULL, &profile[0]); + sdp_set_profile_descs(record, pfseq); + } + + switch (type) { + case MROUTER: + sdp_set_info_attr(record, "mRouter", NULL, NULL); + break; + case ACTIVESYNC: + sdp_set_info_attr(record, "ActiveSync", NULL, NULL); + break; + default: + sdp_set_info_attr(record, "LAN Access Point", NULL, NULL); + break; + } status = sdp_device_record_register(session, device, record, 0); if (status) { syslog(LOG_ERR, "SDP registration failed."); - sdp_record_free(record); record = NULL; + sdp_record_free(record); + record = NULL; return -1; } return 0; } -int dun_sdp_search(bdaddr_t *src, bdaddr_t *dst, int *channel, int mrouter) +int dun_sdp_search(bdaddr_t *src, bdaddr_t *dst, int *channel, int type) { sdp_session_t *s; sdp_list_t *srch, *attrs, *rsp; @@ -128,7 +155,18 @@ int dun_sdp_search(bdaddr_t *src, bdaddr_t *dst, int *channel, int mrouter) return -1; } - sdp_uuid16_create(&svclass, mrouter ? SERIAL_PORT_SVCLASS_ID : LAN_ACCESS_SVCLASS_ID); + switch (type) { + case MROUTER: + sdp_uuid16_create(&svclass, SERIAL_PORT_SVCLASS_ID); + break; + case ACTIVESYNC: + sdp_uuid128_create(&svclass, (void *) async_uuid); + break; + default: + sdp_uuid16_create(&svclass, LAN_ACCESS_SVCLASS_ID); + break; + } + srch = sdp_list_append(NULL, &svclass); attr = SDP_ATTR_PROTO_DESC_LIST; @@ -137,7 +175,7 @@ int dun_sdp_search(bdaddr_t *src, bdaddr_t *dst, int *channel, int mrouter) err = sdp_service_search_attr_req(s, srch, SDP_ATTR_REQ_INDIVIDUAL, attrs, &rsp); sdp_close(s); - + if (err) return 0;