Documentation

Hale.IpRoute.Data.IP

structure Data.IP.IPv4 :

An IPv4 address stored as a 32-bit unsigned integer. $$\text{IPv4} = \{ \text{addr} : \text{UInt32} \}$$

Instances For
    @[implicit_reducible]
    Equations
    Equations
    Instances For
      @[implicit_reducible]
      Equations
      @[inline]

      Create an IPv4 from four octets: a.b.c.d $$\text{ofOctets}(a, b, c, d) = (a \ll 24) \lor (b \ll 16) \lor (c \ll 8) \lor d$$

      Equations
      Instances For

        Extract the four octets.

        Equations
        Instances For
          @[implicit_reducible]
          Equations
          • One or more equations did not get rendered due to their size.
          @[implicit_reducible]
          Equations

          The loopback address 127.0.0.1.

          Equations
          Instances For

            The any address 0.0.0.0.

            Equations
            Instances For

              The broadcast address 255.255.255.255.

              Equations
              Instances For
                structure Data.IP.IPv6 :

                An IPv6 address stored as two 64-bit unsigned integers (high, low). $$\text{IPv6} = \{ \text{hi} : \text{UInt64},\; \text{lo} : \text{UInt64} \}$$

                Instances For
                  @[implicit_reducible]
                  Equations
                  Equations
                  Instances For
                    Equations
                    Instances For
                      @[implicit_reducible]
                      Equations
                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For

                        The loopback address ::1.

                        Equations
                        Instances For

                          The any address ::.

                          Equations
                          Instances For
                            @[implicit_reducible]
                            Equations
                            @[implicit_reducible]
                            Equations
                            inductive Data.IP.IP :

                            A generic IP address (IPv4 or IPv6).

                            Instances For
                              @[implicit_reducible]
                              Equations
                              @[implicit_reducible]
                              Equations
                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For
                                @[implicit_reducible]
                                Equations

                                An IPv4 CIDR range with bounded mask length. $$\text{AddrRange4} = \{ \text{base} : \text{IPv4},\; \text{mask} : \{n : \mathbb{N} \mid n \leq 32\} \}$$

                                • base : IPv4

                                  The network base address.

                                • maskLen : Nat

                                  The prefix length (0..32).

                                • valid : self.maskLen 32

                                  Proof that mask length is valid.

                                Instances For
                                  @[inline]

                                  Compute the network mask from the prefix length. $$\text{mask}(n) = \text{0xFFFFFFFF} \ll (32 - n)$$

                                  Equations
                                  Instances For
                                    @[inline]

                                    Check if an address falls within this CIDR range. $$\text{isMatchedTo}(ip, r) \iff (ip \land \text{mask}) = (\text{base} \land \text{mask})$$

                                    Equations
                                    Instances For

                                      An IPv6 CIDR range with bounded mask length. $$\text{AddrRange6} = \{ \text{base} : \text{IPv6},\; \text{mask} : \{n : \mathbb{N} \mid n \leq 128\} \}$$

                                      Instances For

                                        A generic CIDR range.

                                        Instances For
                                          @[implicit_reducible]
                                          Equations

                                          Parse an IPv4 address from dotted-decimal string. Returns none on invalid input.

                                          Equations
                                          • One or more equations did not get rendered due to their size.
                                          Instances For

                                            Parse a CIDR range like "192.168.1.0/24".

                                            Equations
                                            • One or more equations did not get rendered due to their size.
                                            Instances For