Wed Mar 19 23:15:20 2008 UTC ()
add the knowledge to create service records for "Personal Area Networking"
profiles
	NAP	Network Access Point
	GN	Group Network
	PANU	Personal Area Networking User


(plunky)
diff -r1.3 -r1.4 src/usr.sbin/sdpd/Makefile
diff -r0 -r1.1 src/usr.sbin/sdpd/gn.c
diff -r0 -r1.1 src/usr.sbin/sdpd/nap.c
diff -r0 -r1.1 src/usr.sbin/sdpd/panu.c
diff -r1.4 -r1.5 src/usr.sbin/sdpd/profile.c
diff -r1.2 -r1.3 src/usr.sbin/sdpd/profile.h

cvs diff -r1.3 -r1.4 src/usr.sbin/sdpd/Makefile (expand / switch to unified diff)

--- src/usr.sbin/sdpd/Makefile 2007/05/28 12:06:41 1.3
+++ src/usr.sbin/sdpd/Makefile 2008/03/19 23:15:19 1.4
@@ -1,11 +1,11 @@ @@ -1,11 +1,11 @@
1# $NetBSD: Makefile,v 1.3 2007/05/28 12:06:41 tls Exp $ 1# $NetBSD: Makefile,v 1.4 2008/03/19 23:15:19 plunky Exp $
2 2
3USE_FORT?= yes # network server 3USE_FORT?= yes # network server
4 4
5PROG= sdpd 5PROG= sdpd
6MAN= sdpd.8 6MAN= sdpd.8
7SRCS= bgd.c dun.c ftrn.c hf.c hset.c irmc.c irmc_command.c lan.c \ 7SRCS= bgd.c dun.c ftrn.c gn.c hf.c hset.c irmc.c irmc_command.c \
8 log.c main.c opush.c profile.c provider.c sar.c scr.c \ 8 lan.c log.c main.c nap.c opush.c panu.c profile.c provider.c \
9 sd.c server.c sp.c srr.c ssar.c ssr.c sur.c uuid.c 9 sar.c scr.c sd.c server.c sp.c srr.c ssar.c ssr.c sur.c uuid.c
10 10
11.include <bsd.prog.mk> 11.include <bsd.prog.mk>

File Added: src/usr.sbin/sdpd/Attic/gn.c
/*	$NetBSD: gn.c,v 1.1 2008/03/19 23:15:19 plunky Exp $	*/

/*-
 * Copyright (c) 2008 Iain Hibbert
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include <sys/cdefs.h>
__RCSID("$NetBSD: gn.c,v 1.1 2008/03/19 23:15:19 plunky Exp $");

#include <sys/queue.h>
#include <bluetooth.h>
#include <sdp.h>
#include <string.h>
#include "profile.h"
#include "provider.h"

static int32_t
gn_profile_create_service_class_id_list(uint8_t *buf,
    uint8_t const * const eob, uint8_t const *data, uint32_t datalen)
{
	const uint16_t service_classes[] = {
		SDP_SERVICE_CLASS_GN,
	};

	return common_profile_create_service_class_id_list(buf, eob,
	    (uint8_t const *) service_classes, sizeof(service_classes));
}

static int32_t
gn_profile_create_protocol_descriptor_list(uint8_t *buf,
    uint8_t const * const eob, uint8_t const *data, uint32_t datalen)
{
	provider_t const *provider = (provider_t const *) data;
	sdp_gn_profile_t *gn = (sdp_gn_profile_t *) provider->data;

	return bnep_profile_create_protocol_descriptor_list(buf, eob,
	    (uint8_t const *) &gn->psm, 2);
}

static int32_t
gn_profile_create_service_availability(uint8_t *buf,
    uint8_t const * const eob, uint8_t const *data, uint32_t datalen)
{
	provider_t const *provider = (provider_t const *) data;
	sdp_gn_profile_t *gn = (sdp_gn_profile_p) provider->data;

	if (buf + 2 > eob)
		return (-1);

	SDP_PUT8(SDP_DATA_UINT8, buf);
	SDP_PUT8(gn->load_factor, buf);

	return 2;
}

static int32_t
gn_profile_create_bluetooth_profile_descriptor_list(uint8_t *buf,
    uint8_t const * const eob, uint8_t const *data, uint32_t datalen)
{
	const uint16_t profile_descriptor_list[] = {
		SDP_SERVICE_CLASS_GN,
		0x0100,
	};

	return common_profile_create_bluetooth_profile_descriptor_list(buf, eob,
	    (uint8_t const *) profile_descriptor_list,
	    sizeof(profile_descriptor_list));
}

static int32_t
gn_profile_create_service_name(uint8_t *buf,
    uint8_t const * const eob, uint8_t const *data, uint32_t datalen)
{
	const char service_name[] = "Group Ad-hoc Network";

	return common_profile_create_string8(buf, eob,
	    (uint8_t const *) service_name, strlen(service_name));
}

static int32_t
gn_profile_create_service_description(uint8_t *buf,
    uint8_t const * const eob, uint8_t const *data, uint32_t datalen)
{
	const char service_descr[] = "Personal Group Ad-hoc Network Service";

	return common_profile_create_string8(buf, eob,
	    (uint8_t const *) service_descr, strlen(service_descr));
}

static int32_t
gn_profile_create_security_description(uint8_t *buf,
    uint8_t const * const eob, uint8_t const *data, uint32_t datalen)
{
	provider_t const *provider = (provider_t const *) data;
	sdp_gn_profile_t *gn = (sdp_gn_profile_t *) provider->data;

	if (buf + 3 > eob)
		return (-1);

	SDP_PUT8(SDP_DATA_UINT16, buf);
	SDP_PUT16(gn->security_description, buf);

	return 3;
}

static int32_t
gn_profile_data_valid(uint8_t const *data, uint32_t datalen)
{
	sdp_gn_profile_t const *gn = (sdp_gn_profile_t const *) data;

	if (L2CAP_PSM_INVALID(gn->psm)
	    || gn->security_description > 0x0002)
		return 0;

	return 1;
}

static attr_t gn_profile_attrs[] = {
	{ SDP_ATTR_SERVICE_RECORD_HANDLE,
	  common_profile_create_service_record_handle },
	{ SDP_ATTR_SERVICE_CLASS_ID_LIST,
	  gn_profile_create_service_class_id_list },
	{ SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST,
	  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,
	  gn_profile_create_service_name },
	{ SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID + SDP_ATTR_SERVICE_DESCRIPTION_OFFSET,
	  gn_profile_create_service_description },
	{ SDP_ATTR_SECURITY_DESCRIPTION,
	  gn_profile_create_security_description },
	{ 0, NULL } /* end entry */
};

static uint16_t gn_profile_uuids[] = {
	SDP_SERVICE_CLASS_GN,
	SDP_UUID_PROTOCOL_L2CAP,
	SDP_UUID_PROTOCOL_BNEP,
};

profile_t gn_profile_descriptor = {
	gn_profile_uuids,
	sizeof(gn_profile_uuids),
	sizeof(sdp_gn_profile_t),
	gn_profile_data_valid,
	(attr_t const * const) &gn_profile_attrs,
};

File Added: src/usr.sbin/sdpd/Attic/nap.c
/*	$NetBSD: nap.c,v 1.1 2008/03/19 23:15:19 plunky Exp $	*/

/*-
 * Copyright (c) 2008 Iain Hibbert
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include <sys/cdefs.h>
__RCSID("$NetBSD: nap.c,v 1.1 2008/03/19 23:15:19 plunky Exp $");

#include <sys/queue.h>
#include <bluetooth.h>
#include <sdp.h>
#include <string.h>
#include "profile.h"
#include "provider.h"

static int32_t
nap_profile_create_service_class_id_list(uint8_t *buf,
    uint8_t const * const eob, uint8_t const *data, uint32_t datalen)
{
	const uint16_t service_classes[] = {
		SDP_SERVICE_CLASS_NAP,
	};

	return common_profile_create_service_class_id_list(buf, eob,
	    (uint8_t const *) service_classes, sizeof(service_classes));
}

static int32_t
nap_profile_create_protocol_descriptor_list(uint8_t *buf,
    uint8_t const *const eob, uint8_t const *data, uint32_t datalen)
{
	provider_t const *provider = (provider_t const *) data;
	sdp_nap_profile_t *nap = (sdp_nap_profile_t *) provider->data;

	return bnep_profile_create_protocol_descriptor_list(buf, eob,
	    (uint8_t const *) &nap->psm, 2);
}

static int32_t
nap_profile_create_bluetooth_profile_descriptor_list(uint8_t *buf,
    uint8_t const * const eob, uint8_t const *data, uint32_t datalen)
{
	const uint16_t profile_descriptor_list[] = {
		SDP_SERVICE_CLASS_NAP,
		0x0100,
	};

	return common_profile_create_bluetooth_profile_descriptor_list(buf, eob,
	    (uint8_t const *) profile_descriptor_list,
	    sizeof(profile_descriptor_list));
}

static int32_t
nap_profile_create_service_availability(uint8_t *buf,
    uint8_t const * const eob, uint8_t const *data, uint32_t datalen)
{
	provider_t const *provider = (provider_t const *) data;
	sdp_nap_profile_t *nap = (sdp_nap_profile_p) provider->data;

	if (buf + 2 > eob)
		return -1;

	SDP_PUT8(SDP_DATA_UINT8, buf);
	SDP_PUT8(nap->load_factor, buf);

	return 2;
}

static int32_t
nap_profile_create_service_name(uint8_t *buf,
    uint8_t const * const eob, uint8_t const *data, uint32_t datalen)
{
	const char service_name[] = "Network Access Point";

	return common_profile_create_string8(buf, eob,
	    (uint8_t const *) service_name, strlen(service_name));
}

static int32_t
nap_profile_create_service_description(uint8_t *buf,
    uint8_t const * const eob, uint8_t const *data, uint32_t datalen)
{
	const char service_descr[] = "Personal Ad-hoc Network Service";

	return common_profile_create_string8(buf, eob,
	    (uint8_t const *) service_descr, strlen(service_descr));
}

static int32_t
nap_profile_create_security_description(uint8_t *buf,
    uint8_t const * const eob, uint8_t const *data, uint32_t datalen)
{
	provider_t const *provider = (provider_t const *) data;
	sdp_nap_profile_t *nap = (sdp_nap_profile_t *) provider->data;

	if (buf + 3 > eob)
		return -1;

	SDP_PUT8(SDP_DATA_UINT16, buf);
	SDP_PUT16(nap->security_description, buf);

	return 3;
}

static int32_t
nap_profile_create_net_access_type(uint8_t *buf,
    uint8_t const * const eob, uint8_t const *data, uint32_t datalen)
{
	provider_t const *provider = (provider_t const *) data;
	sdp_nap_profile_t *nap = (sdp_nap_profile_t *) provider->data;

	if (buf + 3 > eob)
		return -1;

	SDP_PUT8(SDP_DATA_UINT16, buf);
	SDP_PUT16(nap->net_access_type, buf);

	return 3;
}

static int32_t
nap_profile_create_max_net_access_rate(uint8_t *buf,
    uint8_t const * const eob, uint8_t const *data, uint32_t datalen)
{
	provider_t const *provider = (provider_t const *) data;
	sdp_nap_profile_t *nap = (sdp_nap_profile_t *) provider->data;

	if (buf + 5 > eob)
		return -1;

	SDP_PUT8(SDP_DATA_UINT32, buf);
	SDP_PUT32(nap->max_net_access_rate, buf);

	return 5;
}

static int32_t
nap_profile_data_valid(uint8_t const *data, uint32_t datalen)
{
	sdp_nap_profile_t const *nap = (sdp_nap_profile_t const *) data;

	if (L2CAP_PSM_INVALID(nap->psm)
	    || nap->security_description > 0x0002)
		return 0;

	return 1;
}

static attr_t nap_profile_attrs[] = {
	{ SDP_ATTR_SERVICE_RECORD_HANDLE,
	  common_profile_create_service_record_handle },
	{ SDP_ATTR_SERVICE_CLASS_ID_LIST,
	  nap_profile_create_service_class_id_list },
	{ SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST,
	  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,
	  nap_profile_create_service_name },
	{ SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID + SDP_ATTR_SERVICE_DESCRIPTION_OFFSET,
	  nap_profile_create_service_description },
	{ SDP_ATTR_SECURITY_DESCRIPTION,
	  nap_profile_create_security_description },
	{ SDP_ATTR_NET_ACCESS_TYPE,
	  nap_profile_create_net_access_type },
	{ SDP_ATTR_MAX_NET_ACCESS_RATE,
	  nap_profile_create_max_net_access_rate },
	{ 0, NULL } /* end entry */
};

static uint16_t nap_profile_uuids[] = {
	SDP_SERVICE_CLASS_NAP,
	SDP_UUID_PROTOCOL_L2CAP,
	SDP_UUID_PROTOCOL_BNEP,
};

profile_t nap_profile_descriptor = {
	nap_profile_uuids,
	sizeof(nap_profile_uuids),
	sizeof(sdp_nap_profile_t),
	nap_profile_data_valid,
	(attr_t const * const) &nap_profile_attrs,
};

File Added: src/usr.sbin/sdpd/Attic/panu.c
/*	$NetBSD: panu.c,v 1.1 2008/03/19 23:15:19 plunky Exp $	*/

/*-
 * Copyright (c) 2008 Iain Hibbert
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include <sys/cdefs.h>
__RCSID("$NetBSD: panu.c,v 1.1 2008/03/19 23:15:19 plunky Exp $");

#include <sys/queue.h>
#include <bluetooth.h>
#include <sdp.h>
#include <string.h>
#include "profile.h"
#include "provider.h"

static int32_t
panu_profile_create_service_class_id_list(uint8_t *buf,
    uint8_t const * const eob, uint8_t const *data, uint32_t datalen)
{
	const uint16_t service_classes[] = {
		SDP_SERVICE_CLASS_PANU,
	};

	return common_profile_create_service_class_id_list(buf, eob,
	    (uint8_t const *) service_classes, sizeof(service_classes));
}

static int32_t
panu_profile_create_protocol_descriptor_list(uint8_t *buf,
    uint8_t const * const eob, uint8_t const *data, uint32_t datalen)
{
	provider_t const *provider = (provider_t const *) data;
	sdp_panu_profile_t *panu = (sdp_panu_profile_t *) provider->data;

	return bnep_profile_create_protocol_descriptor_list(buf, eob,
	    (uint8_t const *) &panu->psm, 2);
}

static int32_t
panu_profile_create_service_availability(uint8_t *buf,
    uint8_t const * const eob, uint8_t const *data, uint32_t datalen)
{
	provider_t const *provider = (provider_t const *) data;
	sdp_panu_profile_t *panu = (sdp_panu_profile_p) provider->data;

	if (buf + 2 > eob)
		return -1;

	SDP_PUT8(SDP_DATA_UINT8, buf);
	SDP_PUT8(panu->load_factor, buf);

	return 2;
}

static int32_t
panu_profile_create_bluetooth_profile_descriptor_list(uint8_t *buf,
    uint8_t const * const eob, uint8_t const *data, uint32_t datalen)
{
	const uint16_t profile_descriptor_list[] = {
		SDP_SERVICE_CLASS_PANU,
		0x0100,
	};

	return common_profile_create_bluetooth_profile_descriptor_list(buf, eob,
	    (uint8_t const *) profile_descriptor_list,
	    sizeof(profile_descriptor_list));
}

static int32_t
panu_profile_create_service_name(uint8_t *buf,
    uint8_t const * const eob, uint8_t const *data, uint32_t datalen)
{
	const char service_name[] = "Personal Ad-hoc User Service";

	return common_profile_create_string8(buf, eob,
	    (uint8_t const *) service_name, strlen(service_name));
}

static int32_t
panu_profile_create_service_description(uint8_t *buf,
    uint8_t const * const eob, uint8_t const *data, uint32_t datalen)
{
	const char service_descr[] = "Personal Ad-hoc User Service";

	return common_profile_create_string8(buf, eob,
	    (uint8_t const *) service_descr, strlen(service_descr));
}

static int32_t
panu_profile_create_security_description(uint8_t *buf,
    uint8_t const * const eob, uint8_t const *data, uint32_t datalen)
{
	provider_t const *provider = (provider_t const *) data;
	sdp_panu_profile_t *panu = (sdp_panu_profile_t *) provider->data;

	if (buf + 3 > eob)
		return -1;

	SDP_PUT8(SDP_DATA_UINT16, buf);
	SDP_PUT16(panu->security_description, buf);

	return 3;
}

static int32_t
panu_profile_data_valid(uint8_t const *data, uint32_t datalen)
{
	sdp_panu_profile_t const *panu = (sdp_panu_profile_t const *) data;

	if (L2CAP_PSM_INVALID(panu->psm)
	    || panu->security_description > 0x0002)
		return 0;

	return 1;
}

static attr_t panu_profile_attrs[] = {
	{ SDP_ATTR_SERVICE_RECORD_HANDLE,
	  common_profile_create_service_record_handle },
	{ SDP_ATTR_SERVICE_CLASS_ID_LIST,
	  panu_profile_create_service_class_id_list },
	{ SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST,
	  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,
	  panu_profile_create_service_name },
	{ SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID + SDP_ATTR_SERVICE_DESCRIPTION_OFFSET,
	  panu_profile_create_service_description },
	{ SDP_ATTR_SECURITY_DESCRIPTION,
	  panu_profile_create_security_description },
	{ 0, NULL } /* end entry */
};

static uint16_t panu_profile_uuids[] = {
	SDP_SERVICE_CLASS_PANU,
	SDP_UUID_PROTOCOL_L2CAP,
	SDP_UUID_PROTOCOL_BNEP,
};

profile_t panu_profile_descriptor = {
	panu_profile_uuids,
	sizeof(panu_profile_uuids),
	sizeof(sdp_panu_profile_t),
	panu_profile_data_valid,
	(attr_t const * const) &panu_profile_attrs,
};

cvs diff -r1.4 -r1.5 src/usr.sbin/sdpd/Attic/profile.c (expand / switch to unified diff)

--- src/usr.sbin/sdpd/Attic/profile.c 2007/11/09 20:08:41 1.4
+++ src/usr.sbin/sdpd/Attic/profile.c 2008/03/19 23:15:19 1.5
@@ -1,84 +1,92 @@ @@ -1,84 +1,92 @@
1/* $NetBSD: profile.c,v 1.4 2007/11/09 20:08:41 plunky Exp $ */ 1/* $NetBSD: profile.c,v 1.5 2008/03/19 23:15:19 plunky Exp $ */
2 2
3/* 3/*
4 * profile.c 4 * profile.c
5 * 5 *
 6 * Copyright (c) 2008 Iain Hibbert
6 * Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com> 7 * Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
7 * All rights reserved. 8 * All rights reserved.
8 * 9 *
9 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
11 * are met: 12 * are met:
12 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the 16 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution. 17 * documentation and/or other materials provided with the distribution.
17 * 18 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE. 29 * SUCH DAMAGE.
29 * 30 *
30 * $Id: profile.c,v 1.4 2007/11/09 20:08:41 plunky Exp $ 31 * $Id: profile.c,v 1.5 2008/03/19 23:15:19 plunky Exp $
31 * $FreeBSD: src/usr.sbin/bluetooth/sdpd/profile.c,v 1.2 2004/07/28 07:15:44 kan Exp $ 32 * $FreeBSD: src/usr.sbin/bluetooth/sdpd/profile.c,v 1.2 2004/07/28 07:15:44 kan Exp $
32 */ 33 */
33 34
34#include <sys/cdefs.h> 35#include <sys/cdefs.h>
35__RCSID("$NetBSD: profile.c,v 1.4 2007/11/09 20:08:41 plunky Exp $"); 36__RCSID("$NetBSD: profile.c,v 1.5 2008/03/19 23:15:19 plunky Exp $");
36 37
37#include <sys/queue.h> 38#include <sys/queue.h>
38#include <sys/utsname.h> 39#include <sys/utsname.h>
 40#include <net/ethertypes.h>
39#include <bluetooth.h> 41#include <bluetooth.h>
40#include <sdp.h> 42#include <sdp.h>
41#include <string.h> 43#include <string.h>
42#include "profile.h" 44#include "profile.h"
43#include "provider.h" 45#include "provider.h"
44 46
45/* 47/*
46 * Lookup profile descriptor 48 * Lookup profile descriptor
47 */ 49 */
48 50
49profile_p 51profile_p
50profile_get_descriptor(uint16_t uuid) 52profile_get_descriptor(uint16_t uuid)
51{ 53{
52 extern profile_t dun_profile_descriptor; 54 extern profile_t dun_profile_descriptor;
53 extern profile_t ftrn_profile_descriptor; 55 extern profile_t ftrn_profile_descriptor;
 56 extern profile_t gn_profile_descriptor;
54 extern profile_t hf_profile_descriptor; 57 extern profile_t hf_profile_descriptor;
55 extern profile_t hset_profile_descriptor; 58 extern profile_t hset_profile_descriptor;
56 extern profile_t irmc_profile_descriptor; 59 extern profile_t irmc_profile_descriptor;
57 extern profile_t irmc_command_profile_descriptor; 60 extern profile_t irmc_command_profile_descriptor;
58 extern profile_t lan_profile_descriptor; 61 extern profile_t lan_profile_descriptor;
 62 extern profile_t nap_profile_descriptor;
59 extern profile_t opush_profile_descriptor; 63 extern profile_t opush_profile_descriptor;
 64 extern profile_t panu_profile_descriptor;
60 extern profile_t sp_profile_descriptor; 65 extern profile_t sp_profile_descriptor;
61 66
62 static const profile_p profiles[] = { 67 static const profile_p profiles[] = {
63 &dun_profile_descriptor, 68 &dun_profile_descriptor,
64 &ftrn_profile_descriptor, 69 &ftrn_profile_descriptor,
 70 &gn_profile_descriptor,
65 &hf_profile_descriptor, 71 &hf_profile_descriptor,
66 &hset_profile_descriptor, 72 &hset_profile_descriptor,
67 &irmc_profile_descriptor, 73 &irmc_profile_descriptor,
68 &irmc_command_profile_descriptor, 74 &irmc_command_profile_descriptor,
69 &lan_profile_descriptor, 75 &lan_profile_descriptor,
 76 &nap_profile_descriptor,
70 &opush_profile_descriptor, 77 &opush_profile_descriptor,
71 &sp_profile_descriptor 78 &panu_profile_descriptor,
 79 &sp_profile_descriptor,
72 }; 80 };
73 81
74 int32_t i; 82 int32_t i;
75 83
76 for (i = 0; i < sizeof(profiles)/sizeof(profiles[0]); i++) 84 for (i = 0; i < sizeof(profiles)/sizeof(profiles[0]); i++)
77 if (profiles[i]->uuid[0] == uuid) 85 if (profiles[i]->uuid[0] == uuid)
78 return (profiles[i]); 86 return (profiles[i]);
79 87
80 return (NULL); 88 return (NULL);
81} 89}
82 90
83/* 91/*
84 * Look attribute in the profile descripror 92 * Look attribute in the profile descripror
@@ -370,26 +378,85 @@ obex_profile_create_supported_formats_li @@ -370,26 +378,85 @@ obex_profile_create_supported_formats_li
370 * verify server channel number (the first byte in the data) 378 * verify server channel number (the first byte in the data)
371 */ 379 */
372 380
373int32_t 381int32_t
374common_profile_server_channel_valid(uint8_t const *data, uint32_t datalen) 382common_profile_server_channel_valid(uint8_t const *data, uint32_t datalen)
375{ 383{
376 if (data[0] < 1 || data[0] > 30) 384 if (data[0] < 1 || data[0] > 30)
377 return (0); 385 return (0);
378 386
379 return (1); 387 return (1);
380} 388}
381 389
382/* 390/*
 391 * seq8 len8 - 2 bytes
 392 * seq8 len8 - 2 bytes
 393 * uuid16 value16 - 3 bytes (L2CAP)
 394 * uint16 value16 - 3 bytes (PSM)
 395 * seq8 len8 - 2 bytes
 396 * uuid16 value16 - 3 bytes (BNEP)
 397 * uint16 value16 - 3 bytes (v1.0)
 398 * seq8 len8 - 2 bytes
 399 * uint16 value16 - 3 bytes (IPv4)
 400 * uint16 value16 - 3 bytes (ARP)
 401 * uint16 value16 - 3 bytes (IPv6)
 402 */
 403
 404int32_t
 405bnep_profile_create_protocol_descriptor_list(
 406 uint8_t *buf, uint8_t const * const eob,
 407 uint8_t const *data, uint32_t datalen)
 408{
 409 /* supported protocol types */
 410 const uint16_t ptype[] = {
 411 ETHERTYPE_IP,
 412 ETHERTYPE_ARP,
 413#ifdef INET6
 414 ETHERTYPE_IPV6,
 415#endif
 416 };
 417 const int psize = __arraycount(ptype) * 3;
 418 int i;
 419
 420 if (datalen != 2 || (18 + psize) > 255 || (buf + 20 + psize) > eob)
 421 return (-1);
 422
 423 SDP_PUT8(SDP_DATA_SEQ8, buf);
 424 SDP_PUT8(18 + psize, buf);
 425
 426 SDP_PUT8(SDP_DATA_SEQ8, buf);
 427 SDP_PUT8(6, buf);
 428 SDP_PUT8(SDP_DATA_UUID16, buf);
 429 SDP_PUT16(SDP_UUID_PROTOCOL_L2CAP, buf);
 430 SDP_PUT8(SDP_DATA_UINT16, buf);
 431 SDP_PUT16(*(uint16_t *)data, buf);
 432
 433 SDP_PUT8(SDP_DATA_SEQ8, buf);
 434 SDP_PUT8(8 + psize, buf);
 435 SDP_PUT8(SDP_DATA_UUID16, buf);
 436 SDP_PUT16(SDP_UUID_PROTOCOL_BNEP, buf);
 437 SDP_PUT8(SDP_DATA_UINT16, buf);
 438 SDP_PUT16(0x0100, buf);
 439 SDP_PUT8(SDP_DATA_SEQ8, buf);
 440 SDP_PUT8(psize, buf);
 441 for (i = 0 ; i < __arraycount(ptype) ; i ++) {
 442 SDP_PUT8(SDP_DATA_UINT16, buf);
 443 SDP_PUT16(ptype[i], buf);
 444 }
 445
 446 return (20 + psize);
 447}
 448
 449/*
383 * verify server channel number and supported_formats_size 450 * verify server channel number and supported_formats_size
384 * sdp_opush_profile and sdp_irmc_profile 451 * sdp_opush_profile and sdp_irmc_profile
385 */ 452 */
386 453
387int32_t 454int32_t
388obex_profile_data_valid(uint8_t const *data, uint32_t datalen) 455obex_profile_data_valid(uint8_t const *data, uint32_t datalen)
389{ 456{
390 sdp_opush_profile_t const *opush = (sdp_opush_profile_t const *) data; 457 sdp_opush_profile_t const *opush = (sdp_opush_profile_t const *) data;
391 458
392 if (opush->server_channel < 1 || 459 if (opush->server_channel < 1 ||
393 opush->server_channel > 30 || 460 opush->server_channel > 30 ||
394 opush->supported_formats_size == 0 || 461 opush->supported_formats_size == 0 ||
395 opush->supported_formats_size > sizeof(opush->supported_formats)) 462 opush->supported_formats_size > sizeof(opush->supported_formats))

cvs diff -r1.2 -r1.3 src/usr.sbin/sdpd/Attic/profile.h (expand / switch to unified diff)

--- src/usr.sbin/sdpd/Attic/profile.h 2007/11/09 20:08:41 1.2
+++ src/usr.sbin/sdpd/Attic/profile.h 2008/03/19 23:15:19 1.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: profile.h,v 1.2 2007/11/09 20:08:41 plunky Exp $ */ 1/* $NetBSD: profile.h,v 1.3 2008/03/19 23:15:19 plunky Exp $ */
2 2
3/* 3/*
4 * profile.h 4 * profile.h
5 * 5 *
6 * Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com> 6 * Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
7 * All rights reserved. 7 * All rights reserved.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -17,27 +17,27 @@ @@ -17,27 +17,27 @@
17 * 17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE. 28 * SUCH DAMAGE.
29 * 29 *
30 * $Id: profile.h,v 1.2 2007/11/09 20:08:41 plunky Exp $ 30 * $Id: profile.h,v 1.3 2008/03/19 23:15:19 plunky Exp $
31 * $FreeBSD: src/usr.sbin/bluetooth/sdpd/profile.h,v 1.1 2004/01/20 20:48:26 emax Exp $ 31 * $FreeBSD: src/usr.sbin/bluetooth/sdpd/profile.h,v 1.1 2004/01/20 20:48:26 emax Exp $
32 */ 32 */
33 33
34#ifndef _PROFILE_H_ 34#ifndef _PROFILE_H_
35#define _PROFILE_H_ 35#define _PROFILE_H_
36 36
37/* 37/*
38 * Attribute descriptor 38 * Attribute descriptor
39 */ 39 */
40 40
41typedef int32_t (profile_attr_create_t)( 41typedef int32_t (profile_attr_create_t)(
42 uint8_t *buf, uint8_t const * const eob, 42 uint8_t *buf, uint8_t const * const eob,
43 uint8_t const *data, uint32_t datalen); 43 uint8_t const *data, uint32_t datalen);
@@ -75,18 +75,19 @@ typedef struct profile *profile_p; @@ -75,18 +75,19 @@ typedef struct profile *profile_p;
75 75
76profile_p profile_get_descriptor(uint16_t uuid); 76profile_p profile_get_descriptor(uint16_t uuid);
77profile_attr_create_p profile_get_attr(const profile_p profile, uint16_t attr); 77profile_attr_create_p profile_get_attr(const profile_p profile, uint16_t attr);
78 78
79profile_attr_create_t common_profile_create_service_record_handle; 79profile_attr_create_t common_profile_create_service_record_handle;
80profile_attr_create_t common_profile_create_service_class_id_list; 80profile_attr_create_t common_profile_create_service_class_id_list;
81profile_attr_create_t common_profile_create_bluetooth_profile_descriptor_list; 81profile_attr_create_t common_profile_create_bluetooth_profile_descriptor_list;
82profile_attr_create_t common_profile_create_language_base_attribute_id_list; 82profile_attr_create_t common_profile_create_language_base_attribute_id_list;
83profile_attr_create_t common_profile_create_service_provider_name; 83profile_attr_create_t common_profile_create_service_provider_name;
84profile_attr_create_t common_profile_create_string8; 84profile_attr_create_t common_profile_create_string8;
85profile_attr_create_t rfcomm_profile_create_protocol_descriptor_list; 85profile_attr_create_t rfcomm_profile_create_protocol_descriptor_list;
86profile_attr_create_t obex_profile_create_protocol_descriptor_list; 86profile_attr_create_t obex_profile_create_protocol_descriptor_list;
87profile_attr_create_t obex_profile_create_supported_formats_list; 87profile_attr_create_t obex_profile_create_supported_formats_list;
 88profile_attr_create_t bnep_profile_create_protocol_descriptor_list;
88 89
89profile_data_valid_t common_profile_server_channel_valid; 90profile_data_valid_t common_profile_server_channel_valid;
90profile_data_valid_t obex_profile_data_valid; 91profile_data_valid_t obex_profile_data_valid;
91 92
92#endif /* ndef _PROFILE_H_ */ 93#endif /* ndef _PROFILE_H_ */