17 #ifndef HH_SENF_Ext_NetEmu_WirelessInterfaceAPI_ 18 #define HH_SENF_Ext_NetEmu_WirelessInterfaceAPI_ 1 21 #include <boost/ptr_container/ptr_unordered_map.hpp> 29 class WirelessReceiver;
30 class WirelessTransmitter;
31 class EmulatedWirelessInterface;
32 class EmulatedWirelessReceiver;
33 class EmulatedWirelessTransmitter;
34 class ModulationParameterRegistry;
46 :
public boost::equality_comparable<ModulationParameter>,
47 public boost::less_than_comparable<ModulationParameter>
49 typedef boost::uint32_t
id_t;
58 ModulationParameter(std::string
const & _coding,
short _minRssi,
unsigned _rate,
unsigned _bandwidth, boost::uint8_t _linkTypeId, std::string
const & _info =
"");
61 void dump(std::ostream & os)
const;
63 void dumpTableRow(std::ostream & os,
bool is_current_modulation)
const;
74 return id == other.
id;
79 virtual boost::uint16_t v_modulationId()
const = 0;
81 virtual void v_dump(std::ostream & os)
const = 0;
82 virtual void v_dumpTableHeader(std::ostream & os)
const = 0;
83 virtual void v_dumpTableRow(std::ostream & os)
const = 0;
87 :
private boost::noncopyable
99 typedef boost::ptr_unordered_map<ModulationParameter::id_t, ModulationParameter> Modulations;
100 Modulations modulations_;
126 public detail::CommfaceAccess<WirelessReceiver, WirelessTransmitter>
149 Frequency(
unsigned frequencyLower_,
unsigned frequencyUpper_,
unsigned bandwidthLower_,
unsigned bandwidthUpper_);
151 Frequency(
unsigned frequency_,
unsigned bandwidth_);
160 struct FrequenciesIndexes
161 :
public boost::multi_index::indexed_by<
162 boost::multi_index::ordered_non_unique<
163 boost::multi_index::tag<ByLower>,
164 boost::multi_index::composite_key<
166 boost::multi_index::member<Frequency, unsigned, &Frequency::bandwidthLower>,
167 boost::multi_index::member<Frequency, unsigned, &Frequency::frequencyLower> > >,
168 boost::multi_index::ordered_non_unique<
169 boost::multi_index::tag<ByUpper>,
170 boost::multi_index::composite_key<
172 boost::multi_index::member<Frequency, unsigned, &Frequency::bandwidthUpper>,
173 boost::multi_index::member<Frequency, unsigned, &Frequency::frequencyUpper> > > >
176 typedef boost::multi_index_container<Frequency, FrequenciesIndexes> Frequencies;
178 typedef std::pair<unsigned, unsigned> FrequencyInterval;
179 typedef std::set<FrequencyInterval> FrequencyIntervals;
181 struct frequency_is_whitelisted
183 FrequencyIntervals
const & whitelistedFrequencies_;
184 frequency_is_whitelisted(FrequencyIntervals
const & whitelistedFrequencies);
185 bool operator()(
unsigned frequencyLower,
unsigned frequencyUpper);
186 bool operator()(
Frequency const & frequency);
189 typedef std::set<ModulationParameter::id_t> ModulationParameterIds;
192 typedef boost::filter_iterator<frequency_is_whitelisted, Frequencies::const_iterator>
FrequencyIterator;
199 using detail::CommfaceAccess<WirelessReceiver,WirelessTransmitter>::receiver;
200 using detail::CommfaceAccess<WirelessReceiver,WirelessTransmitter>::transmitter;
204 ModulationParameterIds
const & modulationParameterIds()
const;
205 unsigned maxNSS()
const;
210 unsigned frequency()
const;
212 void frequency(
unsigned freq);
213 void frequency(
unsigned freq,
unsigned bw);
215 FrequenciesRange frequencies()
const;
217 void whitelistedFrequencyRange(
unsigned frequencyLower,
unsigned frequencyUpper);
218 void whitelistedChannel(
unsigned frequency,
unsigned bandwidth);
219 void clearWhitelistedFrequencies();
221 void coverageRange(
unsigned distance);
229 void clearRegisteredFrequencies();
230 void clearRegisteredModulations();
232 void registerFrequency(
unsigned frequency,
unsigned bandwidth);
234 void registerFrequency(
unsigned frequencyLower,
unsigned frequencyUpper,
235 unsigned bandwidthLower,
unsigned bandwidthUpper);
245 virtual void v_coverageRange(
unsigned distance) = 0;
247 virtual unsigned v_frequency()
const = 0;
248 virtual unsigned v_bandwidth()
const = 0;
249 virtual void v_frequency(
unsigned freq,
unsigned bw) = 0;
253 void listModulations(std::ostream & os)
const;
254 void listFrequencies(std::ostream & os)
const;
256 void lookupFrequency(
unsigned freq,
unsigned bw)
const;
258 ModulationParameterIds modulationIds_;
259 Frequencies frequencies_;
260 FrequencyIntervals whitelistedFrequencies_;
273 public detail::InterfaceAccess<WirelessInterface>
284 using detail::InterfaceAccess<WirelessInterface>::interface;
298 public detail::InterfaceAccess<WirelessInterface>
309 TxPower(
int _lower,
int _upper);
313 struct TxPowersIndices
314 :
public boost::multi_index::indexed_by<
315 boost::multi_index::ordered_unique<
316 boost::multi_index::member<TxPower, const int, &TxPower::upper> > >
319 typedef boost::multi_index_container<TxPower, TxPowersIndices> TxPowers;
337 void txPower(
int power);
338 TxPowersRange txPowers()
const;
349 void registerTxPower(
int power);
350 void registerTxPower(
int powerLower,
int powerUpper);
361 virtual int v_txPower()
const = 0;
363 virtual void v_txPower(
int power) = 0;
367 using detail::InterfaceAccess<WirelessInterface>::interface;
369 void listTxpowers(std::ostream & os)
const;
std::string info
Arbitrary additional information.
unsigned bandwidth
Bandwidth in KHz.
Emulated wireless transmitter base-class.
const int upper
Transmit power interval upper bound.
bool operator==(ModulationParameter const &other) const
boost::iterator_range< FrequencyIterator > FrequenciesRange
Range of frequency entries.
short minRssi
Minimum RSSI value.
Wireless modulation parameter.
Interface API base class specialization for wireless interfaces.
Transmit power table entry.
unsigned rate
Bitrate in kbit/s.
boost::filter_iterator< frequency_is_whitelisted, Frequencies::const_iterator > FrequencyIterator
TypedInterfaceDecorator< WirelessInterface, Interface::Decorator > Decorator
WirelessInterface base class specific decorator type.
Receive capable wireless interface base class.
void dump(std::ostream &os) const
virtual ~ModulationParameter()
boost::iterator_range< TxPowers::const_iterator > TxPowersRange
unsigned bandwidthLower
Bandwidth interval lower bound.
InterfaceAPI public header.
boost::uint8_t linkTypeId
Interface API base class for receive capable interfaces.
const int lower
Transmit power interval lower bound.
Emulated wireless interface base-class.
bool operator<(ModulationParameter const &other) const
Interface API base class for transmit capable interfaces.
void dumpTableHeader(std::ostream &os) const
static ModulationParameterRegistry & instance()
void dumpTableRow(std::ostream &os, bool is_current_modulation) const
Specialized Interface decorator base-class.
Transmit capable wireless interface base class.
unsigned frequencyLower
Frequency interval lower bound.
ModulationParameter(std::string const &_coding, short _minRssi, unsigned _rate, unsigned _bandwidth, boost::uint8_t _linkTypeId, std::string const &_info="")
unsigned bandwidthUpper
Bandwidth interval upper bound.
unsigned frequencyUpper
Frequency interval upper bound.