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
//! Routing Information Protocol (RIPv1/RIPv2) wire constants.
//!
//! Values come from RFC 1058 (RIP version 1) and RFC 2453 (RIP version 2),
//! plus the IANA Address Family Numbers registry. RIPng (RFC 2080) constants
//! live under the RIPng submodule, added in a later step. Each constant cites
//! its defining RFC / IANA source in a line comment.
use Ipv4Addr;
// ---------------------------------------------------------------------------
// Fixed protocol constants (RFC 1058 §3.1, RFC 2453 §4)
// ---------------------------------------------------------------------------
/// RIP UDP port for IPv4 RIP. RFC 1058 §3.1 / IANA service registry.
pub const RIP_UDP_PORT: u16 = 520;
/// RIP message header length (command, version, 2-octet reserved), in octets.
/// RFC 1058 §3.1 / RFC 2453 §4.
pub const RIP_HEADER_LEN: usize = 4;
/// RIP route entry length, in octets. RFC 1058 §3.1 / RFC 2453 §4.
pub const RIP_ENTRY_LEN: usize = 20;
/// Maximum route entries per RIP message (generation guideline). RFC 2453 §4.
pub const RIP_MAX_ENTRIES: usize = 25;
/// Metric value denoting an unreachable destination (infinity). RFC 1058 §3.1.
pub const RIP_METRIC_INFINITY: u32 = 16;
// ---------------------------------------------------------------------------
// Command codes (RFC 1058 §3.1, RFC 2453 §4)
// ---------------------------------------------------------------------------
/// Request command: ask a router for all or part of its routing table.
/// RFC 1058 §3.1.
pub const RIP_COMMAND_REQUEST: u8 = 1;
/// Response command: a routing table message, solicited or unsolicited.
/// RFC 1058 §3.1.
pub const RIP_COMMAND_RESPONSE: u8 = 2;
// ---------------------------------------------------------------------------
// Demand/triggered-RIP command codes (RFC 2091 §2.3)
// ---------------------------------------------------------------------------
/// Update Request command: demand-RIP request for routes on an on-demand
/// circuit. RFC 2091 §2.3.
pub const RIP_COMMAND_UPDATE_REQUEST: u8 = 9;
/// Update Response command: demand-RIP routing update on an on-demand circuit.
/// RFC 2091 §2.3.
pub const RIP_COMMAND_UPDATE_RESPONSE: u8 = 10;
/// Update Acknowledge command: demand-RIP acknowledgement of an Update
/// Response. RFC 2091 §2.3.
pub const RIP_COMMAND_UPDATE_ACK: u8 = 11;
// ---------------------------------------------------------------------------
// Version numbers (RFC 1058 §3.1, RFC 2453 §4)
// ---------------------------------------------------------------------------
/// RIP version 1. RFC 1058 §3.1.
pub const RIP_VERSION_1: u8 = 1;
/// RIP version 2. RFC 2453 §4.
pub const RIP_VERSION_2: u8 = 2;
// ---------------------------------------------------------------------------
// Address Family Identifiers (IANA Address Family Numbers; RFC 2453 §4.1)
// ---------------------------------------------------------------------------
/// IP (IPv4) address family identifier carried in a route entry.
/// IANA Address Family Numbers.
pub const RIP_AFI_IP: u16 = 2;
/// Authentication entry marker address family. RFC 2453 §4.1.
pub const RIP_AFI_AUTH: u16 = 0xFFFF;
// ---------------------------------------------------------------------------
// Multicast group (RFC 2453 §3.5)
// ---------------------------------------------------------------------------
/// RIPv2 IPv4 multicast group for periodic responses. RFC 2453 §3.5.
pub const RIP_V2_MULTICAST: Ipv4Addr = new;