-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathLinkManagerStateMachineActiveStandby.h
914 lines (824 loc) · 27.6 KB
/
LinkManagerStateMachineActiveStandby.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
/*
* Copyright 2021 (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* ActiveStandbyStateMachine.h
*
* Created on: Oct 18, 2020
* Author: tamer
*/
#ifndef LINK_MANAGER_LINKMANAGERSTATEMACHINEACTIVESTANDBY_H_
#define LINK_MANAGER_LINKMANAGERSTATEMACHINEACTIVESTANDBY_H_
#include <bitset>
#include <functional>
#include <string>
#include <tuple>
#include <vector>
#include <boost/function.hpp>
#include "link_manager/LinkManagerStateMachineBase.h"
#include "link_prober/LinkProber.h"
#include "link_prober/LinkProberState.h"
#include "link_state/LinkState.h"
#include "link_state/LinkStateMachine.h"
#include "mux_state/MuxState.h"
#include "mux_state/MuxStateMachine.h"
namespace test {
class FakeMuxPort;
class MuxManagerTest;
}
namespace mux {
#define ps(compositeState) std::get<0>(compositeState)
#define ms(compositeState) std::get<1>(compositeState)
#define ls(compositeState) std::get<2>(compositeState)
class MuxPort;
}
namespace link_manager
{
/**
*@class ActiveStandbyStateMachine
*
*@brief Composite state machine of LinkProberState, MuxState, and LinkState
*/
class ActiveStandbyStateMachine: public LinkManagerStateMachineBase,
public std::enable_shared_from_this<ActiveStandbyStateMachine>
{
public:
enum class SwitchCause {
PeerHeartbeatMissing,
PeerLinkDown,
TlvSwitchActiveCommand,
LinkDown,
TransceiverDaemonTimeout,
MatchingHardwareState,
ConfigMuxMode,
HarewareStateUnknown,
TimedOscillation,
Count
};
public:
/**
*@method ActiveStandbyStateMachine
*
*@brief class default constructor
*/
ActiveStandbyStateMachine() = delete;
/**
*@method ActiveStandbyStateMachine
*
*@brief class copy constructor
*
*@param ActiveStandbyStateMachine (in) reference to ActiveStandbyStateMachine object to be copied
*/
ActiveStandbyStateMachine(const ActiveStandbyStateMachine &) = delete;
/**
*@method ActiveStandbyStateMachine
*
*@brief class constructor
*
*@param muxPortPtr (in) pointer to container MuxPort object
*@param strand (in) boost serialization object
*@param muxPortConfig (in) reference to MuxPortConfig object
*/
ActiveStandbyStateMachine(
mux::MuxPort *muxPortPtr,
boost::asio::io_service::strand &strand,
common::MuxPortConfig &muxPortConfig
);
/**
*@method ~ActiveStandbyStateMachine
*
*@brief class destructor
*/
virtual ~ActiveStandbyStateMachine() = default;
/**
*@method initializeTransitionFunctionTable
*
*@brief initialize static transition function table
*
*@return none
*/
void initializeTransitionFunctionTable();
private:
/**
*@method setLabel
*
*@brief sets linkmgr State db state
*
*@return none
*/
inline void setLabel(Label label);
/**
*@method enterLinkProberState
*
*@brief force LinkProberState to switch state
*
*@param nextState (in, out) reference to composite state, the state linkProber
* entry will be changed to align with state label provided
*@param label (in) state to switch to
*
*@param forceReset (in) force reset the aligned link prober state
*
*@return none
*/
inline void enterLinkProberState(CompositeState &nextState, link_prober::LinkProberState::Label label, bool forceReset=false);
/**
*@method enterMuxState
*
*@brief force MuxState to switch state
*
*@param nextState (in, out) reference to composite state, the state MuxState
* entry will be changed to align with state label provided
*@param label (in) state to switch to
*
*@return none
*/
inline void enterMuxState(CompositeState &nextState, mux_state::MuxState::Label label);
/**
*@method enterLinkState
*
*@brief force LinkState to switch state
*
*@param nextState (in, out) reference to composite state, the state LinkState
* entry will be changed to align with state label provided
*@param label (in) state to switch to
*
*@return none
*/
inline void enterLinkState(CompositeState &nextState, link_state::LinkState::Label label);
/**
*@method enterMuxWaitState
*
*@brief force MuxState to switch to WaitState
*
*@param nextState (in, out) reference to composite state, the state MuxState
* entry will be changed to WaitState
*
*@return none
*/
inline void enterMuxWaitState(CompositeState &nextState);
/**
*@method switchMuxState
*
*@brief switch Mux to switch via xcvrd to state label provider
*
*@param nextState (in, out) reference to composite state, the state MuxState
* entry will be changed to align with state label provided
*@param label (in) state to switch to
*@param forceSwitch (in) Force switch mux state, used to match the driver state only
*
*@return none
*/
inline void switchMuxState(link_manager::ActiveStandbyStateMachine::SwitchCause cause, CompositeState &nextState, mux_state::MuxState::Label label, bool forceSwitch = false);
/**
* @method shutdownOrRestartLinkProberOnDefaultRoute()
*
* @brief shutdown or restart link prober based on default route state
*
* @return none
*/
void shutdownOrRestartLinkProberOnDefaultRoute();
public:
/**
*@method handleSwssBladeIpv4AddressUpdate
*
*@brief initialize LinkProber component. Note if this is the last component to be initialized,
* state machine will be activated
*
*@return none
*/
void handleSwssBladeIpv4AddressUpdate(boost::asio::ip::address address);
/**
*@method activateStateMachine
*
*@brief activate the state machine by starting the LinkProber. This should be done after all
* components have been initialized.
*
*@return none
*/
void activateStateMachine();
/**
*@method handleStateChange
*
*@brief handles LinkProverEvent
*
*@param state (in) new LinkProberState label
*
*@return none
*/
void handleStateChange(LinkProberEvent &event, link_prober::LinkProberState::Label state);
/**
*@method handleStateChange
*
*@brief handles MuxStateEvent
*
*@param state (in) new MuxState label
*
*@return none
*/
void handleStateChange(MuxStateEvent &event, mux_state::MuxState::Label state);
/**
*@method handleStateChange
*
*@brief handles LinkStateEvent
*
*@param state (in) new LinkState label
*
*@return none
*/
void handleStateChange(LinkStateEvent &event, link_state::LinkState::Label state);
/**
*@method handleGetServerMacNotification
*
*@brief handle get Server MAC address
*
*@param address (in) Server MAC address
*
*@return none
*/
void handleGetServerMacAddressNotification(std::array<uint8_t, ETHER_ADDR_LEN> address);
/**
*@method handleGetMuxStateNotification
*
*@brief handle get MUX state notification
*
*@param label (in) new MuxState label
*
*@return none
*/
void handleGetMuxStateNotification(mux_state::MuxState::Label label);
/**
*@method handleProbeMuxStateNotification
*
*@brief handle probe MUX state notification
*
*@param label (in) new MuxState label
*
*@return none
*/
void handleProbeMuxStateNotification(mux_state::MuxState::Label label);
/**
*@method handleMuxStateNotification
*
*@brief handle MUX state notification
*
*@param label (in) new MuxState label
*
*@return none
*/
void handleMuxStateNotification(mux_state::MuxState::Label label);
/**
*@method handleSwssLinkStateNotification
*
*@brief handle link state change notification
*
*@param label (in) new LinkState label
*
*@return none
*/
void handleSwssLinkStateNotification(const link_state::LinkState::Label label);
/**
* @method handlePeerLinkStateNotification
*
* @brief handle peer link state notification
*
* @param label (in) new peer link state label
*
* @return none
*/
void handlePeerLinkStateNotification(const link_state::LinkState::Label label);
/**
*@method handleMuxConfigNotification
*
*@brief handle MUX configuration change notification
*
*@param mode (in) new MUX config mode
*
*@return none
*/
void handleMuxConfigNotification(const common::MuxPortConfig::Mode mode);
/**
*@method handleSuspendTimerExpiry
*
*@brief handle suspend timer expiry notification from LinkProber
*
*@return none
*/
void handleSuspendTimerExpiry();
/**
*@method handleSwitchActiveCommandCompletion
*
*@brief handle completion of sending switch command to peer ToR
*
*@return none
*/
void handleSwitchActiveCommandCompletion();
/**
*@method handleSwitchActiveRequestEvent
*
*@brief handle switch active request from peer ToR
*
*@return none
*/
void handleSwitchActiveRequestEvent();
/**
* @method handleDefaultRouteStateNotification(const DefaultRoute routeState)
*
* @brief handle default route state notification from routeorch
*
* @param routeState
*
* @return none
*/
void handleDefaultRouteStateNotification(const DefaultRoute routeState);
/**
* @method handlePostPckLossRatioNotification
*
* @brief handle get post pck loss ratio
*
* @param unknownEventCount (in) count of missing icmp packets
* @param expectedPacketCount (in) count of expected icmp packets
*
* @return none
*/
void handlePostPckLossRatioNotification(const uint64_t unknownEventCount, const uint64_t expectedPacketCount);
/**
* @method handleResetLinkProberPckLossCount
*
* @brief reset link prober heartbeat packet loss count
*
* @return none
*/
void handleResetLinkProberPckLossCount();
/**
* @method handleResetSuspendTimer
*
* @brief reset the heartbeat suspend timer
*
* @return none
*/
void handleResetSuspendTimer();
private:
/**
*@method updateMuxLinkmgrState
*
*@brief Update State DB MUX LinkMgr state
*
*@return none
*/
void updateMuxLinkmgrState();
/**
*@method startMuxProbeTimer
*
*@brief start a timer to monitor the MUX state
*
*@param factor factor used to scale the timeout
*
*@return none
*/
inline void startMuxProbeTimer(uint32_t factor = 1);
/**
*@method handleLinkWaitTimeout
*
*@brief handle when LinkProber heartbeats were lost due link down, bad cable, server down or state mismatching
*
*@param errorCode (in) timer error code
*
*@return none
*/
void handleMuxProbeTimeout(boost::system::error_code errorCode);
/**
*@method startMuxWaitTimer
*
*@brief start a timer to timeout xcvrd/orchagent
*
*@param factor factor used to scale the timeout
*
*@return none
*/
inline void startMuxWaitTimer(uint32_t factor = 1);
/**
*@method handleMuxWaitTimeout
*
*@brief handle when xcrvrd/orchagent has timed out responding to linkmgrd.
*
*@param errorCode (in) timer error code
*
*@return none
*/
void handleMuxWaitTimeout(boost::system::error_code errorCode);
/**
*@method startOscillationTimer
*
*@brief when there is no icmp heartbeat, start a timer to oscillate between active and standby
*
*@return none
*/
void startOscillationTimer();
/**
*@method tryCancelOscillationTimerIfAlive
*
*@brief cancel the oscillation timer if it is alive
*
*@return none
*/
inline void tryCancelOscillationTimerIfAlive();
/**
*@method handleOscillationTimeout
*
*@brief handle when oscillation timer expires
*
*@param errorCode (in) timer error code
*
*@return none
*/
void handleOscillationTimeout(boost::system::error_code errorCode);
/**
*@method initLinkProberState
*
*@brief initialize LinkProberState when configuring the composite state machine
*
*@param compositeState (in, out) reference to composite state, the state linkProber
* entry will be changed to align with MuxState
*
*@param forceReset (in) force reset the aligned link prober state
*
*@return none
*/
void initLinkProberState(CompositeState &compositeState, bool forceReset=false);
/**
*@method LinkProberStandbyMuxActiveLinkUpTransitionFunction
*
*@brief transition function when entering {LinkProberStandby, MuxActive, LinkUp} state
*
*@param nextState (in, out) reference to composite state, the state will be changed
* to reflect next new state.
*
*@return none
*/
void LinkProberStandbyMuxActiveLinkUpTransitionFunction(CompositeState &nextState);
/**
*@method LinkProberUnknownMuxActiveLinkUpTransitionFunction
*
*@brief transition function when entering {LinkProberUnknown, MuxActive, LinkUp} state
*
*@param nextState (in, out) reference to composite state, the state will be changed
* to reflect next new state.
*
*@return none
*/
void LinkProberUnknownMuxActiveLinkUpTransitionFunction(CompositeState &nextState);
/**
*@method LinkProberActiveMuxStandbyLinkUpTransitionFunction
*
*@brief transition function when entering {LinkProberActive, MuxStandby, LinkUp} state
*
*@param nextState (in, out) reference to composite state, the state will be changed
* to reflect next new state.
*
*@return none
*/
void LinkProberActiveMuxStandbyLinkUpTransitionFunction(CompositeState &nextState);
/**
*@method LinkProberUnknownMuxStandbyLinkUpTransitionFunction
*
*@brief transition function when entering {LinkProberUnknown, MuxStandby, LinkUp} state
*
*@param nextState (in, out) reference to composite state, the state will be changed
* to reflect next new state.
*
*@return none
*/
void LinkProberUnknownMuxStandbyLinkUpTransitionFunction(CompositeState &nextState);
/**
*@method LinkProberActiveMuxUnknownLinkUpTransitionFunction
*
*@brief transition function when entering {LinkProberActive, MuxUnknown, LinkUp} state
*
*@param nextState (in, out) reference to composite state, the state will be changed
* to reflect next new state.
*
*@return none
*/
void LinkProberActiveMuxUnknownLinkUpTransitionFunction(CompositeState &nextState);
/**
*@method LinkProberStandbyMuxUnknownLinkUpTransitionFunction
*
*@brief transition function when entering {LinkProberStandby, MuxUnknown, LinkUp} state
*
*@param nextState (in, out) reference to composite state, the state will be changed
* to reflect next new state.
*
*@return none
*/
void LinkProberStandbyMuxUnknownLinkUpTransitionFunction(CompositeState &nextState);
/**
*@method LinkProberUnknownMuxUnknownLinkUpTransitionFunction
*
*@brief transition function when entering {LinkProberUnknown, MuxUnknown, LinkUp} state
*
*@param nextState (in, out) reference to composite state, the state will be changed
* to reflect next new state.
*
*@return none
*/
void LinkProberUnknownMuxUnknownLinkUpTransitionFunction(CompositeState &nextState);
/**
*@method LinkProberActiveMuxErrorLinkUpTransitionFunction
*
*@brief transition function when entering {LinkProberActive, MuxError, LinkUp} state
*
*@param nextState (in, out) reference to composite state, the state will be changed
* to reflect next new state.
*
*@return none
*/
void LinkProberActiveMuxErrorLinkUpTransitionFunction(CompositeState &nextState);
/**
*@method LinkProberStandbyMuxErrorLinkUpTransitionFunction
*
*@brief transition function when entering {LinkProberStandby, MuxError, LinkUp} state
*
*@param nextState (in, out) reference to composite state, the state will be changed
* to reflect next new state.
*
*@return none
*/
void LinkProberStandbyMuxErrorLinkUpTransitionFunction(CompositeState &nextState);
/**
*@method LinkProberWaitMuxActiveLinkUpTransitionFunction
*
*@brief transition function when entering {LinkProberWait, MuxActive, LinkUp} state
*
*@param nextState (in, out) reference to composite state, the state will be changed
* to reflect next new state.
*
*@return none
*/
void LinkProberWaitMuxActiveLinkUpTransitionFunction(CompositeState &nextState);
/**
*@method LinkProberWaitMuxStandbyLinkUpTransitionFunction
*
*@brief transition function when entering {LinkProberWait, MuxStandby, LinkUp} state
*
*@param nextState (in, out) reference to composite state, the state will be changed
* to reflect next new state.
*
*@return none
*/
void LinkProberWaitMuxStandbyLinkUpTransitionFunction(CompositeState &nextState);
/**
*@method LinkProberWaitMuxUnknownLinkUpTransitionFunction
*
*@brief transition function when entering {LinkProberWait, MuxUnknown, LinkUp} state
*
*@param nextState (in, out) reference to composite state, the state will be changed
* to reflect next new state.
*
*@return none
*/
void LinkProberWaitMuxUnknownLinkUpTransitionFunction(CompositeState &nextState);
/**
*@method LinkProberUnknownMuxActiveLinkDownTransitionFunction
*
*@brief transition function when entering {LinkProberUnknown, MuxActive, LinkDown} state
*
*@param nextState (in, out) reference to composite state, the state will be changed
* to reflect next new state.
*
*@return none
*/
void LinkProberUnknownMuxActiveLinkDownTransitionFunction(CompositeState &nextState);
/**
*@method LinkProberUnknownMuxStandbyLinkDownTransitionFunction
*
*@brief transition function when entering {LinkProberUnknown, MuxStandby, LinkDown} state
*
*@param nextState (in, out) reference to composite state, the state will be changed
* to reflect next new state.
*
*@return none
*/
void LinkProberUnknownMuxStandbyLinkDownTransitionFunction(CompositeState &nextState);
/**
*@method LinkProberUnknownMuxUnknownLinkDownTransitionFunction
*
*@brief transition function when entering {LinkProberUnknown, MuxUnknown, LinkDown} state
*
*@param nextState (in, out) reference to composite state, the state will be changed
* to reflect next new state.
*
*@return none
*/
void LinkProberUnknownMuxUnknownLinkDownTransitionFunction(CompositeState &nextState);
/**
*@method LinkProberWaitMuxActiveLinkDownTransitionFunction
*
*@brief transition function when entering {LinkProberWait, MuxActive, LinkDown} state
*
*@param nextState (in, out) reference to composite state, the state will be changed
* to reflect next new state.
*
*@return none
*/
void LinkProberWaitMuxActiveLinkDownTransitionFunction(CompositeState &nextState);
/**
*@method LinkProberWaitMuxStandbyLinkDownTransitionFunction
*
*@brief transition function when entering {LinkProberWait, MuxStandby, LinkDown} state
*
*@param nextState (in, out) reference to composite state, the state will be changed
* to reflect next new state.
*
*@return none
*/
void LinkProberWaitMuxStandbyLinkDownTransitionFunction(CompositeState &nextState);
/**
*@method LinkProberWaitMuxUnknownLinkDownTransitionFunction
*
*@brief transition function when entering {LinkProberWait, MuxUnknown, LinkDown} state
*
*@param nextState (in, out) reference to composite state, the state will be changed
* to reflect next new state.
*
*@return none
*/
void LinkProberWaitMuxUnknownLinkDownTransitionFunction(CompositeState &nextState);
private:
// This is used for testing...
friend class mux::MuxPort;
friend class test::FakeMuxPort;
friend class test::MuxManagerTest;
/**
*@method setInitializeProberFnPtr
*
*@brief set new InitializeProberFnPtr for the state machine. This method is used for testing
*
*@param initializeProberFnPtr (in) pointer to new InitializeProberFnPtr
*
*@return none
*/
void setInitializeProberFnPtr(boost::function<void ()> initializeProberFnPtr) {mInitializeProberFnPtr = initializeProberFnPtr;};
/**
*@method setStartProbingFnPtr
*
*@brief set new StartProbingFnPtr for the state machine. This method is used for testing
*
*@param startProbingFnPtr (in) pointer to new StartProbingFnPtr
*
*@return none
*/
void setStartProbingFnPtr(boost::function<void ()> startProbingFnPtr) {mStartProbingFnPtr = startProbingFnPtr;};
/**
*@method setUpdateEthernetFrameFnPtr
*
*@brief set new UpdateEthernetFrameFnPtr for the state machine. This method is used for testing
*
*@param updateEthernetFrameFnPtr (in) pointer to new UpdateEthernetFrameFnPtr
*
*@return none
*/
void setUpdateEthernetFrameFnPtr(boost::function<void ()> updateEthernetFrameFnPtr) {mUpdateEthernetFrameFnPtr = updateEthernetFrameFnPtr;};
/**
*@method setProbePeerTorFnPtr
*
*@brief set new ProbePeerTorFnPtr for the state machine. This method is used for testing
*
*@param probePeerTorFnPtr (in) pointer to new ProbePeerTorFnPtr
*
*@return none
*/
void setProbePeerTorFnPtr(boost::function<void ()> probePeerTorFnPtr) {mProbePeerTorFnPtr = probePeerTorFnPtr;};
/**
*@method setDetectLinkFnPtr
*
*@brief set new DetectLinkFnPtr for the state machine. This method is used for testing
*
*@param detectLinkFnPtr (in) pointer to new DetectLinkFnPtr
*
*@return none
*/
void setDetectLinkFnPtr(boost::function<void ()> detectLinkFnPtr) {mDetectLinkFnPtr = detectLinkFnPtr;};
/**
*@method setSuspendTxFnPtr
*
*@brief set new SuspendTXFnPtr for the state machine. This method is used for testing
*
*@param suspendTxFnPtr (in) pointer to new SuspendTxFnPtr
*
*@return none
*/
void setSuspendTxFnPtr(boost::function<void (uint32_t suspendTime_msec)> suspendTxFnPtr) {mSuspendTxFnPtr = suspendTxFnPtr;};
/**
*@method setResumeTxFnPtr
*
*@brief set new ResumeTXFnPtr for the state machine. This method is used for testing
*
*@param resumeTxFnPtr (in) pointer to new ResumeTxFnPtr
*
*@return none
*/
void setResumeTxFnPtr(boost::function<void ()> resumeTxFnPtr) {mResumeTxFnPtr = resumeTxFnPtr;};
/**
*@method setSendPeerSwitchCommandFnPtr
*
*@brief set new SendPeerSwitchCommandFnPtr for the state machine. This method is used for testing
*
*@param sendPeerSwitchCommandFnPtr (in) pointer to new ResumeTxFnPtr
*
*@return none
*/
void setSendPeerSwitchCommandFnPtr(boost::function<void ()> sendPeerSwitchCommandFnPtr) {
mSendPeerSwitchCommandFnPtr = sendPeerSwitchCommandFnPtr;
};
/**
* @method setShutdownTxFnPtr
*
* @brief set shutdownTxFnPtr. This method is used for testing
*
* @param shutdownTxFnPtr (in) pointer to new ShutdownTxFnPtr
*
* @return none
*/
void setShutdownTxFnPtr(boost::function<void ()> shutdownTxFnPtr) {
mShutdownTxFnPtr = shutdownTxFnPtr;
}
/**
* @method setRestartTxFnPtr
*
* @brief set restartTxFnPtr. This method is used for testing
*
* @param restartTxFnPtr (in) pointer to new restartTxFnPtr
*
* @return none
*/
void setRestartTxFnPtr(boost::function<void ()> restartTxFnPtr) {
mRestartTxFnPtr = restartTxFnPtr;
}
/**
* @method setDecreaseIntervalFnPtr
*
* @brief set new DecreaseIntervalFnPtr for the state machine. This method is used for testing
*
* @param DecreaseIntervalFnPtr (in) pointer to new DecreaseIntervalFnPtr
*
* @return none
*/
void setDecreaseIntervalFnPtr(boost::function<void (uint32_t switchTime_msec)> DecreaseIntervalFnPtr) {
mDecreaseIntervalFnPtr = DecreaseIntervalFnPtr;
};
/**
* @method setRevertIntervalFnPtr
*
* @brief set new RevertIntervalFnPtr for the state machine. This method is used for testing
*
* @param RevertIntervalFnPtr (in) pointer to new RevertIntervalFnPtr
*
* @return none
*/
void setRevertIntervalFnPtr(boost::function<void ()> RevertIntervalFnPtr) {
mRevertIntervalFnPtr = RevertIntervalFnPtr;
};
private:
link_state::LinkState::Label mPeerLinkState = link_state::LinkState::Label::Down;
boost::asio::deadline_timer mDeadlineTimer;
boost::asio::deadline_timer mWaitTimer;
boost::asio::deadline_timer mOscillationTimer;
bool mOscillationTimerAlive = false;
boost::function<void ()> mInitializeProberFnPtr;
boost::function<void ()> mStartProbingFnPtr;
boost::function<void ()> mProbePeerTorFnPtr;
boost::function<void ()> mDetectLinkFnPtr;
boost::function<void (uint32_t suspendTime_msec)> mSuspendTxFnPtr;
boost::function<void ()> mResumeTxFnPtr;
boost::function<void ()> mSendPeerSwitchCommandFnPtr;
boost::function<void ()> mResetIcmpPacketCountsFnPtr;
boost::function<void ()> mShutdownTxFnPtr;
boost::function<void ()> mRestartTxFnPtr;
boost::function<void (uint32_t switchTime_msec)> mDecreaseIntervalFnPtr;
boost::function<void ()> mRevertIntervalFnPtr;
uint32_t mWaitActiveUpCount = 0;
uint32_t mActiveUnknownUpCount = 0;
uint32_t mStandbyUnknownUpCount = 0;
uint32_t mMuxUnknownBackoffFactor = 1;
uint32_t mWaitStandbyUpBackoffFactor = 1;
uint32_t mUnknownActiveUpBackoffFactor = 1;
bool mPendingMuxModeChange = false;
common::MuxPortConfig::Mode mTargetMuxMode = common::MuxPortConfig::Mode::Auto;
mux_state::MuxState::Label mLastSetMuxState = mux_state::MuxState::Label::Wait;
bool mContinuousLinkProberUnknownEvent = false; // When posting unknown_end event, we want to make sure the previous state is unknown.
link_manager::ActiveStandbyStateMachine::SwitchCause mSendSwitchActiveCommandCause;
};
} /* namespace link_manager */
#endif /* LINK_MANAGER_LINKMANAGERSTATEMACHINEACTIVESTANDBY_H_ */