Metric.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* vim: set expandtab ts=4 sw=4: */
  2. /*
  3. * You may redistribute this program and/or modify it under the terms of
  4. * the GNU General Public License as published by the Free Software Foundation,
  5. * either version 3 of the License, or (at your option) any later version.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  14. */
  15. #ifndef Metric_H
  16. #define Metric_H
  17. #include <stdint.h>
  18. // This is INTERNAL to cjdns, it does not get used in the protocol at all,
  19. // but it is an internal protocol which is used to coordinate the different
  20. // modules.
  21. //
  22. // Different parts of the code become aware of the validity of different paths.
  23. // The InterfaceController becomes aware of peers, the DHT and the subnode
  24. // Pathfinder become aware of more distant nodes. And of course the SessionManager
  25. // becomes aware of a node by virtue of communicating with it.
  26. //
  27. // Each of these components informs the SessionManager when it becomes aware
  28. // of a path, if the SessionManager has a session for the node and the metric
  29. // for the path is lower than the metric which the SessionManager currently
  30. // has, it will update the path to that node.
  31. //
  32. // Because this is not inter-node protocol, you can change these numbers at any
  33. // time.
  34. // This is known to be a peer by InterfaceController, OR'd with the latency
  35. static const uint32_t Metric_IC_PEER = 0xff000000;
  36. static const uint32_t Metric_IC_PEER_MASK = 0x0000ffff;
  37. // Node is a direct peer according to the SubnodePathfinder
  38. static const uint32_t Metric_PF_PEER = 0xff100000;
  39. // The snode says this is a path to the node
  40. static const uint32_t Metric_SNODE_SAYS = 0xff200000;
  41. // This is our discovered path to our snode
  42. static const uint32_t Metric_SNODE = 0xff300000;
  43. // Node is a direct peer according to the (dht) Pathfinder
  44. static const uint32_t Metric_DHT_PEER = 0xff400000;
  45. // We sent a ping to a node to complete the session setup, it replied.
  46. // This is a path which we know works, but we don't know if it's any good.
  47. static const uint32_t Metric_PING_REPLY = 0xff500000;
  48. static const uint32_t Metric_DHT_INCOMING = 0xff510000;
  49. // Anything that comes from the DHT Pathfinder is &'d with Metric_DHT_MASK
  50. // and OR'd with Metric_DHT.
  51. static const uint32_t Metric_DHT = 0xff600000;
  52. static const uint32_t Metric_DHT_MASK = 0x000fffff;
  53. // Incoming message, CryptoAuth has not yet checked that the key is real
  54. static const uint32_t Metric_SM_INCOMING = 0xff700000;
  55. // Outgoing message, some upper layer thinks this is the path
  56. static const uint32_t Metric_SM_SEND = 0xff710000;
  57. // This will cause the SM to kill off a path
  58. static const uint32_t Metric_DEAD_LINK = 0xffffffff;
  59. #endif