blob: f2f46da08c7d8d595ca3aae7e5430570c2d6982f [file] [log] [blame]
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001/****************************************************************************
2
3 (c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
4 www.systec-electronic.com
5
6 Project: openPOWERLINK
7
8 Description: source file for NMT-CN-Userspace-Module
9
10 License:
11
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions
14 are met:
15
16 1. Redistributions of source code must retain the above copyright
17 notice, this list of conditions and the following disclaimer.
18
19 2. Redistributions in binary form must reproduce the above copyright
20 notice, this list of conditions and the following disclaimer in the
21 documentation and/or other materials provided with the distribution.
22
23 3. Neither the name of SYSTEC electronic GmbH nor the names of its
24 contributors may be used to endorse or promote products derived
25 from this software without prior written permission. For written
26 permission, please contact info@systec-electronic.com.
27
28 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
31 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
32 COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
33 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
34 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
35 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
36 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
38 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39 POSSIBILITY OF SUCH DAMAGE.
40
41 Severability Clause:
42
43 If a provision of this License is or becomes illegal, invalid or
44 unenforceable in any jurisdiction, that shall not affect:
45 1. the validity or enforceability in that jurisdiction of any other
46 provision of this License; or
47 2. the validity or enforceability in other jurisdictions of that or
48 any other provision of this License.
49
50 -------------------------------------------------------------------------
51
52 $RCSfile: EplNmtCnu.c,v $
53
54 $Author: D.Krueger $
55
56 $Revision: 1.6 $ $Date: 2008/10/17 15:32:32 $
57
58 $State: Exp $
59
60 Build Environment:
61 GCC V3.4
62
63 -------------------------------------------------------------------------
64
65 Revision History:
66
67 2006/06/09 k.t.: start of the implementation
68
69****************************************************************************/
70
71#include "EplInc.h"
72#include "user/EplNmtCnu.h"
73#include "user/EplDlluCal.h"
74
75#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_CN)) != 0)
76
77/***************************************************************************/
78/* */
79/* */
80/* G L O B A L D E F I N I T I O N S */
81/* */
82/* */
83/***************************************************************************/
84
85//---------------------------------------------------------------------------
86// const defines
87//---------------------------------------------------------------------------
88
89//---------------------------------------------------------------------------
90// local types
91//---------------------------------------------------------------------------
92
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -080093typedef struct {
94 unsigned int m_uiNodeId;
95 tEplNmtuCheckEventCallback m_pfnCheckEventCb;
Daniel Krueger9d7164c2008-12-19 11:41:57 -080096
97} tEplNmtCnuInstance;
98
99//---------------------------------------------------------------------------
100// modul globale vars
101//---------------------------------------------------------------------------
102
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800103static tEplNmtCnuInstance EplNmtCnuInstance_g;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800104
105//---------------------------------------------------------------------------
106// local function prototypes
107//---------------------------------------------------------------------------
108
109static tEplNmtCommand EplNmtCnuGetNmtCommand(tEplFrameInfo * pFrameInfo_p);
110
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800111static BOOL EplNmtCnuNodeIdList(BYTE * pbNmtCommandDate_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800112
113static tEplKernel PUBLIC EplNmtCnuCommandCb(tEplFrameInfo * pFrameInfo_p);
114
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800115//=========================================================================//
116// //
117// P U B L I C F U N C T I O N S //
118// //
119//=========================================================================//
120
121//---------------------------------------------------------------------------
122//
123// Function: EplNmtCnuInit
124//
125// Description: init the first instance of the module
126//
127//
128//
129// Parameters: uiNodeId_p = NodeId of the local node
130//
131//
132// Returns: tEplKernel = errorcode
133//
134//
135// State:
136//
137//---------------------------------------------------------------------------
138EPLDLLEXPORT tEplKernel PUBLIC EplNmtCnuInit(unsigned int uiNodeId_p)
139{
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800140 tEplKernel Ret;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800141
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800142 Ret = EplNmtCnuAddInstance(uiNodeId_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800143
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800144 return Ret;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800145}
146
147//---------------------------------------------------------------------------
148//
149// Function: EplNmtCnuAddInstance
150//
151// Description: init the add new instance of the module
152//
153//
154//
155// Parameters: uiNodeId_p = NodeId of the local node
156//
157//
158// Returns: tEplKernel = errorcode
159//
160//
161// State:
162//
163//---------------------------------------------------------------------------
164EPLDLLEXPORT tEplKernel PUBLIC EplNmtCnuAddInstance(unsigned int uiNodeId_p)
165{
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800166 tEplKernel Ret;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800167
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800168 Ret = kEplSuccessful;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800169
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800170 // reset instance structure
171 EPL_MEMSET(&EplNmtCnuInstance_g, 0, sizeof(EplNmtCnuInstance_g));
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800172
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800173 // save nodeid
174 EplNmtCnuInstance_g.m_uiNodeId = uiNodeId_p;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800175
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800176 // register callback-function for NMT-commands
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800177#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLU)) != 0)
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800178 Ret = EplDlluCalRegAsndService(kEplDllAsndNmtCommand,
179 EplNmtCnuCommandCb,
180 kEplDllAsndFilterLocal);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800181#endif
182
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800183 return Ret;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800184
185}
186
187//---------------------------------------------------------------------------
188//
189// Function: EplNmtCnuDelInstance
190//
191// Description: delte instance of the module
192//
193//
194//
195// Parameters:
196//
197//
198// Returns: tEplKernel = errorcode
199//
200//
201// State:
202//
203//---------------------------------------------------------------------------
204EPLDLLEXPORT tEplKernel PUBLIC EplNmtCnuDelInstance()
205{
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800206 tEplKernel Ret;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800207
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800208 Ret = kEplSuccessful;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800209
210#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLU)) != 0)
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800211 // deregister callback function from DLL
212 Ret = EplDlluCalRegAsndService(kEplDllAsndNmtCommand,
213 NULL, kEplDllAsndFilterNone);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800214#endif
215
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800216 return Ret;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800217}
218
219//---------------------------------------------------------------------------
220//
221// Function: EplNmtCnuSendNmtRequest
222//
223// Description: Send an NMT-Request to the MN
224//
225//
226//
227// Parameters: uiNodeId_p = NodeId of the local node
228// NmtCommand_p = requested NMT-Command
229//
230//
231// Returns: tEplKernel = errorcode
232//
233//
234// State:
235//
236//---------------------------------------------------------------------------
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800237EPLDLLEXPORT tEplKernel PUBLIC EplNmtCnuSendNmtRequest(unsigned int uiNodeId_p,
238 tEplNmtCommand
239 NmtCommand_p)
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800240{
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800241 tEplKernel Ret;
242 tEplFrameInfo NmtRequestFrameInfo;
243 tEplFrame NmtRequestFrame;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800244
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800245 Ret = kEplSuccessful;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800246
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800247 // build frame
248 EPL_MEMSET(&NmtRequestFrame.m_be_abDstMac[0], 0x00, sizeof(NmtRequestFrame.m_be_abDstMac)); // set by DLL
249 EPL_MEMSET(&NmtRequestFrame.m_be_abSrcMac[0], 0x00, sizeof(NmtRequestFrame.m_be_abSrcMac)); // set by DLL
250 AmiSetWordToBe(&NmtRequestFrame.m_be_wEtherType,
251 EPL_C_DLL_ETHERTYPE_EPL);
252 AmiSetByteToLe(&NmtRequestFrame.m_le_bDstNodeId, (BYTE) EPL_C_ADR_MN_DEF_NODE_ID); // node id of the MN
253 AmiSetByteToLe(&NmtRequestFrame.m_le_bMessageType,
254 (BYTE) kEplMsgTypeAsnd);
255 AmiSetByteToLe(&NmtRequestFrame.m_Data.m_Asnd.m_le_bServiceId,
256 (BYTE) kEplDllAsndNmtRequest);
257 AmiSetByteToLe(&NmtRequestFrame.m_Data.m_Asnd.m_Payload.
258 m_NmtRequestService.m_le_bNmtCommandId,
259 (BYTE) NmtCommand_p);
260 AmiSetByteToLe(&NmtRequestFrame.m_Data.m_Asnd.m_Payload.m_NmtRequestService.m_le_bTargetNodeId, (BYTE) uiNodeId_p); // target for the nmt command
261 EPL_MEMSET(&NmtRequestFrame.m_Data.m_Asnd.m_Payload.m_NmtRequestService.
262 m_le_abNmtCommandData[0], 0x00,
263 sizeof(NmtRequestFrame.m_Data.m_Asnd.m_Payload.
264 m_NmtRequestService.m_le_abNmtCommandData));
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800265
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800266 // build info-structure
267 NmtRequestFrameInfo.m_NetTime.m_dwNanoSec = 0;
268 NmtRequestFrameInfo.m_NetTime.m_dwSec = 0;
269 NmtRequestFrameInfo.m_pFrame = &NmtRequestFrame;
270 NmtRequestFrameInfo.m_uiFrameSize = EPL_C_DLL_MINSIZE_NMTREQ; // sizeof(NmtRequestFrame);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800271
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800272 // send NMT-Request
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800273#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLU)) != 0)
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800274 Ret = EplDlluCalAsyncSend(&NmtRequestFrameInfo, // pointer to frameinfo
275 kEplDllAsyncReqPrioNmt); // priority
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800276#endif
277
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800278 return Ret;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800279}
280
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800281//---------------------------------------------------------------------------
282//
283// Function: EplNmtCnuRegisterStateChangeCb
284//
285// Description: register Callback-function go get informed about a
286// NMT-Change-State-Event
287//
288//
289//
290// Parameters: pfnEplNmtStateChangeCb_p = functionpointer
291//
292//
293// Returns: tEplKernel = errorcode
294//
295//
296// State:
297//
298//---------------------------------------------------------------------------
299
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800300EPLDLLEXPORT tEplKernel PUBLIC
301EplNmtCnuRegisterCheckEventCb(tEplNmtuCheckEventCallback
302 pfnEplNmtCheckEventCb_p)
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800303{
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800304 tEplKernel Ret;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800305
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800306 Ret = kEplSuccessful;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800307
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800308 // save callback-function in modul global var
309 EplNmtCnuInstance_g.m_pfnCheckEventCb = pfnEplNmtCheckEventCb_p;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800310
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800311 return Ret;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800312
313}
314
315//=========================================================================//
316// //
317// P R I V A T E F U N C T I O N S //
318// //
319//=========================================================================//
320
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800321//---------------------------------------------------------------------------
322//
323// Function: EplNmtCnuCommandCb
324//
325// Description: callback funktion for NMT-Commands
326//
327//
328//
329// Parameters: pFrameInfo_p = Frame with the NMT-Commando
330//
331//
332// Returns: tEplKernel = errorcode
333//
334//
335// State:
336//
337//---------------------------------------------------------------------------
338static tEplKernel PUBLIC EplNmtCnuCommandCb(tEplFrameInfo * pFrameInfo_p)
339{
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800340 tEplKernel Ret = kEplSuccessful;
341 tEplNmtCommand NmtCommand;
342 BOOL fNodeIdInList;
343 tEplNmtEvent NmtEvent = kEplNmtEventNoEvent;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800344
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800345 if (pFrameInfo_p == NULL) {
346 Ret = kEplNmtInvalidFramePointer;
347 goto Exit;
348 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800349
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800350 NmtCommand = EplNmtCnuGetNmtCommand(pFrameInfo_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800351
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800352 // check NMT-Command
353 switch (NmtCommand) {
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800354
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800355 //------------------------------------------------------------------------
356 // plain NMT state commands
357 case kEplNmtCmdStartNode:
358 { // send NMT-Event to state maschine kEplNmtEventStartNode
359 NmtEvent = kEplNmtEventStartNode;
360 break;
361 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800362
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800363 case kEplNmtCmdStopNode:
364 { // send NMT-Event to state maschine kEplNmtEventStopNode
365 NmtEvent = kEplNmtEventStopNode;
366 break;
367 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800368
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800369 case kEplNmtCmdEnterPreOperational2:
370 { // send NMT-Event to state maschine kEplNmtEventEnterPreOperational2
371 NmtEvent = kEplNmtEventEnterPreOperational2;
372 break;
373 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800374
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800375 case kEplNmtCmdEnableReadyToOperate:
376 { // send NMT-Event to state maschine kEplNmtEventEnableReadyToOperate
377 NmtEvent = kEplNmtEventEnableReadyToOperate;
378 break;
379 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800380
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800381 case kEplNmtCmdResetNode:
382 { // send NMT-Event to state maschine kEplNmtEventResetNode
383 NmtEvent = kEplNmtEventResetNode;
384 break;
385 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800386
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800387 case kEplNmtCmdResetCommunication:
388 { // send NMT-Event to state maschine kEplNmtEventResetCom
389 NmtEvent = kEplNmtEventResetCom;
390 break;
391 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800392
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800393 case kEplNmtCmdResetConfiguration:
394 { // send NMT-Event to state maschine kEplNmtEventResetConfig
395 NmtEvent = kEplNmtEventResetConfig;
396 break;
397 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800398
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800399 case kEplNmtCmdSwReset:
400 { // send NMT-Event to state maschine kEplNmtEventSwReset
401 NmtEvent = kEplNmtEventSwReset;
402 break;
403 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800404
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800405 //------------------------------------------------------------------------
406 // extended NMT state commands
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800407
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800408 case kEplNmtCmdStartNodeEx:
409 {
410 // check if own nodeid is in EPL node list
411 fNodeIdInList =
412 EplNmtCnuNodeIdList(&
413 (pFrameInfo_p->m_pFrame->m_Data.
414 m_Asnd.m_Payload.
415 m_NmtCommandService.
416 m_le_abNmtCommandData[0]));
417 if (fNodeIdInList != FALSE) { // own nodeid in list
418 // send event to process command
419 NmtEvent = kEplNmtEventStartNode;
420 }
421 break;
422 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800423
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800424 case kEplNmtCmdStopNodeEx:
425 { // check if own nodeid is in EPL node list
426 fNodeIdInList =
427 EplNmtCnuNodeIdList(&pFrameInfo_p->m_pFrame->m_Data.
428 m_Asnd.m_Payload.
429 m_NmtCommandService.
430 m_le_abNmtCommandData[0]);
431 if (fNodeIdInList != FALSE) { // own nodeid in list
432 // send event to process command
433 NmtEvent = kEplNmtEventStopNode;
434 }
435 break;
436 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800437
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800438 case kEplNmtCmdEnterPreOperational2Ex:
439 { // check if own nodeid is in EPL node list
440 fNodeIdInList =
441 EplNmtCnuNodeIdList(&pFrameInfo_p->m_pFrame->m_Data.
442 m_Asnd.m_Payload.
443 m_NmtCommandService.
444 m_le_abNmtCommandData[0]);
445 if (fNodeIdInList != FALSE) { // own nodeid in list
446 // send event to process command
447 NmtEvent = kEplNmtEventEnterPreOperational2;
448 }
449 break;
450 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800451
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800452 case kEplNmtCmdEnableReadyToOperateEx:
453 { // check if own nodeid is in EPL node list
454 fNodeIdInList =
455 EplNmtCnuNodeIdList(&pFrameInfo_p->m_pFrame->m_Data.
456 m_Asnd.m_Payload.
457 m_NmtCommandService.
458 m_le_abNmtCommandData[0]);
459 if (fNodeIdInList != FALSE) { // own nodeid in list
460 // send event to process command
461 NmtEvent = kEplNmtEventEnableReadyToOperate;
462 }
463 break;
464 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800465
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800466 case kEplNmtCmdResetNodeEx:
467 { // check if own nodeid is in EPL node list
468 fNodeIdInList =
469 EplNmtCnuNodeIdList(&pFrameInfo_p->m_pFrame->m_Data.
470 m_Asnd.m_Payload.
471 m_NmtCommandService.
472 m_le_abNmtCommandData[0]);
473 if (fNodeIdInList != FALSE) { // own nodeid in list
474 // send event to process command
475 NmtEvent = kEplNmtEventResetNode;
476 }
477 break;
478 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800479
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800480 case kEplNmtCmdResetCommunicationEx:
481 { // check if own nodeid is in EPL node list
482 fNodeIdInList =
483 EplNmtCnuNodeIdList(&pFrameInfo_p->m_pFrame->m_Data.
484 m_Asnd.m_Payload.
485 m_NmtCommandService.
486 m_le_abNmtCommandData[0]);
487 if (fNodeIdInList != FALSE) { // own nodeid in list
488 // send event to process command
489 NmtEvent = kEplNmtEventResetCom;
490 }
491 break;
492 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800493
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800494 case kEplNmtCmdResetConfigurationEx:
495 { // check if own nodeid is in EPL node list
496 fNodeIdInList =
497 EplNmtCnuNodeIdList(&pFrameInfo_p->m_pFrame->m_Data.
498 m_Asnd.m_Payload.
499 m_NmtCommandService.
500 m_le_abNmtCommandData[0]);
501 if (fNodeIdInList != FALSE) { // own nodeid in list
502 // send event to process command
503 NmtEvent = kEplNmtEventResetConfig;
504 }
505 break;
506 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800507
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800508 case kEplNmtCmdSwResetEx:
509 { // check if own nodeid is in EPL node list
510 fNodeIdInList =
511 EplNmtCnuNodeIdList(&pFrameInfo_p->m_pFrame->m_Data.
512 m_Asnd.m_Payload.
513 m_NmtCommandService.
514 m_le_abNmtCommandData[0]);
515 if (fNodeIdInList != FALSE) { // own nodeid in list
516 // send event to process command
517 NmtEvent = kEplNmtEventSwReset;
518 }
519 break;
520 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800521
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800522 //------------------------------------------------------------------------
523 // NMT managing commands
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800524
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800525 // TODO: add functions to process managing command (optional)
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800526
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800527 case kEplNmtCmdNetHostNameSet:
528 {
529 break;
530 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800531
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800532 case kEplNmtCmdFlushArpEntry:
533 {
534 break;
535 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800536
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800537 //------------------------------------------------------------------------
538 // NMT info services
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800539
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800540 // TODO: forward event with infos to the application (optional)
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800541
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800542 case kEplNmtCmdPublishConfiguredCN:
543 {
544 break;
545 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800546
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800547 case kEplNmtCmdPublishActiveCN:
548 {
549 break;
550 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800551
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800552 case kEplNmtCmdPublishPreOperational1:
553 {
554 break;
555 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800556
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800557 case kEplNmtCmdPublishPreOperational2:
558 {
559 break;
560 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800561
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800562 case kEplNmtCmdPublishReadyToOperate:
563 {
564 break;
565 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800566
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800567 case kEplNmtCmdPublishOperational:
568 {
569 break;
570 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800571
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800572 case kEplNmtCmdPublishStopped:
573 {
574 break;
575 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800576
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800577 case kEplNmtCmdPublishEmergencyNew:
578 {
579 break;
580 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800581
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800582 case kEplNmtCmdPublishTime:
583 {
584 break;
585 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800586
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800587 //-----------------------------------------------------------------------
588 // error from MN
589 // -> requested command not supported by MN
590 case kEplNmtCmdInvalidService:
591 {
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800592
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800593 // TODO: errorevent to application
594 break;
595 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800596
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800597 //------------------------------------------------------------------------
598 // default
599 default:
600 {
601 Ret = kEplNmtUnknownCommand;
602 goto Exit;
603 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800604
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800605 } // end of switch(NmtCommand)
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800606
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800607 if (NmtEvent != kEplNmtEventNoEvent) {
608 if (EplNmtCnuInstance_g.m_pfnCheckEventCb != NULL) {
609 Ret = EplNmtCnuInstance_g.m_pfnCheckEventCb(NmtEvent);
610 if (Ret == kEplReject) {
611 Ret = kEplSuccessful;
612 goto Exit;
613 } else if (Ret != kEplSuccessful) {
614 goto Exit;
615 }
616 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800617#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTU)) != 0)
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800618 Ret = EplNmtuNmtEvent(NmtEvent);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800619#endif
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800620 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800621
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800622 Exit:
623 return Ret;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800624
625}
626
627//---------------------------------------------------------------------------
628//
629// Function: EplNmtCnuGetNmtCommand()
630//
631// Description: returns the NMT-Command from the frame
632//
633//
634//
635// Parameters: pFrameInfo_p = pointer to the Frame
636// with the NMT-Command
637//
638//
639// Returns: tEplNmtCommand = NMT-Command
640//
641//
642// State:
643//
644//---------------------------------------------------------------------------
645static tEplNmtCommand EplNmtCnuGetNmtCommand(tEplFrameInfo * pFrameInfo_p)
646{
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800647 tEplNmtCommand NmtCommand;
648 tEplNmtCommandService *pNmtCommandService;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800649
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800650 pNmtCommandService =
651 &pFrameInfo_p->m_pFrame->m_Data.m_Asnd.m_Payload.
652 m_NmtCommandService;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800653
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800654 NmtCommand =
655 (tEplNmtCommand) AmiGetByteFromLe(&pNmtCommandService->
656 m_le_bNmtCommandId);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800657
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800658 return NmtCommand;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800659}
660
661//---------------------------------------------------------------------------
662//
663// Function: EplNmtCnuNodeIdList()
664//
665// Description: check if the own nodeid is set in EPL Node List
666//
667//
668//
669// Parameters: pbNmtCommandDate_p = pointer to the data of the NMT Command
670//
671//
672// Returns: BOOL = TRUE if nodeid is set in EPL Node List
673// FALSE if nodeid not set in EPL Node List
674//
675//
676// State:
677//
678//---------------------------------------------------------------------------
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800679static BOOL EplNmtCnuNodeIdList(BYTE * pbNmtCommandDate_p)
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800680{
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800681 BOOL fNodeIdInList;
682 unsigned int uiByteOffset;
683 BYTE bBitOffset;
684 BYTE bNodeListByte;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800685
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800686 // get byte-offset of the own nodeid in NodeIdList
687 // devide though 8
688 uiByteOffset = (unsigned int)(EplNmtCnuInstance_g.m_uiNodeId >> 3);
689 // get bitoffset
690 bBitOffset = (BYTE) EplNmtCnuInstance_g.m_uiNodeId % 8;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800691
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800692 bNodeListByte = AmiGetByteFromLe(&pbNmtCommandDate_p[uiByteOffset]);
693 if ((bNodeListByte & bBitOffset) == 0) {
694 fNodeIdInList = FALSE;
695 } else {
696 fNodeIdInList = TRUE;
697 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800698
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800699 return fNodeIdInList;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800700}
701
702#endif // #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_CN)) != 0)
703
704// EOF