35#ifndef _OPENLCB_ALIASALLOCATOR_HXX_
36#define _OPENLCB_ALIASALLOCATOR_HXX_
55 , return_to_reallocation(1)
63 return_to_reallocation = 1;
66 void do_not_reallocate()
68 return_to_reallocation = 0;
74 uint16_t return_to_reallocation : 1;
164 void TEST_finish_pending_allocation();
169 void TEST_add_allocated_alias(
NodeAlias alias);
172 void TEST_set_reserve_unused_alias_count(
unsigned count)
200 Action handle_allocate_for_cid_frame();
205 Action handle_alias_conflict();
210 friend class AsyncAliasAllocatorTest;
213 StateFlowTimer timer_;
225 return static_cast<IfCan *
>(service());
A BarrierNotifiable allows to create a number of child Notifiable and wait for all of them to finish.
Base class for all QMember types that hold data in an expandable format.
An object that can be scheduled on an executor to run.
This class implements a linked list "queue" of buffers.
State flow with a given typed input queue.
Base::Action Action
Allows using Action without having StateFlowBase:: prefix in front of it.
Create this object statically to add an alias allocator to an already statically allocated interface.
Listens to incoming CAN frames and handles alias conflicts.
void send(Buffer< CanMessageData > *message, unsigned priority) override
Entry point to the flow.
This state flow is responsible for reserving node ID aliases.
unsigned cid_frame_sequence_
Which CID frame are we trying to send out. Valid values: 7..4.
NodeID if_id_
48-bit nodeID that we will use for alias reservations.
void clear_reserved_aliases()
Removes all aliases that are reserved but not yet used.
unsigned conflict_detected_
Set to 1 if an incoming frame signals an alias conflict.
Q waitingClients_
Set of client flows that are waiting for allocating an alias.
unsigned reserveUnusedAliases_
How many unused aliases we should reserve.
void return_alias(NodeID id, NodeAlias alias)
Releases a given alias.
BarrierNotifiable n_
Notifiable used for tracking outgoing frames.
void add_allocated_alias(NodeAlias alias)
Call from an alternate alias allocator.
NodeAlias get_new_seed()
Returns a new alias to check from the random sequence.
IfCan * if_can()
Physical interface for sending packets and assigning handlers to received packets.
unsigned num_reserved_aliases()
unsigned seed_
Seed for generating random-looking alias numbers.
void reinit_seed()
Resets the alias allocator to the state it was at construction.
Action entry() override
Entry into the StateFlow activity.
NodeAlias get_allocated_alias(NodeID destination_id, Executable *done)
Allocates an alias from the reserved but unused aliases list.
void next_seed()
Generates the next alias to check in the seed_ variable.
virtual ~AliasAllocator()
Destructor.
Test fixture base class with helper methods for exercising the asynchronous interface code.
Implementation of the OpenLCB interface abstraction for the CAN-bus interface standard.
void set_alias_allocator(AliasAllocator *a)
Sets the alias allocator for this If. Takes ownership of pointer.
size_t g_alias_test_conflicts
Counts the number of aliases that were given up because a conflict has arisen during the allocation.
uint64_t NodeID
48-bit NMRAnet Node ID type
uint16_t NodeAlias
Alias to a 48-bit NMRAnet Node ID type.
Information we know locally about an NMRAnet CAN alias.
uint16_t alias
The current alias.