3
* BlueZ - Bluetooth protocol stack for Linux
5
* Copyright (C) 2004-2009 Marcel Holtmann <marcel@holtmann.org>
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2 of the License, or
11
* (at your option) any later version.
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with this program; if not, write to the Free Software
20
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
33
#include <sys/param.h>
35
#include <bluetooth/bluetooth.h>
36
#include <bluetooth/sdp.h>
37
#include <bluetooth/sdp_lib.h>
46
int port_delete(bdaddr_t *src, bdaddr_t *dst, int16_t id)
48
char filename[PATH_MAX + 1];
49
char src_addr[18], dst_addr[18];
52
ba2str(src, src_addr);
53
ba2str(dst, dst_addr);
55
create_name(filename, PATH_MAX, STORAGEDIR, src_addr, "serial");
56
snprintf(key, sizeof(key), "%s#%hd", dst_addr, id);
58
return textfile_del(filename, key);
61
int port_store(bdaddr_t *src, bdaddr_t *dst, int16_t id,
62
uint8_t ch, const char *svcname)
64
char filename[PATH_MAX + 1];
65
char src_addr[18], dst_addr[18];
71
svcname = "Bluetooth RFCOMM port";
73
ba2str(src, src_addr);
74
ba2str(dst, dst_addr);
76
create_name(filename, PATH_MAX, STORAGEDIR, src_addr, "serial");
77
create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
79
size = strlen(svcname) + 5;
80
value = g_malloc0(size);
82
snprintf(key, 32, "%s#%hd", dst_addr, id);
83
snprintf(value, size, "%d:%s", ch, svcname);
85
err = textfile_put(filename, key, value);
91
int proxy_delete(bdaddr_t *src, const char *tty)
93
char filename[PATH_MAX + 1], src_addr[18];
95
ba2str(src, src_addr);
97
create_name(filename, PATH_MAX, STORAGEDIR, src_addr, "proxy");
99
return textfile_del(filename, tty);
102
int proxy_store(bdaddr_t *src, const char *uuid, const char *tty,
103
const char *name, uint8_t ch, int opts, struct termios *ti)
105
char filename[PATH_MAX + 1], key[32], src_addr[18], *value;
110
ba2str(src, src_addr);
112
create_name(filename, PATH_MAX, STORAGEDIR, src_addr, "proxy");
113
create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
116
name = "Port Proxy Entity";
118
size = MAX_LEN_UUID_STR + 16 + strlen(name) + sizeof(struct termios) * 2;
119
value = g_malloc0(size);
121
snprintf(key, 32, "%s", tty);
123
/* tty uuid 00 0x0000 name:termios */
124
pos = snprintf(value, size, "%s %d 0x%04X %s:", uuid, ch, opts, name);
129
for (i = 0, pti = (uint8_t *) ti; i < sizeof(struct termios); i++, pti++)
130
sprintf(value + pos + (i * 2), "%2.2X", *pti);
133
err = textfile_put(filename, key, value);