|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Implements the TAvctpSockAddr to TSockAddr munging |
|
15 // This is because all ESOCK functions that take a TSockAddr will only |
|
16 // pass sizeof(TSockAddr) bytes through. |
|
17 // |
|
18 // |
|
19 |
|
20 /** |
|
21 @file |
|
22 @internalTechnology |
|
23 */ |
|
24 |
|
25 #include <bluetoothav.h> |
|
26 #include <bluetooth/avctptypes.h> |
|
27 |
|
28 using namespace SymbianAvctp; |
|
29 |
|
30 EXPORT_C TAvctpSockAddr::TAvctpSockAddr() |
|
31 /** |
|
32 c'tor |
|
33 */ |
|
34 { |
|
35 SetPort(0); |
|
36 } |
|
37 |
|
38 EXPORT_C TAvctpSockAddr::TAvctpSockAddr(const TSockAddr& aAddr) |
|
39 : TBTSockAddr(aAddr) |
|
40 /** |
|
41 c'tor |
|
42 */ |
|
43 { |
|
44 } |
|
45 |
|
46 EXPORT_C TAvctpSockAddr& TAvctpSockAddr::Cast(const TSockAddr& aAddr) |
|
47 { |
|
48 return *((TAvctpSockAddr *)&aAddr); |
|
49 } |
|
50 |
|
51 EXPORT_C TPid TAvctpSockAddr::Pid() const |
|
52 { |
|
53 return static_cast<TPid>(TSockAddr::Port() & 0xFFFF); |
|
54 } |
|
55 |
|
56 EXPORT_C void TAvctpSockAddr::SetPid(const TPid aPid) |
|
57 { |
|
58 TSockAddr::SetPort(Port() | (aPid & 0xFFFF)); |
|
59 } |
|
60 |
|
61 EXPORT_C TInt TAvctpSockAddr::Channel() const |
|
62 { |
|
63 // get from upper 16bits of Port |
|
64 return static_cast<TInt>((TSockAddr::Port() >> 16) & 0xffff); |
|
65 } |
|
66 |
|
67 EXPORT_C void TAvctpSockAddr::SetChannel(TInt aChannel) |
|
68 { |
|
69 // store in upper 16bits of Port |
|
70 TUint port = Port(); |
|
71 port &= 0x0000ffff; |
|
72 TSockAddr::SetPort(port | ((aChannel & 0xffff) << 16)); |
|
73 } |
|
74 |
|
75 // EOF |