summaryrefslogtreecommitdiffstats
path: root/sdpd
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2007-05-22 11:43:30 +0000
committerMarcel Holtmann <marcel@holtmann.org>2007-05-22 11:43:30 +0000
commit09e129d5ef90ad61775517e752b8b9918f1a7c3e (patch)
tree10d5f0cb124ab58c658d6b0ae0f9890da58d41f0 /sdpd
parent646f2140653faca517ecd55863e15e4d9dffc4af (diff)
Minimize SDP root records and browse groups
Diffstat (limited to 'sdpd')
-rw-r--r--sdpd/main.c7
-rw-r--r--sdpd/sdpd.82
-rw-r--r--sdpd/sdpd.h5
-rw-r--r--sdpd/server.c9
-rw-r--r--sdpd/service.c83
5 files changed, 17 insertions, 89 deletions
diff --git a/sdpd/main.c b/sdpd/main.c
index 856c6cb3..0abc8088 100644
--- a/sdpd/main.c
+++ b/sdpd/main.c
@@ -68,7 +68,6 @@ static struct option main_options[] = {
{ "help", 0, 0, 'h' },
{ "nodaemon", 0, 0, 'n' },
{ "mtu", 1, 0, 'm' },
- { "public", 0, 0, 'p' },
{ "master", 0, 0, 'M' },
{ 0, 0, 0, 0}
};
@@ -80,7 +79,7 @@ int main(int argc, char *argv[])
uint32_t flags = SDP_SERVER_COMPAT;
int opt, daemonize = 1, debug = 0;
- while ((opt = getopt_long(argc, argv, "ndm:pM", main_options, NULL)) != -1) {
+ while ((opt = getopt_long(argc, argv, "ndm:M", main_options, NULL)) != -1) {
switch (opt) {
case 'n':
daemonize = 0;
@@ -94,10 +93,6 @@ int main(int argc, char *argv[])
mtu = atoi(optarg);
break;
- case 'p':
- flags |= SDP_SERVER_PUBLIC;
- break;
-
case 'M':
flags |= SDP_SERVER_MASTER;
break;
diff --git a/sdpd/sdpd.8 b/sdpd/sdpd.8
index 3b69430d..e23c6ffc 100644
--- a/sdpd/sdpd.8
+++ b/sdpd/sdpd.8
@@ -70,8 +70,6 @@ Don't detach from the controlling terminal.
Enable debugging output.
.IP "\fB-m <mtu>\fP" 10
Set maximum MTU to use on the L2CAP channel.
-.IP "\fB-p\fP" 10
-Register server record in public browse group.
.SH "BUGS"
.PP
diff --git a/sdpd/sdpd.h b/sdpd/sdpd.h
index 31f3b645..d3d45b85 100644
--- a/sdpd/sdpd.h
+++ b/sdpd/sdpd.h
@@ -44,8 +44,8 @@ int service_register_req(sdp_req_t *req, sdp_buf_t *rsp);
int service_update_req(sdp_req_t *req, sdp_buf_t *rsp);
int service_remove_req(sdp_req_t *req, sdp_buf_t *rsp);
-void register_public_browse_group(int public);
-void register_server_service(int public);
+void register_public_browse_group(void);
+void register_server_service(void);
void register_device_id(const uint16_t vendor, const uint16_t product,
const uint16_t version);
@@ -80,7 +80,6 @@ uint32_t sdp_get_time();
#define SDP_SERVER_COMPAT (1 << 0)
#define SDP_SERVER_MASTER (1 << 1)
-#define SDP_SERVER_PUBLIC (1 << 2)
int start_sdp_server(uint16_t mtu, const char *did, uint32_t flags);
void stop_sdp_server(void);
diff --git a/sdpd/server.c b/sdpd/server.c
index fab17f00..2750dec2 100644
--- a/sdpd/server.c
+++ b/sdpd/server.c
@@ -57,7 +57,7 @@ static int l2cap_sock, unix_sock;
* l2cap and unix sockets over which discovery and registration clients
* access us respectively
*/
-static int init_server(uint16_t mtu, int master, int public, int compat)
+static int init_server(uint16_t mtu, int master, int compat)
{
struct l2cap_options opts;
struct sockaddr_l2 l2addr;
@@ -65,10 +65,10 @@ static int init_server(uint16_t mtu, int master, int public, int compat)
socklen_t optlen;
/* Register the public browse group root */
- register_public_browse_group(public);
+ register_public_browse_group();
/* Register the SDP server's service record */
- register_server_service(public);
+ register_server_service();
/* Create L2CAP socket */
l2cap_sock = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP);
@@ -220,11 +220,10 @@ int start_sdp_server(uint16_t mtu, const char *did, uint32_t flags)
{
int compat = flags & SDP_SERVER_COMPAT;
int master = flags & SDP_SERVER_MASTER;
- int public = flags & SDP_SERVER_PUBLIC;
info("Starting SDP server");
- if (init_server(mtu, master, public, compat) < 0) {
+ if (init_server(mtu, master, compat) < 0) {
error("Server initialization failed");
return -1;
}
diff --git a/sdpd/service.c b/sdpd/service.c
index 50df26e8..8c48555b 100644
--- a/sdpd/service.c
+++ b/sdpd/service.c
@@ -69,53 +69,27 @@ static void update_db_timestamp(void)
sdp_attr_replace(server, SDP_ATTR_SVCDB_STATE, d);
}
-static void add_lang_attr(sdp_record_t *r)
-{
- sdp_lang_attr_t base_lang;
- sdp_list_t *langs = 0;
-
- base_lang.code_ISO639 = (0x65 << 8) | 0x6e;
- // UTF-8 MIBenum (http://www.iana.org/assignments/character-sets)
- base_lang.encoding = 106;
- base_lang.base_offset = SDP_PRIMARY_LANG_BASE;
- langs = sdp_list_append(0, &base_lang);
- sdp_set_lang_attr(r, langs);
- sdp_list_free(langs, 0);
-}
-
-void register_public_browse_group(int public)
+void register_public_browse_group(void)
{
sdp_list_t *browselist;
uuid_t bgscid, pbgid;
sdp_data_t *sdpdata;
sdp_record_t *browse = sdp_record_alloc();
- if (public) {
- browse->handle = sdp_next_handle();
- if (browse->handle < 0x10000)
- return;
- } else
- browse->handle = SDP_SERVER_RECORD_HANDLE + 1;
+ browse->handle = SDP_SERVER_RECORD_HANDLE + 1;
sdp_record_add(BDADDR_ANY, browse);
sdpdata = sdp_data_alloc(SDP_UINT32, &browse->handle);
sdp_attr_add(browse, SDP_ATTR_RECORD_HANDLE, sdpdata);
- add_lang_attr(browse);
- sdp_set_info_attr(browse, "Public Browse Group Root", "BlueZ",
- "Root of public browse hierarchy");
-
sdp_uuid16_create(&bgscid, BROWSE_GRP_DESC_SVCLASS_ID);
browselist = sdp_list_append(0, &bgscid);
sdp_set_service_classes(browse, browselist);
sdp_list_free(browselist, 0);
- if (public)
- sdp_uuid16_create(&pbgid, PUBLIC_BROWSE_GROUP);
- else
- sdp_uuid16_create(&pbgid, BROWSE_GRP_DESC_SVCLASS_ID);
-
- sdp_set_group_id(browse, pbgid);
+ sdp_uuid16_create(&pbgid, PUBLIC_BROWSE_GROUP);
+ sdp_attr_add_new(browse, SDP_ATTR_GROUP_ID,
+ SDP_UUID16, &pbgid.value.uuid16);
}
/*
@@ -124,17 +98,14 @@ void register_public_browse_group(int public)
* discovery clients. This method constructs a service record
* and stores it in the repository
*/
-void register_server_service(int public)
+void register_server_service(void)
{
- int i;
- sdp_list_t *classIDList, *browseList;
- sdp_list_t *access_proto = 0;
- uuid_t l2cap, classID, browseGroupId, sdpSrvUUID;
+ sdp_list_t *classIDList;
+ uuid_t classID;
void **versions, **versionDTDs;
uint8_t dtd;
- uint16_t version, port;
- sdp_data_t *pData, *port_data, *version_data;
- sdp_list_t *pd, *seq;
+ sdp_data_t *pData;
+ int i;
server = sdp_record_alloc();
server->pattern = NULL;
@@ -146,13 +117,6 @@ void register_server_service(int public)
sdp_attr_add(server, SDP_ATTR_RECORD_HANDLE,
sdp_data_alloc(SDP_UINT32, &server->handle));
- /*
- * Add all attributes to service record. (No need to commit since we
- * are the server and this record is already in the database.)
- */
- add_lang_attr(server);
- sdp_set_info_attr(server, "SDP Server", "BlueZ", "Bluetooth service discovery server");
-
sdp_uuid16_create(&classID, SDP_SERVER_SVCLASS_ID);
classIDList = sdp_list_append(0, &classID);
sdp_set_service_classes(server, classIDList);
@@ -181,33 +145,6 @@ void register_server_service(int public)
free(versionDTDs);
sdp_attr_add(server, SDP_ATTR_VERSION_NUM_LIST, pData);
- sdp_uuid16_create(&sdpSrvUUID, SDP_UUID);
- sdp_set_service_id(server, sdpSrvUUID);
-
- sdp_uuid16_create(&l2cap, L2CAP_UUID);
- pd = sdp_list_append(0, &l2cap);
- port = SDP_PSM;
- port_data = sdp_data_alloc(SDP_UINT16, &port);
- pd = sdp_list_append(pd, port_data);
- version = 1;
- version_data = sdp_data_alloc(SDP_UINT16, &version);
- pd = sdp_list_append(pd, version_data);
- seq = sdp_list_append(0, pd);
-
- access_proto = sdp_list_append(0, seq);
- sdp_set_access_protos(server, access_proto);
- sdp_list_free(access_proto, free);
- sdp_data_free(port_data);
- sdp_data_free(version_data);
- sdp_list_free(pd, 0);
-
- if (public) {
- sdp_uuid16_create(&browseGroupId, PUBLIC_BROWSE_GROUP);
- browseList = sdp_list_append(0, &browseGroupId);
- sdp_set_browse_groups(server, browseList);
- sdp_list_free(browseList, 0);
- }
-
update_db_timestamp();
}