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
|
/*
* Copyright (C) 2005 Hugo Santos <hugo@fivebits.net>
* $Id: dbeacon.h 399 2007-06-25 00:32:38Z hugo $
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*/
#ifndef _dbeacon_h_
#define _dbeacon_h_
#if __FreeBSD_version <= 500042
#include <inttypes.h>
#else
#include <stdint.h>
#endif
#include <string>
#include <map>
#include "address.h"
struct Stats {
Stats();
uint64_t timestamp, lastupdate;
float avgdelay, avgjitter, avgloss, avgdup, avgooo;
bool valid;
uint8_t rttl;
void check_validity(uint64_t);
};
struct beaconExternalStats {
beaconExternalStats();
uint64_t lastupdate;
uint32_t age;
Stats ASM, SSM;
bool identified;
std::string name, contact;
};
struct beaconMcastState {
beaconMcastState();
uint32_t lastseq;
uint32_t packetcount, packetcountreal;
uint32_t pointer;
int lastdelay, lastjitter, lastloss, lastdup, lastooo;
Stats s;
#define PACKETS_PERIOD 40
#define PACKETS_VERY_OLD 150
uint32_t cacheseqnum[PACKETS_PERIOD+1];
void refresh(uint32_t, uint64_t);
void update(uint8_t, uint32_t, uint64_t, uint64_t, uint64_t);
};
typedef std::map<int, std::string> WebSites;
struct beaconSource {
beaconSource();
address addr;
uint64_t creation;
int sttl;
uint64_t lastevent;
uint64_t lastlocalevent;
beaconMcastState ASM, SSM;
void setName(const std::string &);
void update(uint8_t, uint32_t, uint64_t, uint64_t, uint64_t, bool);
beaconExternalStats &getExternal(const address &, uint64_t now, uint64_t ts);
bool rxlocal(uint64_t now) const;
std::string name;
std::string adminContact;
std::string CC;
uint32_t Flags;
typedef std::map<address, beaconExternalStats> ExternalSources;
ExternalSources externalSources;
WebSites webSites;
bool identified;
};
typedef std::map<address, beaconSource> Sources;
beaconSource &getSource(const address &, const char *name, uint64_t now, uint64_t recvts, bool rxlocal);
void removeSource(const address &, bool);
uint64_t get_timestamp();
uint64_t get_time_of_day();
enum content_type {
NPROBE,
NSSMPROBE,
SSMPING
};
void ListenTo(content_type, int);
void SetupFDSet(int);
int SetupSSMPing();
void handle_ssmping(int s, address &, const address &, uint8_t *, int, uint64_t);
extern const char * const defaultPort;
extern const int defaultTTL;
extern int forceFamily;
extern int mcastInterface;
struct beaconExternalStats;
extern uint32_t flags;
extern std::string beaconName, adminContact, twoLetterCC;
extern Sources sources;
extern WebSites webSites;
extern address beaconUnicastAddr;
extern int verbose;
void info(const char *format, ...);
void fatal(const char *format, ...);
#endif
|