Add ActiveSync networking support

This commit is contained in:
Marcel Holtmann 2005-08-21 08:56:10 +00:00
parent ad0ddadb14
commit 7d463a7ae8
7 changed files with 105 additions and 53 deletions

View File

@ -3,7 +3,7 @@
* BlueZ - Bluetooth protocol stack for Linux
*
* Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com>
* Copyright (C) 2002-2004 Marcel Holtmann <marcel@holtmann.org>
* Copyright (C) 2002-2005 Marcel Holtmann <marcel@holtmann.org>
*
*
* This program is free software; you can redistribute it and/or modify

View File

@ -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

View File

@ -3,7 +3,7 @@
* BlueZ - Bluetooth protocol stack for Linux
*
* Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com>
* Copyright (C) 2002-2004 Marcel Holtmann <marcel@holtmann.org>
* Copyright (C) 2002-2005 Marcel Holtmann <marcel@holtmann.org>
*
*
* 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);

View File

@ -3,7 +3,7 @@
* BlueZ - Bluetooth protocol stack for Linux
*
* Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com>
* Copyright (C) 2002-2004 Marcel Holtmann <marcel@holtmann.org>
* Copyright (C) 2002-2005 Marcel Holtmann <marcel@holtmann.org>
*
*
* This program is free software; you can redistribute it and/or modify

View File

@ -3,7 +3,7 @@
* BlueZ - Bluetooth protocol stack for Linux
*
* Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com>
* Copyright (C) 2002-2004 Marcel Holtmann <marcel@holtmann.org>
* Copyright (C) 2002-2005 Marcel Holtmann <marcel@holtmann.org>
*
*
* 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 <pppd> 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':

View File

@ -3,7 +3,7 @@
* BlueZ - Bluetooth protocol stack for Linux
*
* Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com>
* Copyright (C) 2002-2004 Marcel Holtmann <marcel@holtmann.org>
* Copyright (C) 2002-2005 Marcel Holtmann <marcel@holtmann.org>
*
*
* This program is free software; you can redistribute it and/or modify

View File

@ -3,7 +3,7 @@
* BlueZ - Bluetooth protocol stack for Linux
*
* Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com>
* Copyright (C) 2002-2004 Marcel Holtmann <marcel@holtmann.org>
* Copyright (C) 2002-2005 Marcel Holtmann <marcel@holtmann.org>
*
*
* 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;