internal uuid_t(UInt16 uuid) { type = StackConsts.SdpType_uint8_t.UUID16; PADDING = new byte[PADDING_SIZEa]; var arr = BitConverter.GetBytes(uuid); value = new byte[ValueLength]; Array.Copy(arr, value, arr.Length); }
//union { // uint16_t uuid16; // uint32_t uuid32; // uint128_t uuid128; //} value; internal uuid_t(Guid uuid) { type = StackConsts.SdpType_uint8_t.UUID128; PADDING = new byte[PADDING_SIZEa]; var netOrder = InTheHand.Net.Sockets.BluetoothListener.HostToNetworkOrder(uuid); var arr = netOrder.ToByteArray(); // Should be ok to not copying this. Debug.Assert(arr.Length == ValueLength); value = arr; }
private static void Map(StackConsts.SdpType_uint8_t sdpDataElementType, out ElementTypeDescriptor etd, out SizeIndex sizeIndex) { const SizeIndex NotUsed = SizeIndex.LengthOneByteOrNil; switch (sdpDataElementType) { // Signed/Unsigned Integer case StackConsts.SdpType_uint8_t.UINT8: etd = ElementTypeDescriptor.UnsignedInteger; sizeIndex = SizeIndex.LengthOneByteOrNil; break; case StackConsts.SdpType_uint8_t.INT8: etd = ElementTypeDescriptor.TwosComplementInteger; sizeIndex = SizeIndex.LengthOneByteOrNil; break; case StackConsts.SdpType_uint8_t.UINT16: etd = ElementTypeDescriptor.UnsignedInteger; sizeIndex = SizeIndex.LengthTwoBytes; break; case StackConsts.SdpType_uint8_t.INT16: etd = ElementTypeDescriptor.TwosComplementInteger; sizeIndex = SizeIndex.LengthTwoBytes; break; case StackConsts.SdpType_uint8_t.UINT32: etd = ElementTypeDescriptor.UnsignedInteger; sizeIndex = SizeIndex.LengthFourBytes; break; case StackConsts.SdpType_uint8_t.INT32: etd = ElementTypeDescriptor.TwosComplementInteger; sizeIndex = SizeIndex.LengthFourBytes; break; case StackConsts.SdpType_uint8_t.UINT64: etd = ElementTypeDescriptor.UnsignedInteger; sizeIndex = SizeIndex.LengthEightBytes; break; case StackConsts.SdpType_uint8_t.INT64: etd = ElementTypeDescriptor.TwosComplementInteger; sizeIndex = SizeIndex.LengthEightBytes; break; case StackConsts.SdpType_uint8_t.UINT128: etd = ElementTypeDescriptor.UnsignedInteger; sizeIndex = SizeIndex.LengthSixteenBytes; break; case StackConsts.SdpType_uint8_t.INT128: etd = ElementTypeDescriptor.TwosComplementInteger; sizeIndex = SizeIndex.LengthSixteenBytes; break; // Strings case StackConsts.SdpType_uint8_t.TEXT_STR_UNSPEC: case StackConsts.SdpType_uint8_t.TEXT_STR8: case StackConsts.SdpType_uint8_t.TEXT_STR16: case StackConsts.SdpType_uint8_t.TEXT_STR32: etd = ElementTypeDescriptor.TextString; sizeIndex = NotUsed; break; case StackConsts.SdpType_uint8_t.URL_STR_UNSPEC: case StackConsts.SdpType_uint8_t.URL_STR8: case StackConsts.SdpType_uint8_t.URL_STR16: case StackConsts.SdpType_uint8_t.URL_STR32: etd = ElementTypeDescriptor.Url; sizeIndex = NotUsed; break; // UUID case StackConsts.SdpType_uint8_t.UUID16: etd = ElementTypeDescriptor.Uuid; sizeIndex = SizeIndex.LengthTwoBytes; break; case StackConsts.SdpType_uint8_t.UUID32: etd = ElementTypeDescriptor.Uuid; sizeIndex = SizeIndex.LengthFourBytes; break; case StackConsts.SdpType_uint8_t.UUID128: etd = ElementTypeDescriptor.Uuid; sizeIndex = SizeIndex.LengthSixteenBytes; break; case StackConsts.SdpType_uint8_t.UUID_UNSPEC: throw new NotSupportedException("UUID_UNSPEC"); // Seq/Alt case StackConsts.SdpType_uint8_t.SEQ_UNSPEC: case StackConsts.SdpType_uint8_t.SEQ8: case StackConsts.SdpType_uint8_t.SEQ16: case StackConsts.SdpType_uint8_t.SEQ32: etd = ElementTypeDescriptor.ElementSequence; sizeIndex = NotUsed; break; case StackConsts.SdpType_uint8_t.ALT_UNSPEC: case StackConsts.SdpType_uint8_t.ALT8: case StackConsts.SdpType_uint8_t.ALT16: case StackConsts.SdpType_uint8_t.ALT32: etd = ElementTypeDescriptor.ElementAlternative; sizeIndex = NotUsed; break; // Nil/Boolean/etc. case StackConsts.SdpType_uint8_t.BOOL: etd = ElementTypeDescriptor.Boolean; sizeIndex = SizeIndex.LengthOneByteOrNil; break; case StackConsts.SdpType_uint8_t.DATA_NIL: etd = ElementTypeDescriptor.Nil; sizeIndex = SizeIndex.LengthOneByteOrNil; break; // default: Debug.Fail("Unexpected SdpType_uint8_t: 0x" + ((int)sdpDataElementType).ToString("X")); etd = ElementTypeDescriptor.Unknown; sizeIndex = SizeIndex.AdditionalUInt32; break; } }