Compare commits
No commits in common. "8cc6b6dd69cee050c16a1c871c986ed933141866" and "5889f942b802a25e07b49b48bf968061c4c2ef97" have entirely different histories.
8cc6b6dd69
...
5889f942b8
32 changed files with 76 additions and 545 deletions
|
@ -1,63 +1,28 @@
|
||||||
protocol "babel" load "./libmmss_proto_babel.so" default;
|
protocol "babel" load "./libmmss_proto_babel.so" default;
|
||||||
|
|
||||||
/* topology:
|
network "net0" {
|
||||||
|
etx min 1.0 max 5.0 sine period 15 m;
|
||||||
C - D
|
|
||||||
/ \
|
|
||||||
A - B G - H
|
|
||||||
\ /
|
|
||||||
E - F
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
network "net_A_B";
|
|
||||||
network "net_B_C";
|
|
||||||
network "net_B_E";
|
|
||||||
network "net_C_D" { etx min 1.0 max 5.0 sine period 20 m; }
|
|
||||||
network "net_D_G";
|
|
||||||
network "net_E_F" { etx min 1.0 max 5.0 sine period 20 m phase 10 m; }
|
|
||||||
network "net_F_G";
|
|
||||||
network "net_G_H";
|
|
||||||
|
|
||||||
|
|
||||||
#network "net1" {
|
|
||||||
# etx min 1.0 max 5.0 sine period 15 m phase 5 m;
|
|
||||||
#}
|
|
||||||
|
|
||||||
#network "net2" {
|
|
||||||
# etx min 1.0 max 5.0 sine period 15 m phase 10 m;
|
|
||||||
#}
|
|
||||||
|
|
||||||
node "A" {
|
|
||||||
interface "mmss_A_B" network "net_A_B" address 00:00:00:00:00:00:01:02;
|
|
||||||
}
|
}
|
||||||
node "B" {
|
|
||||||
interface "mmss_B_A" network "net_A_B" address 00:00:00:00:00:00:02:01;
|
network "net1" {
|
||||||
interface "mmss_B_C" network "net_B_C" address 00:00:00:00:00:00:02:03;
|
etx min 1.0 max 5.0 sine period 15 m phase 5 m;
|
||||||
interface "mmss_B_E" network "net_B_E" address 00:00:00:00:00:00:02:05;
|
|
||||||
}
|
}
|
||||||
node "C" {
|
|
||||||
interface "mmss_C_B" network "net_B_C" address 00:00:00:00:00:00:03:02;
|
network "net2" {
|
||||||
interface "mmss_C_D" network "net_C_D" address 00:00:00:00:00:00:03:04;
|
etx min 1.0 max 5.0 sine period 15 m phase 10 m;
|
||||||
}
|
}
|
||||||
node "D" {
|
|
||||||
interface "mmss_D_C" network "net_C_D" address 00:00:00:00:00:00:04:03;
|
node "node1" {
|
||||||
interface "mmss_D_G" network "net_D_G" address 00:00:00:00:00:00:04:07;
|
interface "mmss1.0" network "net0" address 00:00:00:00:00:00:00:10;
|
||||||
|
interface "mmss1.1" network "net1" address 00:00:00:00:00:00:00:11;
|
||||||
}
|
}
|
||||||
node "E" {
|
|
||||||
interface "mmss_E_B" network "net_B_E" address 00:00:00:00:00:00:05:02;
|
node "node2" {
|
||||||
interface "mmss_E_F" network "net_E_F" address 00:00:00:00:00:00:05:06;
|
interface "mmss2.1" network "net1" address 00:00:00:00:00:00:00:21;
|
||||||
|
interface "mmss2.2" network "net2" address 00:00:00:00:00:00:00:22;
|
||||||
}
|
}
|
||||||
node "F" {
|
|
||||||
interface "mmss_F_E" network "net_E_F" address 00:00:00:00:00:00:06:05;
|
node "node3" {
|
||||||
interface "mmss_F_G" network "net_F_G" address 00:00:00:00:00:00:06:07;
|
interface "mmss3.2" network "net2" address 00:00:00:00:00:00:00:32;
|
||||||
}
|
interface "mmss3.0" network "net0" address 00:00:00:00:00:00:00:30;
|
||||||
node "G" {
|
|
||||||
interface "mmss_G_D" network "net_D_G" address 00:00:00:00:00:00:07:04;
|
|
||||||
interface "mmss_G_F" network "net_F_G" address 00:00:00:00:00:00:07:06;
|
|
||||||
interface "mmss_G_H" network "net_G_H" address 00:00:00:00:00:00:07:08;
|
|
||||||
}
|
|
||||||
node "H" {
|
|
||||||
interface "mmss_H_G" network "net_G_H" address 00:00:00:00:00:00:08:07;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2013-2014, Matthias Schiffer <mschiffer@universe-factory.net>
|
Copyright (c) 2013, Matthias Schiffer <mschiffer@universe-factory.net>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2013-2014, Matthias Schiffer <mschiffer@universe-factory.net>
|
Copyright (c) 2013, Matthias Schiffer <mschiffer@universe-factory.net>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2013-2014, Matthias Schiffer <mschiffer@universe-factory.net>
|
Copyright (c) 2013, Matthias Schiffer <mschiffer@universe-factory.net>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
|
|
@ -11,10 +11,7 @@ add_executable(mmss
|
||||||
iface.cpp
|
iface.cpp
|
||||||
lex.cpp
|
lex.cpp
|
||||||
mmss.cpp
|
mmss.cpp
|
||||||
monitor_file.cpp
|
|
||||||
monitor_log.cpp
|
|
||||||
network.cpp
|
network.cpp
|
||||||
node.cpp
|
|
||||||
protocol.cpp
|
protocol.cpp
|
||||||
${BISON_mmss_config_parse_OUTPUTS}
|
${BISON_mmss_config_parse_OUTPUTS}
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2013-2014, Matthias Schiffer <mschiffer@universe-factory.net>
|
Copyright (c) 2013, Matthias Schiffer <mschiffer@universe-factory.net>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2013-2014, Matthias Schiffer <mschiffer@universe-factory.net>
|
Copyright (c) 2013, Matthias Schiffer <mschiffer@universe-factory.net>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2013-2014, Matthias Schiffer <mschiffer@universe-factory.net>
|
Copyright (c) 2013, Matthias Schiffer <mschiffer@universe-factory.net>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -97,7 +97,7 @@ config: config statement
|
||||||
|
|
|
|
||||||
;
|
;
|
||||||
|
|
||||||
statement: TOK_NETWORK network network_tail
|
statement: TOK_NETWORK network '{' network_config '}'
|
||||||
| TOK_PROTOCOL protocol ';'
|
| TOK_PROTOCOL protocol ';'
|
||||||
| TOK_NODE node '{' node_config '}'
|
| TOK_NODE node '{' node_config '}'
|
||||||
;
|
;
|
||||||
|
@ -108,10 +108,6 @@ network: TOK_STRING {
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
network_tail:
|
|
||||||
'{' network_config '}'
|
|
||||||
| ';'
|
|
||||||
|
|
||||||
network_config: network_config network_statement
|
network_config: network_config network_statement
|
||||||
|
|
|
|
||||||
;
|
;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2013-2014, Matthias Schiffer <mschiffer@universe-factory.net>
|
Copyright (c) 2013, Matthias Schiffer <mschiffer@universe-factory.net>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -29,9 +29,6 @@
|
||||||
#include "network.hpp"
|
#include "network.hpp"
|
||||||
#include "node.hpp"
|
#include "node.hpp"
|
||||||
|
|
||||||
#include "monitor_file.hpp"
|
|
||||||
#include "monitor_log.hpp"
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
@ -68,30 +65,34 @@ static inline const char* get_log_prefix(int log_level) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void context_t::logf(int priority, const char *format, ...) {
|
void context_t::vlogf_orig(const node_t *orig, int priority, const char *format, std::va_list ap) {
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
size_t pos;
|
size_t pos;
|
||||||
|
|
||||||
pos = snprintf_safe(buf, sizeof(buf), "[% 6u.%03u] %s", now()/1000, now()%1000, get_log_prefix(priority));
|
if (orig)
|
||||||
|
pos = snprintf_safe(buf, sizeof(buf), "[% 6u.%03u] %s: %s", now()/1000, now()%1000, orig->get_name().c_str(), get_log_prefix(priority));
|
||||||
|
else
|
||||||
|
pos = snprintf_safe(buf, sizeof(buf), "[% 6u.%03u] %s", now()/1000, now()%1000, get_log_prefix(priority));
|
||||||
|
|
||||||
std::va_list ap;
|
|
||||||
va_start(ap, format);
|
|
||||||
std::vsnprintf(buf+pos, sizeof(buf)-pos, format, ap);
|
std::vsnprintf(buf+pos, sizeof(buf)-pos, format, ap);
|
||||||
va_end(ap);
|
|
||||||
|
|
||||||
std::fprintf(stderr, "%s\n", buf);
|
std::fprintf(stderr, "%s\n", buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void context_t::logf(int priority, const char *format, ...) {
|
||||||
|
std::va_list ap;
|
||||||
|
va_start(ap, format);
|
||||||
|
vlogf_orig(nullptr, priority, format, ap);
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
void context_t::run(int argc, char *argv[]) {
|
void context_t::run(int argc, char *argv[]) {
|
||||||
if (argc != 3) {
|
if (argc != 2) {
|
||||||
std::fprintf(stderr, "usage: %s config logfile\n", argv[0]);
|
std::fprintf(stderr, "usage: %s config\n", argv[0]);
|
||||||
std::exit(1);
|
std::exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
attach_monitor(std::make_shared<monitor_log_t>());
|
|
||||||
attach_monitor(std::make_shared<monitor_file_t>(argv[2]));
|
|
||||||
|
|
||||||
std::shared_ptr<const config_t> conf = config_t::read(this, argv[1]);
|
std::shared_ptr<const config_t> conf = config_t::read(this, argv[1]);
|
||||||
|
|
||||||
if (!conf)
|
if (!conf)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2013-2014, Matthias Schiffer <mschiffer@universe-factory.net>
|
Copyright (c) 2013, Matthias Schiffer <mschiffer@universe-factory.net>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -27,7 +27,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "event.hpp"
|
#include "event.hpp"
|
||||||
#include "monitor.hpp"
|
|
||||||
#include "queue.hpp"
|
#include "queue.hpp"
|
||||||
|
|
||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
|
@ -40,7 +39,6 @@ namespace MMSS {
|
||||||
class context_t : public now_t, public nocopy_t {
|
class context_t : public now_t, public nocopy_t {
|
||||||
private:
|
private:
|
||||||
timeout_queue_t<event_t> event_queue;
|
timeout_queue_t<event_t> event_queue;
|
||||||
std::list<std::shared_ptr<monitor_t>> monitors;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
context_t() : event_queue(this) {}
|
context_t() : event_queue(this) {}
|
||||||
|
@ -49,50 +47,7 @@ public:
|
||||||
event_queue.put(std::move(data), timeout);
|
event_queue.put(std::move(data), timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void attach_monitor(std::shared_ptr<monitor_t> &&monitor) {
|
void vlogf_orig(const node_t *orig, int priority, const char *format, std::va_list ap);
|
||||||
monitors.emplace_back(std::move(monitor));
|
|
||||||
}
|
|
||||||
|
|
||||||
void node_log(node_t *node, int priority, const std::string &message) {
|
|
||||||
for (auto monitor : monitors)
|
|
||||||
monitor->handle_log(node, priority, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
void node_init(node_t *node, const uint8_t *node_id, size_t len) {
|
|
||||||
for (auto monitor : monitors)
|
|
||||||
monitor->handle_init(node, node_id, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
void network(network_t *net) {
|
|
||||||
for (auto monitor : monitors)
|
|
||||||
monitor->handle_network(net);
|
|
||||||
}
|
|
||||||
|
|
||||||
void node_iface(node_t *node, iface_t *iface) {
|
|
||||||
for (auto monitor : monitors)
|
|
||||||
monitor->handle_iface(node, iface);
|
|
||||||
}
|
|
||||||
|
|
||||||
void node_neigh(node_t *node, iface_t *iface, const gmrf_addr_t *addr, float rxcost, float txcost) {
|
|
||||||
for (auto monitor : monitors)
|
|
||||||
monitor->handle_neigh(node, iface, addr, rxcost, txcost);
|
|
||||||
}
|
|
||||||
|
|
||||||
void node_neigh_lost(node_t *node, iface_t *iface, const gmrf_addr_t *addr) {
|
|
||||||
for (auto monitor : monitors)
|
|
||||||
monitor->handle_neigh_lost(node, iface, addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void node_route(node_t *node, const uint8_t *node_id, size_t len, iface_t *iface, const gmrf_addr_t *addr, int metric) {
|
|
||||||
for (auto monitor : monitors)
|
|
||||||
monitor->handle_route(node, node_id, len, iface, addr, metric);
|
|
||||||
}
|
|
||||||
|
|
||||||
void node_route_lost(node_t *node, const uint8_t *node_id, size_t len) {
|
|
||||||
for (auto monitor : monitors)
|
|
||||||
monitor->handle_route_lost(node, node_id, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
void logf(int priority, const char *format, ...);
|
void logf(int priority, const char *format, ...);
|
||||||
|
|
||||||
void run(int argc, char *argv[]);
|
void run(int argc, char *argv[]);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2013-2014, Matthias Schiffer <mschiffer@universe-factory.net>
|
Copyright (c) 2013, Matthias Schiffer <mschiffer@universe-factory.net>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2013-2014, Matthias Schiffer <mschiffer@universe-factory.net>
|
Copyright (c) 2013, Matthias Schiffer <mschiffer@universe-factory.net>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2013-2014, Matthias Schiffer <mschiffer@universe-factory.net>
|
Copyright (c) 2013, Matthias Schiffer <mschiffer@universe-factory.net>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -29,8 +29,6 @@
|
||||||
#include "iface.hpp"
|
#include "iface.hpp"
|
||||||
#include "node.hpp"
|
#include "node.hpp"
|
||||||
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
|
|
||||||
using namespace MMSS;
|
using namespace MMSS;
|
||||||
|
|
||||||
|
@ -84,39 +82,23 @@ void gmrf_logf(gmrf_t *gmrf, int priority, const char *format, ...) {
|
||||||
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
|
node->get_context()->vlogf_orig(node, priority, format, ap);
|
||||||
char *message;
|
|
||||||
if (vasprintf(&message, format, ap) >= 0) {
|
|
||||||
node->get_context()->node_log(node, priority, std::string(message));
|
|
||||||
std::free(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gmrf_debug_init(gmrf_t *gmrf, const uint8_t *node_id, size_t len) {
|
void gmrf_debug_init(gmrf_t *gmrf UNUSED, const uint8_t *node_id UNUSED, size_t len UNUSED) {
|
||||||
node_t *node = static_cast<node_t*>(gmrf);
|
|
||||||
node->get_context()->node_init(node, node_id, len);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gmrf_debug_neigh(gmrf_t *gmrf, gmrf_iface_t *iface, const gmrf_addr_t *addr, float rxcost, float txcost) {
|
void gmrf_debug_neigh(gmrf_t *gmrf UNUSED, gmrf_iface_t *iface UNUSED, const gmrf_addr_t *addr UNUSED, float rxcost UNUSED, float txcost UNUSED) {
|
||||||
node_t *node = static_cast<node_t*>(gmrf);
|
|
||||||
node->get_context()->node_neigh(node, static_cast<iface_t*>(iface), addr, rxcost, txcost);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gmrf_debug_neigh_lost(gmrf_t *gmrf, gmrf_iface_t *iface, const gmrf_addr_t *addr) {
|
void gmrf_debug_neigh_lost(gmrf_t *gmrf UNUSED, gmrf_iface_t *iface UNUSED, const gmrf_addr_t *addr UNUSED) {
|
||||||
node_t *node = static_cast<node_t*>(gmrf);
|
|
||||||
node->get_context()->node_neigh_lost(node, static_cast<iface_t*>(iface), addr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gmrf_debug_route(gmrf_t *gmrf, const uint8_t *node_id, size_t len, gmrf_iface_t *iface, const gmrf_addr_t *addr, int metric) {
|
void gmrf_debug_route(gmrf_t *gmrf UNUSED, const uint8_t *node_id UNUSED, size_t len UNUSED, gmrf_iface_t *iface UNUSED, const gmrf_addr_t *addr UNUSED, int metric UNUSED) {
|
||||||
node_t *node = static_cast<node_t*>(gmrf);
|
|
||||||
node->get_context()->node_route(node, node_id, len, static_cast<iface_t*>(iface), addr, metric);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gmrf_debug_route_lost(gmrf_t *gmrf, const uint8_t *node_id, size_t len) {
|
void gmrf_debug_route_lost(gmrf_t *gmrf UNUSED, const uint8_t *node_id UNUSED, size_t len UNUSED) {
|
||||||
node_t *node = static_cast<node_t*>(gmrf);
|
|
||||||
node->get_context()->node_route_lost(node, node_id, len);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2013-2014, Matthias Schiffer <mschiffer@universe-factory.net>
|
Copyright (c) 2013, Matthias Schiffer <mschiffer@universe-factory.net>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2013-2014, Matthias Schiffer <mschiffer@universe-factory.net>
|
Copyright (c) 2013, Matthias Schiffer <mschiffer@universe-factory.net>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
|
10
mmss/lex.cpp
10
mmss/lex.cpp
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2013-2014, Matthias Schiffer <mschiffer@universe-factory.net>
|
Copyright (c) 2012-2014, Matthias Schiffer <mschiffer@universe-factory.net>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -123,7 +123,7 @@ int lex_t::io_error(YYSTYPE *yylval) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int lex_t::syntax_error(YYSTYPE *yylval) {
|
int lex_t::syntax_error(YYSTYPE *yylval) {
|
||||||
if (std::ferror(file))
|
if (ferror(file))
|
||||||
return io_error(yylval);
|
return io_error(yylval);
|
||||||
|
|
||||||
yylval->error = "syntax error";
|
yylval->error = "syntax error";
|
||||||
|
@ -143,7 +143,7 @@ int lex_t::consume_comment(YYSTYPE *yylval, YYLTYPE *yylloc) {
|
||||||
prev = current();
|
prev = current();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (std::ferror(file))
|
if (ferror(file))
|
||||||
return io_error(yylval);
|
return io_error(yylval);
|
||||||
|
|
||||||
yylval->error = "unterminated block comment";
|
yylval->error = "unterminated block comment";
|
||||||
|
@ -170,7 +170,7 @@ int lex_t::parse_string(YYSTYPE *yylval, YYLTYPE *yylloc) {
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (!next(yylloc, true)) {
|
if (!next(yylloc, true)) {
|
||||||
std::free(buf);
|
free(buf);
|
||||||
return unterminated_string(yylval);
|
return unterminated_string(yylval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ int lex_t::parse_float(YYSTYPE *yylval, YYLTYPE *yylloc) {
|
||||||
yylval->fnum = std::strtof(token, &endptr);
|
yylval->fnum = std::strtof(token, &endptr);
|
||||||
|
|
||||||
bool ok = !*endptr;
|
bool ok = !*endptr;
|
||||||
std::free(token);
|
free(token);
|
||||||
|
|
||||||
if (!ok)
|
if (!ok)
|
||||||
return syntax_error(yylval);
|
return syntax_error(yylval);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2013-2014, Matthias Schiffer <mschiffer@universe-factory.net>
|
Copyright (c) 2012-2014, Matthias Schiffer <mschiffer@universe-factory.net>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2013-2014, Matthias Schiffer <mschiffer@universe-factory.net>
|
Copyright (c) 2013, Matthias Schiffer <mschiffer@universe-factory.net>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
|
|
@ -1,54 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright (c) 2013-2014, Matthias Schiffer <mschiffer@universe-factory.net>
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
1. Redistributions of source code must retain the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer.
|
|
||||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer in the documentation
|
|
||||||
and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "types.hpp"
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
|
|
||||||
namespace MMSS {
|
|
||||||
|
|
||||||
class monitor_t : public nocopy_t {
|
|
||||||
public:
|
|
||||||
virtual ~monitor_t() {}
|
|
||||||
|
|
||||||
virtual void handle_log(node_t *node, int priority, const std::string &message) = 0;
|
|
||||||
|
|
||||||
virtual void handle_init(node_t *node, const uint8_t *node_id, size_t len) = 0;
|
|
||||||
|
|
||||||
virtual void handle_network(network_t *net) = 0;
|
|
||||||
virtual void handle_iface(node_t *node, iface_t *iface) = 0;
|
|
||||||
|
|
||||||
virtual void handle_neigh(node_t *node, iface_t *iface, const gmrf_addr_t *addr, float rxcost, float txcost) = 0;
|
|
||||||
virtual void handle_neigh_lost(node_t *node, iface_t *iface, const gmrf_addr_t *addr) = 0;
|
|
||||||
|
|
||||||
virtual void handle_route(node_t *node, const uint8_t *node_id, size_t len, iface_t *iface, const gmrf_addr_t *addr, int metric) = 0;
|
|
||||||
virtual void handle_route_lost(node_t *node, const uint8_t *node_id, size_t len) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,103 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright (c) 2013-2014, Matthias Schiffer <mschiffer@universe-factory.net>
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
1. Redistributions of source code must retain the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer.
|
|
||||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer in the documentation
|
|
||||||
and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "monitor_file.hpp"
|
|
||||||
#include "context.hpp"
|
|
||||||
#include "node.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
namespace MMSS {
|
|
||||||
|
|
||||||
monitor_file_t::monitor_file_t(const std::string &filename) {
|
|
||||||
file = std::fopen(filename.c_str(), "w");
|
|
||||||
|
|
||||||
if (!file) {
|
|
||||||
std::fprintf(stderr, "monitor_file: unable to open output file\n");
|
|
||||||
std::exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
monitor_file_t::~monitor_file_t() {
|
|
||||||
std::fclose(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
void monitor_file_t::handle_log(node_t *node, int priority, const std::string &message) {
|
|
||||||
std::fprintf(file, "%llu LOG %s %i %s\n", (unsigned long long)node->get_context()->now(), node->get_name().c_str(), priority, message.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
void monitor_file_t::handle_init(node_t *node, const uint8_t *node_id, size_t len) {
|
|
||||||
std::fprintf(file, "%llu INIT %s ", (unsigned long long)node->get_context()->now(), node->get_name().c_str());
|
|
||||||
for (size_t i = 0; i < len; i++)
|
|
||||||
std::fprintf(file, "%02x", node_id[i]);
|
|
||||||
std::fprintf(file, "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void monitor_file_t::handle_network(network_t *net) {
|
|
||||||
std::fprintf(file, "%llu NETWORK %s\n", (unsigned long long)net->get_context()->now(), net->get_name().c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
void monitor_file_t::handle_iface(node_t *node, iface_t *iface) {
|
|
||||||
std::fprintf(file, "%llu IFACE %s %s %s ", (unsigned long long)node->get_context()->now(), node->get_name().c_str(), iface->get_name().c_str(), iface->get_network()->get_name().c_str());
|
|
||||||
|
|
||||||
const gmrf_addr_t *addr = iface->get_address();
|
|
||||||
for (size_t i = 0; i < GMRF_ADDR_LEN; i++)
|
|
||||||
std::fprintf(file, "%02x", addr->d[i]);
|
|
||||||
|
|
||||||
std::fprintf(file, "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void monitor_file_t::handle_neigh(node_t *node, iface_t *iface, const gmrf_addr_t *addr, float rxcost, float txcost) {
|
|
||||||
std::fprintf(file, "%llu NEIGH %s %s ", (unsigned long long)node->get_context()->now(), node->get_name().c_str(), iface->get_name().c_str());
|
|
||||||
for (size_t i = 0; i < GMRF_ADDR_LEN; i++)
|
|
||||||
std::fprintf(file, "%02x", addr->d[i]);
|
|
||||||
std::fprintf(file, " %f %f\n", rxcost, txcost);
|
|
||||||
}
|
|
||||||
|
|
||||||
void monitor_file_t::handle_neigh_lost(node_t *node, iface_t *iface, const gmrf_addr_t *addr) {
|
|
||||||
std::fprintf(file, "%llu NEIGH %s %s ", (unsigned long long)node->get_context()->now(), node->get_name().c_str(), iface->get_name().c_str());
|
|
||||||
for (size_t i = 0; i < GMRF_ADDR_LEN; i++)
|
|
||||||
std::fprintf(file, "%02x", addr->d[i]);
|
|
||||||
std::fprintf(file, " LOST\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void monitor_file_t::handle_route(node_t *node, const uint8_t *node_id, size_t len, iface_t *iface, const gmrf_addr_t *addr, int metric) {
|
|
||||||
std::fprintf(file, "%llu ROUTE %s ", (unsigned long long)node->get_context()->now(), node->get_name().c_str());
|
|
||||||
for (size_t i = 0; i < len; i++)
|
|
||||||
std::fprintf(file, "%02x", node_id[i]);
|
|
||||||
std::fprintf(file, " %s ", iface->get_name().c_str());
|
|
||||||
for (size_t i = 0; i < GMRF_ADDR_LEN; i++)
|
|
||||||
std::fprintf(file, "%02x", addr->d[i]);
|
|
||||||
std::fprintf(file, " %i\n", metric);
|
|
||||||
}
|
|
||||||
|
|
||||||
void monitor_file_t::handle_route_lost(node_t *node, const uint8_t *node_id, size_t len) {
|
|
||||||
std::fprintf(file, "%llu ROUTE %s ", (unsigned long long)node->get_context()->now(), node->get_name().c_str());
|
|
||||||
for (size_t i = 0; i < len; i++)
|
|
||||||
std::fprintf(file, "%02x", node_id[i]);
|
|
||||||
std::fprintf(file, " LOST\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,58 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright (c) 2013-2014, Matthias Schiffer <mschiffer@universe-factory.net>
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
1. Redistributions of source code must retain the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer.
|
|
||||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer in the documentation
|
|
||||||
and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "monitor.hpp"
|
|
||||||
|
|
||||||
#include <cstdio>
|
|
||||||
|
|
||||||
|
|
||||||
namespace MMSS {
|
|
||||||
|
|
||||||
class monitor_file_t : public monitor_t {
|
|
||||||
private:
|
|
||||||
std::FILE *file;
|
|
||||||
|
|
||||||
public:
|
|
||||||
monitor_file_t(const std::string &filename);
|
|
||||||
virtual ~monitor_file_t();
|
|
||||||
|
|
||||||
virtual void handle_log(node_t *node, int priority, const std::string &message);
|
|
||||||
|
|
||||||
virtual void handle_init(node_t *node, const uint8_t *node_id, size_t len);
|
|
||||||
|
|
||||||
virtual void handle_network(network_t *net);
|
|
||||||
virtual void handle_iface(node_t *node, iface_t *iface);
|
|
||||||
|
|
||||||
virtual void handle_neigh(node_t *node, iface_t *iface, const gmrf_addr_t *addr, float rxcost, float txcost);
|
|
||||||
virtual void handle_neigh_lost(node_t *node, iface_t *iface, const gmrf_addr_t *addr);
|
|
||||||
|
|
||||||
virtual void handle_route(node_t *node, const uint8_t *node_id, size_t len, iface_t *iface, const gmrf_addr_t *addr, int metric);
|
|
||||||
virtual void handle_route_lost(node_t *node, const uint8_t *node_id, size_t len);
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,60 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright (c) 2013-2014, Matthias Schiffer <mschiffer@universe-factory.net>
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
1. Redistributions of source code must retain the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer.
|
|
||||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer in the documentation
|
|
||||||
and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "monitor_log.hpp"
|
|
||||||
#include "context.hpp"
|
|
||||||
#include "node.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
namespace MMSS {
|
|
||||||
|
|
||||||
void monitor_log_t::handle_log(node_t *node, int priority, const std::string &message) {
|
|
||||||
if (priority < LOG_DEBUG)
|
|
||||||
node->get_context()->logf(priority, "%s: %s", node->get_name().c_str(), message.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
void monitor_log_t::handle_init(node_t *node UNUSED, const uint8_t *node_id UNUSED, size_t len UNUSED) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void monitor_log_t::handle_network(network_t *net UNUSED) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void monitor_log_t::handle_iface(node_t *node UNUSED, iface_t *iface UNUSED) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void monitor_log_t::handle_neigh(node_t *node UNUSED, iface_t *iface UNUSED, const gmrf_addr_t *addr UNUSED, float rxcost UNUSED, float txcost UNUSED) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void monitor_log_t::handle_neigh_lost(node_t *node UNUSED, iface_t *iface UNUSED, const gmrf_addr_t *addr UNUSED) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void monitor_log_t::handle_route(node_t *node UNUSED, const uint8_t *node_id UNUSED, size_t len UNUSED, iface_t *iface UNUSED, const gmrf_addr_t *addr UNUSED, int metric UNUSED) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void monitor_log_t::handle_route_lost(node_t *node UNUSED, const uint8_t *node_id UNUSED, size_t len UNUSED) {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,49 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright (c) 2013-2014, Matthias Schiffer <mschiffer@universe-factory.net>
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
1. Redistributions of source code must retain the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer.
|
|
||||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer in the documentation
|
|
||||||
and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "monitor.hpp"
|
|
||||||
|
|
||||||
namespace MMSS {
|
|
||||||
|
|
||||||
class monitor_log_t : public monitor_t {
|
|
||||||
public:
|
|
||||||
virtual void handle_log(node_t *node, int priority, const std::string &message);
|
|
||||||
|
|
||||||
virtual void handle_init(node_t *node, const uint8_t *node_id, size_t len);
|
|
||||||
|
|
||||||
virtual void handle_network(network_t *net);
|
|
||||||
virtual void handle_iface(node_t *node, iface_t *iface);
|
|
||||||
|
|
||||||
virtual void handle_neigh(node_t *node, iface_t *iface, const gmrf_addr_t *addr, float rxcost, float txcost);
|
|
||||||
virtual void handle_neigh_lost(node_t *node, iface_t *iface, const gmrf_addr_t *addr);
|
|
||||||
|
|
||||||
virtual void handle_route(node_t *node, const uint8_t *node_id, size_t len, iface_t *iface, const gmrf_addr_t *addr, int metric);
|
|
||||||
virtual void handle_route_lost(node_t *node, const uint8_t *node_id, size_t len);
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2013-2014, Matthias Schiffer <mschiffer@universe-factory.net>
|
Copyright (c) 2013, Matthias Schiffer <mschiffer@universe-factory.net>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -34,11 +34,6 @@
|
||||||
|
|
||||||
namespace MMSS {
|
namespace MMSS {
|
||||||
|
|
||||||
network_t::network_t(context_t *mmss0, const std::string &name0, unsigned rand_seed0)
|
|
||||||
: mmss(mmss0), name(name0), mtu(1500), rand_seed(rand_seed0), etx_min(1), etx_max(1) {
|
|
||||||
mmss->network(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
float network_t::get_etx() const {
|
float network_t::get_etx() const {
|
||||||
if (etx_min == etx_max)
|
if (etx_min == etx_max)
|
||||||
return etx_min;
|
return etx_min;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2013-2014, Matthias Schiffer <mschiffer@universe-factory.net>
|
Copyright (c) 2013, Matthias Schiffer <mschiffer@universe-factory.net>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -57,7 +57,8 @@ private:
|
||||||
void enqueue(const void *data, size_t len, const iface_t *src_iface, const std::shared_ptr<iface_t> &dest_iface);
|
void enqueue(const void *data, size_t len, const iface_t *src_iface, const std::shared_ptr<iface_t> &dest_iface);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
network_t(context_t *mmss0, const std::string &name0, unsigned rand_seed0);
|
network_t(context_t *mmss0, const std::string &name0, unsigned rand_seed0)
|
||||||
|
: mmss(mmss0), name(name0), mtu(1500), rand_seed(rand_seed0), etx_min(1), etx_max(1) {}
|
||||||
|
|
||||||
void set_packet_loss(float etx) {
|
void set_packet_loss(float etx) {
|
||||||
etx_min = etx_max = etx;
|
etx_min = etx_max = etx;
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright (c) 2013-2014, Matthias Schiffer <mschiffer@universe-factory.net>
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
1. Redistributions of source code must retain the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer.
|
|
||||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer in the documentation
|
|
||||||
and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "node.hpp"
|
|
||||||
#include "context.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
namespace MMSS {
|
|
||||||
|
|
||||||
gmrf_iface_state_t * node_t::add_iface(const std::shared_ptr<iface_t> &iface) {
|
|
||||||
interfaces.insert(iface);
|
|
||||||
mmss->node_iface(this, iface.get());
|
|
||||||
return proto->add_iface(gmrf_ctx, iface.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2013-2014, Matthias Schiffer <mschiffer@universe-factory.net>
|
Copyright (c) 2013, Matthias Schiffer <mschiffer@universe-factory.net>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -59,7 +59,10 @@ public:
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
gmrf_iface_state_t* add_iface(const std::shared_ptr<iface_t> &iface);
|
gmrf_iface_state_t* add_iface(const std::shared_ptr<iface_t> &iface) {
|
||||||
|
interfaces.insert(iface);
|
||||||
|
return proto->add_iface(gmrf_ctx, iface.get());
|
||||||
|
}
|
||||||
|
|
||||||
context_t* get_context() const {
|
context_t* get_context() const {
|
||||||
return mmss;
|
return mmss;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2013-2014, Matthias Schiffer <mschiffer@universe-factory.net>
|
Copyright (c) 2013, Matthias Schiffer <mschiffer@universe-factory.net>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2013-2014, Matthias Schiffer <mschiffer@universe-factory.net>
|
Copyright (c) 2013, Matthias Schiffer <mschiffer@universe-factory.net>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2013-2014, Matthias Schiffer <mschiffer@universe-factory.net>
|
Copyright (c) 2013, Matthias Schiffer <mschiffer@universe-factory.net>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2013-2014, Matthias Schiffer <mschiffer@universe-factory.net>
|
Copyright (c) 2013, Matthias Schiffer <mschiffer@universe-factory.net>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2013-2014, Matthias Schiffer <mschiffer@universe-factory.net>
|
Copyright (c) 2013, Matthias Schiffer <mschiffer@universe-factory.net>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -56,7 +56,6 @@ private:
|
||||||
class context_t;
|
class context_t;
|
||||||
class config_t;
|
class config_t;
|
||||||
class iface_t;
|
class iface_t;
|
||||||
class monitor_t;
|
|
||||||
class network_t;
|
class network_t;
|
||||||
class node_t;
|
class node_t;
|
||||||
class now_t;
|
class now_t;
|
||||||
|
|
Reference in a new issue