diff options
Diffstat (limited to 'usr.sbin/bluetooth')
-rw-r--r-- | usr.sbin/bluetooth/sdpd/gn.c | 30 | ||||
-rw-r--r-- | usr.sbin/bluetooth/sdpd/lan.c | 9 | ||||
-rw-r--r-- | usr.sbin/bluetooth/sdpd/nap.c | 30 | ||||
-rw-r--r-- | usr.sbin/bluetooth/sdpd/panu.c | 30 | ||||
-rw-r--r-- | usr.sbin/bluetooth/sdpd/profile.c | 25 | ||||
-rw-r--r-- | usr.sbin/bluetooth/sdpd/profile.h | 1 |
6 files changed, 110 insertions, 15 deletions
diff --git a/usr.sbin/bluetooth/sdpd/gn.c b/usr.sbin/bluetooth/sdpd/gn.c index 618388d..d35c0ee 100644 --- a/usr.sbin/bluetooth/sdpd/gn.c +++ b/usr.sbin/bluetooth/sdpd/gn.c @@ -100,8 +100,12 @@ gn_profile_create_protocol_descriptor_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { + provider_p provider = (provider_p) data; + sdp_gn_profile_p gn = (sdp_gn_profile_p) provider->data; + return (bnep_profile_create_protocol_descriptor_list( - buf, eob, NULL, 0)); + buf, eob, (uint8_t const *) &gn->psm, + sizeof(gn->psm))); } static int32_t @@ -117,6 +121,26 @@ gn_profile_create_security_description( sizeof(gn->security_description))); } +static int32_t +gn_profile_create_service_availability( + uint8_t *buf, uint8_t const * const eob, + uint8_t const *data, uint32_t datalen) +{ + provider_p provider = (provider_p) data; + sdp_gn_profile_p gn = (sdp_gn_profile_p) provider->data; + + return (common_profile_create_service_availability(buf, eob, + &gn->load_factor, 1)); +} + +static int32_t +gn_profile_data_valid(uint8_t const *data, uint32_t datalen) +{ + sdp_gn_profile_p gn = (sdp_gn_profile_p) data; + + return ((gn->psm == 0)? 0 : 1); +} + static attr_t gn_profile_attrs[] = { { SDP_ATTR_SERVICE_RECORD_HANDLE, common_profile_create_service_record_handle }, @@ -126,6 +150,8 @@ static attr_t gn_profile_attrs[] = { gn_profile_create_protocol_descriptor_list }, { SDP_ATTR_LANGUAGE_BASE_ATTRIBUTE_ID_LIST, common_profile_create_language_base_attribute_id_list }, + { SDP_ATTR_SERVICE_AVAILABILITY, + gn_profile_create_service_availability }, { SDP_ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST, gn_profile_create_bluetooth_profile_descriptor_list }, { SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID + SDP_ATTR_SERVICE_NAME_OFFSET, @@ -140,7 +166,7 @@ static attr_t gn_profile_attrs[] = { profile_t gn_profile_descriptor = { SDP_SERVICE_CLASS_GN, sizeof(sdp_gn_profile_t), - common_profile_always_valid, + gn_profile_data_valid, (attr_t const * const) &gn_profile_attrs }; diff --git a/usr.sbin/bluetooth/sdpd/lan.c b/usr.sbin/bluetooth/sdpd/lan.c index a5612ed..2425a89 100644 --- a/usr.sbin/bluetooth/sdpd/lan.c +++ b/usr.sbin/bluetooth/sdpd/lan.c @@ -102,13 +102,8 @@ lan_profile_create_service_availability( provider_p provider = (provider_p) data; sdp_lan_profile_p lan = (sdp_lan_profile_p) provider->data; - if (buf + 2 > eob) - return (-1); - - SDP_PUT8(SDP_DATA_UINT8, buf); - SDP_PUT8(lan->load_factor, buf); - - return (2); + return (common_profile_create_service_availability(buf, eob, + &lan->load_factor, 1)); } static int32_t diff --git a/usr.sbin/bluetooth/sdpd/nap.c b/usr.sbin/bluetooth/sdpd/nap.c index 45c0c6d..5a857d8 100644 --- a/usr.sbin/bluetooth/sdpd/nap.c +++ b/usr.sbin/bluetooth/sdpd/nap.c @@ -99,8 +99,12 @@ nap_profile_create_protocol_descriptor_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { + provider_p provider = (provider_p) data; + sdp_nap_profile_p nap = (sdp_nap_profile_p) provider->data; + return (bnep_profile_create_protocol_descriptor_list( - buf, eob, NULL, 0)); + buf, eob, (uint8_t const *) &nap->psm, + sizeof(nap->psm))); } static int32_t @@ -150,6 +154,26 @@ nap_profile_create_max_net_access_rate( return (3); } +static int32_t +nap_profile_create_service_availability( + uint8_t *buf, uint8_t const * const eob, + uint8_t const *data, uint32_t datalen) +{ + provider_p provider = (provider_p) data; + sdp_nap_profile_p nap = (sdp_nap_profile_p) provider->data; + + return (common_profile_create_service_availability(buf, eob, + &nap->load_factor, 1)); +} + +static int32_t +nap_profile_data_valid(uint8_t const *data, uint32_t datalen) +{ + sdp_nap_profile_p nap = (sdp_nap_profile_p) data; + + return ((nap->psm == 0)? 0 : 1); +} + static attr_t nap_profile_attrs[] = { { SDP_ATTR_SERVICE_RECORD_HANDLE, common_profile_create_service_record_handle }, @@ -159,6 +183,8 @@ static attr_t nap_profile_attrs[] = { nap_profile_create_protocol_descriptor_list }, { SDP_ATTR_LANGUAGE_BASE_ATTRIBUTE_ID_LIST, common_profile_create_language_base_attribute_id_list }, + { SDP_ATTR_SERVICE_AVAILABILITY, + nap_profile_create_service_availability }, { SDP_ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST, nap_profile_create_bluetooth_profile_descriptor_list }, { SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID + SDP_ATTR_SERVICE_NAME_OFFSET, @@ -177,7 +203,7 @@ static attr_t nap_profile_attrs[] = { profile_t nap_profile_descriptor = { SDP_SERVICE_CLASS_NAP, sizeof(sdp_nap_profile_t), - common_profile_always_valid, + nap_profile_data_valid, (attr_t const * const) &nap_profile_attrs }; diff --git a/usr.sbin/bluetooth/sdpd/panu.c b/usr.sbin/bluetooth/sdpd/panu.c index 196b369..a948508 100644 --- a/usr.sbin/bluetooth/sdpd/panu.c +++ b/usr.sbin/bluetooth/sdpd/panu.c @@ -100,8 +100,32 @@ panu_profile_create_protocol_descriptor_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { + provider_p provider = (provider_p) data; + sdp_panu_profile_p panu = (sdp_panu_profile_p) provider->data; + return (bnep_profile_create_protocol_descriptor_list( - buf, eob, NULL, 0)); + buf, eob, (uint8_t const *) &panu->psm, + sizeof(panu->psm))); +} + +static int32_t +panu_profile_data_valid(uint8_t const *data, uint32_t datalen) +{ + sdp_panu_profile_p panu = (sdp_panu_profile_p) data; + + return ((panu->psm == 0)? 0 : 1); +} + +static int32_t +panu_profile_create_service_availability( + uint8_t *buf, uint8_t const * const eob, + uint8_t const *data, uint32_t datalen) +{ + provider_p provider = (provider_p) data; + sdp_panu_profile_p panu = (sdp_panu_profile_p) provider->data; + + return (common_profile_create_service_availability( buf, eob, + &panu->load_factor, 1)); } static attr_t panu_profile_attrs[] = { @@ -113,6 +137,8 @@ static attr_t panu_profile_attrs[] = { panu_profile_create_protocol_descriptor_list }, { SDP_ATTR_LANGUAGE_BASE_ATTRIBUTE_ID_LIST, common_profile_create_language_base_attribute_id_list }, + { SDP_ATTR_SERVICE_AVAILABILITY, + panu_profile_create_service_availability }, { SDP_ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST, panu_profile_create_bluetooth_profile_descriptor_list }, { SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID + SDP_ATTR_SERVICE_NAME_OFFSET, @@ -125,7 +151,7 @@ static attr_t panu_profile_attrs[] = { profile_t panu_profile_descriptor = { SDP_SERVICE_CLASS_PANU, sizeof(sdp_panu_profile_t), - common_profile_always_valid, + panu_profile_data_valid, (attr_t const * const) &panu_profile_attrs }; diff --git a/usr.sbin/bluetooth/sdpd/profile.c b/usr.sbin/bluetooth/sdpd/profile.c index e388efa..f3dfaa7 100644 --- a/usr.sbin/bluetooth/sdpd/profile.c +++ b/usr.sbin/bluetooth/sdpd/profile.c @@ -256,6 +256,24 @@ common_profile_create_string8( } /* + * Service Availability + */ + +int32_t +common_profile_create_service_availability( + uint8_t *buf, uint8_t const * const eob, + uint8_t const *data, uint32_t datalen) +{ + if (datalen != 1 || buf + 2 > eob) + return (-1); + + SDP_PUT8(SDP_DATA_UINT8, buf); + SDP_PUT8(data[0], buf); + + return (2); +} + +/* * seq8 len8 - 2 bytes * seq8 len8 - 2 bytes * uuid16 value16 - 3 bytes @@ -419,13 +437,16 @@ bnep_profile_create_protocol_descriptor_list( #endif }; - uint16_t i, psm = 15, version = 0x0100, + uint16_t i, psm, version = 0x0100, nptypes = sizeof(ptype)/sizeof(ptype[0]), nptypes_size = nptypes * 3; - if (18 + nptypes_size > 255 || buf + 20 + nptypes_size > eob) + if (datalen != 2 || 18 + nptypes_size > 255 || + buf + 20 + nptypes_size > eob) return (-1); + memcpy(&psm, data, sizeof(psm)); + SDP_PUT8(SDP_DATA_SEQ8, buf); SDP_PUT8(18 + nptypes_size, buf); diff --git a/usr.sbin/bluetooth/sdpd/profile.h b/usr.sbin/bluetooth/sdpd/profile.h index e72d2c2..0b0d86d 100644 --- a/usr.sbin/bluetooth/sdpd/profile.h +++ b/usr.sbin/bluetooth/sdpd/profile.h @@ -81,6 +81,7 @@ profile_attr_create_t common_profile_create_bluetooth_profile_descriptor_list; profile_attr_create_t common_profile_create_language_base_attribute_id_list; profile_attr_create_t common_profile_create_service_provider_name; profile_attr_create_t common_profile_create_string8; +profile_attr_create_t common_profile_create_service_availability; profile_attr_create_t rfcomm_profile_create_protocol_descriptor_list; profile_attr_create_t obex_profile_create_protocol_descriptor_list; profile_attr_create_t obex_profile_create_supported_formats_list; |