diff --git a/lib/enumerable/ip/prefix.ex b/lib/enumerable/ip/prefix.ex index 83a6b0e..104050f 100644 --- a/lib/enumerable/ip/prefix.ex +++ b/lib/enumerable/ip/prefix.ex @@ -1,6 +1,5 @@ defimpl Enumerable, for: IP.Prefix do alias IP.{Prefix, Address} - use Bitwise @moduledoc """ Implements `Enumerable` for `IP.Prefix`, allowing consumers to iterate diff --git a/lib/ip/address.ex b/lib/ip/address.ex index bd9c1db..cff81f2 100644 --- a/lib/ip/address.ex +++ b/lib/ip/address.ex @@ -3,8 +3,8 @@ defmodule IP.Address do alias IP.Address.{Helpers, InvalidAddress, ULA} alias IP.Prefix defstruct ~w(address version)a + import Bitwise import Helpers - use Bitwise @moduledoc """ Simple representations of IP Addresses. diff --git a/lib/ip/address/ula.ex b/lib/ip/address/ula.ex index ee886dd..aa69c30 100644 --- a/lib/ip/address/ula.ex +++ b/lib/ip/address/ula.ex @@ -1,7 +1,7 @@ defmodule IP.Address.ULA do alias IP.Address alias IP.Prefix.EUI64 - use Bitwise + import Bitwise @moduledoc false diff --git a/lib/ip/prefix.ex b/lib/ip/prefix.ex index 30b9a9e..b872ebc 100644 --- a/lib/ip/prefix.ex +++ b/lib/ip/prefix.ex @@ -2,7 +2,7 @@ defmodule IP.Prefix do alias IP.{Address, Prefix} alias IP.Prefix.{EUI64, Helpers, InvalidPrefix, Parser} defstruct ~w(address mask)a - use Bitwise + import Bitwise import Helpers @moduledoc """ @@ -412,13 +412,13 @@ defmodule IP.Prefix do @spec space(t) :: non_neg_integer def space(%Prefix{address: %Address{address: address, version: 4}, mask: mask}) do first = address &&& mask - last = first + (~~~mask &&& @ipv4_mask) + last = first + (bnot(mask) &&& @ipv4_mask) last - first + 1 end def space(%Prefix{address: %Address{address: address, version: 6}, mask: mask}) do first = address &&& mask - last = first + (~~~mask &&& @ipv6_mask) + last = first + (bnot(mask) &&& @ipv6_mask) last - first + 1 end diff --git a/lib/ip/prefix/eui64.ex b/lib/ip/prefix/eui64.ex index da890b6..066fc91 100644 --- a/lib/ip/prefix/eui64.ex +++ b/lib/ip/prefix/eui64.ex @@ -1,5 +1,5 @@ defmodule IP.Prefix.EUI64 do - use Bitwise + import Bitwise @moduledoc false diff --git a/lib/ip/prefix/helpers.ex b/lib/ip/prefix/helpers.ex index 4ba59c6..b0614d3 100644 --- a/lib/ip/prefix/helpers.ex +++ b/lib/ip/prefix/helpers.ex @@ -1,5 +1,5 @@ defmodule IP.Prefix.Helpers do - use Bitwise + import Bitwise @moduledoc false @@ -36,14 +36,14 @@ defmodule IP.Prefix.Helpers do defmacro highest_address(addr, mask, 4) do quote do - (unquote(addr) &&& unquote(mask)) + (~~~unquote(mask) &&& 0xFFFFFFFF) + (unquote(addr) &&& unquote(mask)) + (bnot(unquote(mask)) &&& 0xFFFFFFFF) end end defmacro highest_address(addr, mask, 6) do quote do (unquote(addr) &&& unquote(mask)) + - (~~~unquote(mask) &&& 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) + (bnot(unquote(mask)) &&& 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) end end end diff --git a/lib/ip/prefix/parser.ex b/lib/ip/prefix/parser.ex index 9e7d2f2..aa58c48 100644 --- a/lib/ip/prefix/parser.ex +++ b/lib/ip/prefix/parser.ex @@ -1,7 +1,7 @@ defmodule IP.Prefix.Parser do alias IP.{Address, Prefix} + import Bitwise import IP.Prefix.Helpers - use Bitwise @moduledoc false diff --git a/lib/ip/scope.ex b/lib/ip/scope.ex index f8aa5d4..0b9955f 100644 --- a/lib/ip/scope.ex +++ b/lib/ip/scope.ex @@ -1,9 +1,10 @@ defmodule IP.Scope do - alias IP.{Address, Prefix} - use Bitwise - require IP.Prefix import IP.Prefix.Helpers + alias IP.{Address, Prefix} + + require IP.Prefix + @moduledoc """ Implements scope lookup for all (currently) known scopes. diff --git a/mix.lock b/mix.lock index 65647fc..e1ce3f3 100644 --- a/mix.lock +++ b/mix.lock @@ -1,18 +1,18 @@ %{ - "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm", "7af5c7e09fe1d40f76c8e4f9dd2be7cebd83909f31fee7cd0e9eadc567da8353"}, - "credo": {:hex, :credo, "1.6.1", "7dc76dcdb764a4316c1596804c48eada9fff44bd4b733a91ccbf0c0f368be61e", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "698607fb5993720c7e93d2d8e76f2175bba024de964e160e2f7151ef3ab82ac5"}, - "earmark": {:hex, :earmark, "1.4.19", "3854a17305c880cc46305af15fb1630568d23a709aba21aaa996ced082fc29d7", [:mix], [{:earmark_parser, ">= 1.4.18", [hex: :earmark_parser, repo: "hexpm", optional: false]}], "hexpm", "d5a8c9f9e37159a8fdd3ea8437fb4e229eaf56d5129b9a011dc4780a4872079d"}, - "earmark_parser": {:hex, :earmark_parser, "1.4.20", "89970db71b11b6b89759ce16807e857df154f8df3e807b2920a8c39834a9e5cf", [:mix], [], "hexpm", "1eb0d2dabeeeff200e0d17dc3048a6045aab271f73ebb82e416464832eb57bdd"}, + "bunt": {:hex, :bunt, "0.2.1", "e2d4792f7bc0ced7583ab54922808919518d0e57ee162901a16a1b6664ef3b14", [:mix], [], "hexpm", "a330bfb4245239787b15005e66ae6845c9cd524a288f0d141c148b02603777a5"}, + "credo": {:hex, :credo, "1.6.7", "323f5734350fd23a456f2688b9430e7d517afb313fbd38671b8a4449798a7854", [:mix], [{:bunt, "~> 0.2.1", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "41e110bfb007f7eda7f897c10bf019ceab9a0b269ce79f015d54b0dcf4fc7dd3"}, + "earmark": {:hex, :earmark, "1.4.27", "b413b0379043df51475a9b22ce344e8a58a117516c735b8871e6cdd5ed0f0153", [:mix], [{:earmark_parser, "~> 1.4.26", [hex: :earmark_parser, repo: "hexpm", optional: false]}], "hexpm", "579ebe2eaf4c7e040815a73a268036bcd96e6aab8ad2b1fcd979aaeb1ea47e15"}, + "earmark_parser": {:hex, :earmark_parser, "1.4.26", "f4291134583f373c7d8755566122908eb9662df4c4b63caa66a0eabe06569b0a", [:mix], [], "hexpm", "48d460899f8a0c52c5470676611c01f64f3337bad0b26ddab43648428d94aabc"}, "erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"}, - "ex_doc": {:hex, :ex_doc, "0.28.1", "34fab7e7201c5a1f275f3b2f837125c940c512e8543d181bd4dd7acb19c8dba0", [:mix], [{:earmark_parser, "~> 1.4.19", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "10e564dd59101a5edc4de7009a54baed015a246dee01f7200aab24e8f57fc044"}, + "ex_doc": {:hex, :ex_doc, "0.28.5", "3e52a6d2130ce74d096859e477b97080c156d0926701c13870a4e1f752363279", [:mix], [{:earmark_parser, "~> 1.4.19", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "d2c4b07133113e9aa3e9ba27efb9088ba900e9e51caa383919676afdf09ab181"}, "file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"}, "git_cli": {:hex, :git_cli, "0.3.0", "a5422f9b95c99483385b976f5d43f7e8233283a47cda13533d7c16131cb14df5", [:mix], [], "hexpm", "78cb952f4c86a41f4d3511f1d3ecb28edb268e3a7df278de2faa1bd4672eaf9b"}, "git_ops": {:hex, :git_ops, "2.4.5", "185a724dfde3745edd22f7571d59c47a835cf54ded67e9ccbc951920b7eec4c2", [:mix], [{:git_cli, "~> 0.2", [hex: :git_cli, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "e323a5b01ad53bc8c19c3a444be3e61ed7803ecd2e95530446ae9327d0143ecc"}, "inch_ex": {:hex, :inch_ex, "1.0.0", "18496a900ca4b7542a1ff1159e7f8be6c2012b74ca55ac70de5e805f14cdf939", [:mix], [{:poison, "~> 1.5 or ~> 2.0 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"}, - "jason": {:hex, :jason, "1.2.2", "ba43e3f2709fd1aa1dce90aaabfd039d000469c05c56f0b8e31978e03fa39052", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "18a228f5f0058ee183f29f9eae0805c6e59d61c3b006760668d8d18ff0d12179"}, + "jason": {:hex, :jason, "1.4.0", "e855647bc964a44e2f67df589ccf49105ae039d4179db7f6271dfd3843dc27e6", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "79a3791085b2a0f743ca04cec0f7be26443738779d09302e01318f97bdb82121"}, "makeup": {:hex, :makeup, "1.1.0", "6b67c8bc2882a6b6a445859952a602afc1a41c2e08379ca057c0f525366fc3ca", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "0a45ed501f4a8897f580eabf99a2e5234ea3e75a4373c8a52824f6e873be57a6"}, - "makeup_elixir": {:hex, :makeup_elixir, "0.15.2", "dc72dfe17eb240552857465cc00cce390960d9a0c055c4ccd38b70629227e97c", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "fd23ae48d09b32eff49d4ced2b43c9f086d402ee4fd4fcb2d7fad97fa8823e75"}, + "makeup_elixir": {:hex, :makeup_elixir, "0.16.0", "f8c570a0d33f8039513fbccaf7108c5d750f47d8defd44088371191b76492b0b", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "28b2cbdc13960a46ae9a8858c4bebdec3c9a6d7b4b9e7f4ed1502f8159f338e7"}, "makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"}, - "nimble_parsec": {:hex, :nimble_parsec, "1.2.2", "b99ca56bbce410e9d5ee4f9155a212e942e224e259c7ebbf8f2c86ac21d4fa3c", [:mix], [], "hexpm", "98d51bd64d5f6a2a9c6bb7586ee8129e27dfaab1140b5a4753f24dac0ba27d2f"}, + "nimble_parsec": {:hex, :nimble_parsec, "1.2.3", "244836e6e3f1200c7f30cb56733fd808744eca61fd182f731eac4af635cc6d0b", [:mix], [], "hexpm", "c8d789e39b9131acf7b99291e93dae60ab48ef14a7ee9d58c6964f59efb570b0"}, "poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm"}, }