Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Neighbors.h
Go to the documentation of this file.
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Foundation_IO_Network_Neighbors_h_
5#define _Stroika_Foundation_IO_Network_Neighbors_h_ 1
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
9#include <optional>
10
12#include "Stroika/Foundation/Containers/Collection.h"
13#include "Stroika/Foundation/Containers/Set.h"
17
18/**
19 * \file
20 *
21 * \note Code-Status: <a href="Code-Status.md#Beta">Beta</a>
22 *
23 */
24
26
27 /**
28 * \brief Monitor - either immediately or in the background fetches a list of network neighbors (1 hop away network devices).
29 * Also fetches their hardware address (so like 'arp' kind of but may employ other means)
30 *
31 * \note \em Thread-Safety <a href="Thread-Safety.md#C++-Standard-Thread-Safety">C++-Standard-Thread-Safety</a>
32 */
34 public:
35 /**
36 * Note, though there are no guarantees about the form of a hardware address, we generally prefer emitting
37 * things like ab:cd:ef... for ethernet addresses over what windows sometimes uses, ab-cd-ef...
38 */
39 struct Neighbor {
40 InternetAddress fInternetAddress;
41 String fHardwareAddress;
42 Interface::SystemIDType fInterfaceID;
43
44 public:
45 /**
46 * @see Characters::ToString ();
47 */
48 nonvirtual String ToString () const;
49 };
50
51 public:
52 /**
53 */
54 struct Options {
55 enum class Strategy {
56 eArpProgram,
57#if qStroika_Foundation_Common_Platform_Linux
58 eProcNetArp,
59#endif
60 };
61 optional<Containers::Set<Strategy>> fStategies;
62 optional<Time::Duration> fMaxLatnecy; // if monitoring in the background (e.g. in a thread) this configures polling frequency but maybe ignored)
63
64 // if true, assure results always up to date (as if by polling in the background)
65 // If false, minimize resource usage, and just fetch data on GetNeighbors call
66 // Defaults to false, and @todo NYI (when implemented, use IntervalTimer code)
67 optional<bool> fMonitor;
68
69 // sometimes entries will remain in arp table after they have expired (just with address deleted).
70 // Probably best to not include those
71 optional<bool> fIncludePurgedEntries;
72
73 // On windows, we appear to get bogus hardware addresses for broadcast entries
74 // defaults true
75 optional<bool> fOmitAllFFHardwareAddresses;
76 };
77
78 public:
79 /**
80 */
81 NeighborsMonitor (const Options& options = {});
82
83 public:
84 /**
85 */
86 nonvirtual Containers::Collection<Neighbor> GetNeighbors () const;
87
88 private:
89 class Rep_;
90 shared_ptr<Rep_> fRep_;
91 };
92
93}
94
95/*
96 ********************************************************************************
97 ***************************** Implementation Details ***************************
98 ********************************************************************************
99 */
100#include "Neighbors.inl"
101
102#endif /*_Stroika_Foundation_IO_Network_Neighbors_h_*/
String is like std::u32string, except it is much easier to use, often much more space efficient,...
Definition String.h:201
A Collection<T> is a container to manage an un-ordered collection of items, without equality defined ...
Definition Collection.h:102
Monitor - either immediately or in the background fetches a list of network neighbors (1 hop away net...
Definition Neighbors.h:33