3 * BlueZ - Bluetooth protocol stack for Linux
5 * Copyright (C) 2003-2010 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
32 #include <sys/socket.h>
34 #include <bluetooth/bluetooth.h>
35 #include <bluetooth/sdp.h>
36 #include <bluetooth/sdp_lib.h>
40 int sdp_search_hcrp(sdp_session_t *sdp, unsigned short *ctrl_psm, unsigned short *data_psm)
42 sdp_list_t *srch, *attrs, *rsp;
44 uint16_t attr1, attr2;
50 sdp_uuid16_create(&svclass, HCR_PRINT_SVCLASS_ID);
51 srch = sdp_list_append(NULL, &svclass);
53 attr1 = SDP_ATTR_PROTO_DESC_LIST;
54 attrs = sdp_list_append(NULL, &attr1);
55 attr2 = SDP_ATTR_ADD_PROTO_DESC_LIST;
56 attrs = sdp_list_append(attrs, &attr2);
58 err = sdp_service_search_attr_req(sdp, srch, SDP_ATTR_REQ_INDIVIDUAL, attrs, &rsp);
62 for (; rsp; rsp = rsp->next) {
63 sdp_record_t *rec = (sdp_record_t *) rsp->data;
66 if (!sdp_get_access_protos(rec, &protos)) {
67 unsigned short psm = sdp_get_proto_port(protos, L2CAP_UUID);
73 if (!sdp_get_add_access_protos(rec, &protos)) {
74 unsigned short psm = sdp_get_proto_port(protos, L2CAP_UUID);
75 if (psm > 0 && *ctrl_psm > 0) {
85 int sdp_search_spp(sdp_session_t *sdp, uint8_t *channel)
87 sdp_list_t *srch, *attrs, *rsp;
95 sdp_uuid16_create(&svclass, SERIAL_PORT_SVCLASS_ID);
96 srch = sdp_list_append(NULL, &svclass);
98 attr = SDP_ATTR_PROTO_DESC_LIST;
99 attrs = sdp_list_append(NULL, &attr);
101 err = sdp_service_search_attr_req(sdp, srch, SDP_ATTR_REQ_INDIVIDUAL, attrs, &rsp);
105 for (; rsp; rsp = rsp->next) {
106 sdp_record_t *rec = (sdp_record_t *) rsp->data;
109 if (!sdp_get_access_protos(rec, &protos)) {
110 uint8_t ch = sdp_get_proto_port(protos, RFCOMM_UUID);