|
1 // Copyright (c) 2004-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 // |
|
15 |
|
16 #ifndef PANAGTUTILS_H |
|
17 #define PANAGTUTILS_H |
|
18 |
|
19 #include <e32std.h> |
|
20 #include <e32base.h> |
|
21 |
|
22 /** |
|
23 @file |
|
24 @note Global panic function and async event helper class for role state machine |
|
25 The async event helper class is used because the main agent class cannot be derived from CActive, so the helper class is just a small proxy to allow the role state machine to handle async events |
|
26 */ |
|
27 |
|
28 namespace PanAgent |
|
29 /** |
|
30 @internalComponent |
|
31 @released |
|
32 @since v8.1 |
|
33 */ |
|
34 { |
|
35 |
|
36 _LIT(KPanAgentName, "PanAgent"); |
|
37 _LIT(KPanAgentPanic, "PanAgentPanic"); |
|
38 |
|
39 enum TPanAgentPanic |
|
40 /** |
|
41 PAN agent panic codes |
|
42 @internalComponent |
|
43 */ |
|
44 { |
|
45 // General panics |
|
46 ENullNifmanNotifyPointer = 0, //< Attempt to use iNotify pointer to nifman when it was null |
|
47 ENullCommdbHandle = 1, //< Attempt to access commdb when the agent has not got a handle yet |
|
48 ENullBnepConnectionManager = 2, //< Attempt to use the BNEP connection manager before the handle has been fetched from the BNEP packet driver |
|
49 EPanAgentDeletedWithDevicesStillAttached = 3, //< Attempt to delete the pan agent when there are still devices in the device array |
|
50 ENullDeviceSelector = 4, //< Attempt to use the device selector when is doesn't exist |
|
51 ENullTAnyPointer = 5, //< Someone's tried to perform a callback with a NULL pointer instead of the this pointer |
|
52 EOldFormatPanRoleBeingUsedInCommdb = 6, //< An old format commdb is being used, which contains a PAN role of 0xffff. This was removed during development (there was no need for EPanRoleUnknown and EPanRoleNone, so they were folded into one). This panic is here purely to stop people using those old commdb databases by mistake. |
|
53 ESomeoneLeftWithoutGivingAReason = 7, //< A state has left, but no-one recorded an error code to indicate what the problem was! |
|
54 EAttemptToDisconnectBeforeConnectComplete = 8, //< Attempt to use the wrong error path - before ConnectComplete() has been called on nifman, all errors should be signalled via there; only once connected should we try to disconnect |
|
55 EAsyncOperationOnOutgoingConnectionStarterWhenItsNotPerformingAnAsyncRequest = 9, //< Attempt to call RunL() or DoCancel() on the outgoing connection starter when it's not doing anything that requires an async operation - this suggests it has got into an incorrect state |
|
56 EDelayedOpenHelperActiveWhenBothListeningAndAcceptingSocketsAreOpen = 10, |
|
57 // PAN role state machine related panics |
|
58 ENoState = 11, //< Attempted call to state when there isn't one |
|
59 EPanAgentRoleStateMachineSelectedUnknownAsLocalRole = 12, //< The PAN agent role state machine selected an illegal role as the local role |
|
60 EPanAgentRoleStateMachineInvalidLocalRole = 13, //< The PAN agent role state machine selected an invalid local role. |
|
61 EDeviceInNegotiatingModeOnEntryToUState = 14, //< Suggests that the negotiating state forgot to update the state of the device in the array when negotiation completed |
|
62 EDeviceInNegotiatingModeOnEntryToGnOrNapState = 15, //< Suggests that the negotiating state forgot to update the state of the device in the array when negotiation completed |
|
63 EDeviceAttemptingToNegotiateThatIsNotInArray = 16, //< Attempt to negotiate by a device that is not in the array |
|
64 EIncomingConnectionListenerStillActiveAtShutdown = 17, //< No-one's cancelled the incoming connection listener before shutting down |
|
65 EActiveDevicesInArrayInInitialisingState = 18, //< There are active devices in the array when the role state machine is in the initialising state (so either there was an incorrect transition to this state in the role state machine, or someone's put entries in the device array in the wrong state) |
|
66 ENegotiatingDevicesInArrayInInitialisingState = 19, //< There are negotiating devices in the array when the role state machine is in the initialising state (so either there was an incorrect transition to this state in the role state machine, or someone's put entries in the device array in the wrong state) |
|
67 EActiveDevicesInArrayInNegotiatingPanUState = 20, //< There are active devices in the array when we are negotiating PAN-U role (in which case we shouldn't be negotiating PAN-U role) |
|
68 EActiveDevicesInArrayInRenegActConnToGnOrNapRoleAtOurBehest = 21, //< There is an active device in the array, and since we negotiating with a device to go to GN/NAP state, there shouldn't be (we're not in GN/NAP state yet!) |
|
69 ENoActiveDeviceInArrayInRenegActConnToURoleAtPeersBehest = 22, //< There is NOT an active device in the array |
|
70 ENoActiveDevicesInArrayInRenegActConnToGnOrNapRoleAtPeersBehest = 23, //< There is NOT an active device in the array |
|
71 EMoreThanOneDeviceInNegotiatingModeInArray = 24, //< There is more than one negotiating device in the array (which there shouldn't be, as negotiation should be serialised) |
|
72 EUnexpectedDeviceInNegotiatingModeInArray = 25, //< A local device is in the negotiating state when it shouldn't be. |
|
73 EDeletingRemoteDeviceWithoutDisconnecting = 26, //< The remote device object has been deleted without disconnecting the remote device first (suggests an incorrect state transition in remote device state machine) |
|
74 ETooManyDevicesAttachedInURole = 27, //< Attempt to enter a PAN-U role with more than one device attached |
|
75 EUnexpectedDeviceActiveReceivedByState = 28, //< DeviceActive() received by state that does not allow active devices |
|
76 EUnexpectedDeviceRoleChangeFailedReceivedByState = 29, //< DeviceRoleChangeFailed() received by state in which devices should not be changing roles |
|
77 EUnexpectedDeviceDisconnectedReceivedByState = 30, //< DeviceDisconnected() received by state that does not allow devices to disconnect |
|
78 EUnexpectedIncomingConnectionFromPeerReceivedByState = 31, //< Incoming connection from peer received by state in which devices should not be receiving incoming connections |
|
79 EUnexpectedRoleChangeRequestFromPeerReceivedByState = 32, //< Role change request from peer received by state in which devices should not be receiving incoming role changes from the peer device |
|
80 EUnexpectedInitiateOutgoingConnectionReceivedByState = 33, //< Initiate outgoing connectionreceived by state in which devices should not be initiating an outgoing connection |
|
81 EUnexpectedPerformLocalRoleChangeRequestReceivedByState = 34, //< Local r ole change request received by state in which devices should not be perfroming a local role change |
|
82 EDeviceActiveCalledByDeviceNotInActiveState = 35, //< A device has sent a DeviceActive() message, but it is not in the Active state |
|
83 EDeviceDisconnectedThatWasNotInArray = 36, |
|
84 ETooManyDevicesAttachedWhenRenegotiatingActiveConnectionForGnOrNapUpgrade = 37, //< The renegotiating active connection for GN/NAP upgrade state can only be used from U role |
|
85 ENoActiveDeviceInArray = 38, //< We're trying to find an active device and there isn't one in the array |
|
86 EShutdownStateNotLastState = 39, //< The PAN agent was deleted without the shutdown state being the last state used. |
|
87 ENoActiveDeviceAfterNegotiationCompleted = 40, //< A DeviceActive() was received, but there is no active device in the array |
|
88 EMoreThanOneActiveDeviceWhenTryingToRenegotiateUToGnOrNapRoleChange = 41, //< We're attempt to upgrade from U to GN/NAP, but there's more than one active device in the array (which is wrong if we've just come out of U role) |
|
89 ETryingToLockBasebandRolesWhenDevicesAreNegotiating = 42, //< Don't want to do this - we should only try locking roles when we're in a non-negotiating state |
|
90 EFixedLocalRoleUForListeningIap = 43, //< A fixed local role is set for a listening IAP. |
|
91 EActiveDeviceThatIsNotInArray = 44, |
|
92 EDeviceNotActive = 45, |
|
93 EInvalidLocalRoleFromRoleChangeRequestFromPeer = 46, //< Invalid role provide to RoleChangeRequestFromPeer method |
|
94 EInvalidRoleForIncomingConnectionFromPeerL = 47, //< Invalid role provide to IncomingConnectionFromPeerL method |
|
95 // PAN remote device state machine related panics |
|
96 ENoRemDevState = 48, //< Attempted call to state when there isn't one |
|
97 ESendingUnknownRoleInRoleRequest = 49, //< Attempt to send EPanRoleUnknown in a role request - this is an absolute no-no |
|
98 ECallToBnepChannelBeforeChannelSetup = 50, //< Attempt to use BNEP channel to remote device before it has been created |
|
99 EUnexpectedAsyncEventReceivedByState = 51, //< A state has received an asynchronous event (from someone signalling the state machine's TRequestStatus), but wasn't expecting to (ie. there's something wrong with the sequence of states) |
|
100 EInvalidReadyForRoleRequestReceived = 52, //< The remote device object has been incorrectly signalled by the main role state machine (the remote device is not in a state where it can performing role negotiation) |
|
101 EInvalidBnepRoleResponseReceived = 53, //< The remote device object has been incorrectly signalled by BNEP indicating the remote device has responded to a role request (this occurs in states where the remote device has not been connected yet) |
|
102 EInvalidBnepRoleRequestReceived = 54, //< The remote device object has been incorrectly signalled by BNEP indicating the remote device has sent us a role request (this occurs in states where the remote device has not been connected yet) |
|
103 EInvalidRemoteDeviceDisconnectReceived = 55, //< The remote device object has been incorrectly signalled by BNEP indicating the remote device has disconnected (this occurs in states where the remote device has not been connected yet) |
|
104 ENoStateOnExit = 56, //< The remote device object is being deleted without being in any state (this suggests a serious problem - why was it created in the first place?) |
|
105 EPanAgentRoleStateMachineReturnedUnexpectedErrorCode = 57, //< The RoleRequest() returned an unexpected error code which we could not handle |
|
106 EChannelControllerAlreadyExists = 58, //< The remote device object is trying to create a BNEP channel when it already has one |
|
107 ETryingToDecideWhetherToBecomePiconetMasterBasedOnInvalidRole = 59, //< like it says, the local role was not U, GN, or NAP |
|
108 ENullRemoteDeviceAddress = 60, //< The address of the remote device is not set |
|
109 EDoubleShutdownAttemptOnDevice = 61, //< Two attempts have been made to use the preallocated shutdown state (perhaps the shutdown state itself left?) |
|
110 ERemoteDeviceDidNotUsePreallocatedShutdownState = 62, //< Attempt to shutdown by using something other than the state machine's internally held shutdown state (someone's new'ed up a shutdown state themselves) |
|
111 ENoNextStateSet = 63, //< No state was chosen as the next state |
|
112 ERoleStateMachineRequestedWeRenegotiateRolesThenReturnedLocked = 64, //< If the role state machine triggers renegotiation on a device it should ensure it is ready to accept a role request (if it isn't, then something's gone very wrong) |
|
113 ERoleStateMachineCalledReadyForRoleRequestThenReturnedLocked = 65, //< The role state machine told us it was unlocked, then returned locked! Must be bug in the role state machine |
|
114 EStillActiveOnExit = 66, //< There's still a request outstanding when we're being deleted! |
|
115 EInvalidResultCodeFromNapUplinkAuthorisationNotifier = 67, //< Invalid result code received from Local Role selection notifier |
|
116 // Local SDP helper class panics |
|
117 EAttemptToRegisterIllegalPanRoleInLocalSdpDatabase = 68, //< Someone's trying to register a local role other than PAN U, GN, or NAP |
|
118 EPanRoleOutOfBounds = 69, //< The PAN role were were sent is invalid, and therefore cannot be used as an index to the SDP registration array |
|
119 // CPanAgtRemDevSelector panics |
|
120 EPanAgtRemDevSelectorNoDevicesToConnect = 70, //The dev selector is asked to make a connection while there is no devices in the list |
|
121 |
|
122 EPanAgtUnexpectedMessage = 71, // An sync message was received from somewhere that was not expected |
|
123 EPanAgtUnexpectedStateChange = 72, // A response from BNEP was received but the state machine was not in a Paused state (meaning something else unexpectedly changed it while we waited) |
|
124 EPanAgtMissingBinding = 73, // There is probably a binding missing between ESock_IP and ESock_BT (also worth checking that there is one between ESock_DIP and ESock_BT) |
|
125 |
|
126 EInvalidRemoteDeviceState = 74, |
|
127 |
|
128 //RNDIS&BT P&S panics |
|
129 EIPBearerCoexistancePropertyIsNotDefined = 75, // The property is not defined when we require it, maybe it's deleted by mistakes. |
|
130 EBTPanIsAlreadyActive = 76, // BT PAN is active in a improper situation. |
|
131 ERndisIsActiveWhenBTPanTriesToBeActive = 77, // Rndis is allready active when BT Pan tries to be active |
|
132 EInvalidIPBearerCoexistanceProperty = 78, // Facing an invalid IP bearer property |
|
133 EClearKeyWhenNoneIsActive = 79, // BT PAN is going to clear the property, but non-service is active |
|
134 EIPBearerCoexistancePropertyCanNotBeDefined = 80, // The property define returns error other than KErrAlreadyExists |
|
135 EIPBearerCoexistancePropertySetFailed = 81, // Setting Property failed |
|
136 EIPBearerCoexistancePropertyGetFailed = 82, // Getting Property failed |
|
137 EPropertyIsNoneIsActiveWhenBTPanIsActive = 83, // Property is none active when BT Pan is active |
|
138 EImproperSituationToSetPropertyToBTPanIsActive = 84, // Set property to BT PAN is active in an improper situation |
|
139 EBTPanInitiateDirectTransitionToRndis = 85, // BT PAN Initiate a direct transition to Rndis |
|
140 ECreatePanCoexistenceConnectionControllerFailed = 86, // Contruct PAN Coexistence connection controller failed during the contruction time |
|
141 EIPBearerCoexistancePropertyShouldnotBePanIsActive = 87, // The P&S key should not be BT PAN active |
|
142 ENoPanConnectionExistsWhileInPanIsActiveCoexistencePandSState = 88, //P&S key is BT PAN active when there is no BT PAN connection existing |
|
143 }; |
|
144 |
|
145 /** |
|
146 Panics raised by state machine default behaviour are multiplied by this |
|
147 factor. The less signifigant digits are then available to carry a state |
|
148 index, allowing more information when fixing defects. |
|
149 |
|
150 For example, a unexpected device active passed to the PAN local state machine may |
|
151 raise panic 'PanAgentPanic 321008' if it occurs in the 'Negotiating Gn Role' state. |
|
152 */ |
|
153 const TInt KStatePanicMultiplier = 10000; |
|
154 |
|
155 /** |
|
156 A delimiter to prevent a panic code of 0 creating ambigious panics. |
|
157 Without this panic code 0 in state 8 and panic code 8 (not in the state |
|
158 machine) would be identical. |
|
159 */ |
|
160 const TInt KStatePanicDelimiter = 1000; // '1' is the delimiter |
|
161 |
|
162 void PanAgentPanic(TPanAgentPanic aPanicCode); |
|
163 void PanAgentPanic(TPanAgentPanic aPanicCode, TInt aState); |
|
164 |
|
165 class MPanAgtTimerCallback |
|
166 /** |
|
167 Callback from timer helper class |
|
168 @internalComponent |
|
169 */ |
|
170 { |
|
171 public: |
|
172 virtual void TimerComplete() = 0; |
|
173 virtual void TimerError(TInt aError) = 0; |
|
174 |
|
175 protected: |
|
176 virtual ~MPanAgtTimerCallback() {}; |
|
177 }; |
|
178 |
|
179 NONSHARABLE_CLASS(CPanAgtTimerHelper) : public CActive |
|
180 /** |
|
181 A helper class for a state that is already using its TRS-type async event for something else |
|
182 @internalComponent |
|
183 */ |
|
184 { |
|
185 public: |
|
186 static CPanAgtTimerHelper* NewL(MPanAgtTimerCallback& aCallback); |
|
187 void SetTimer(TTimeIntervalMicroSeconds32 aInterval); |
|
188 |
|
189 // CActive-derived methods |
|
190 virtual void RunL(); |
|
191 virtual void DoCancel(); |
|
192 |
|
193 private: |
|
194 CPanAgtTimerHelper(MPanAgtTimerCallback& aCallback); |
|
195 void ConstructL(); |
|
196 |
|
197 private: |
|
198 RTimer iTimer; |
|
199 MPanAgtTimerCallback& iCallback; |
|
200 }; |
|
201 |
|
202 } // PanAgent |
|
203 #endif // PANAGTUTILS_H |