Giter VIP home page Giter VIP logo

sandialabs / arcus Goto Github PK

View Code? Open in Web Editor NEW
9.0 10.0 4.0 647 KB

Arcus, developed by Sandia National Laboratories, is a C# library for calculating, parsing, formatting, converting and comparing both IPv4 and IPv6 addresses and subnets. It accounts for 128-bit numbers on 32-bit platforms.

License: Apache License 2.0

C# 99.47% PowerShell 0.53%
ipv6 ipv4 subnet networking ipaddress ip ipaddresses ipv6-address ipv4-address ip-calculator

arcus's People

Contributors

ahsteele avatar nicksterx avatar rheone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

arcus's Issues

[Doc] Create a style guideline

Description

We're lacking a style guideline both for the C# code and the Sphinx doc generation.

Impact

It will keep the code clean and concise for all devs

Proposed solutions

  • provide a document with the desired guidelines
  • settle upon a .editorconfig for all file types
  • create appropriate resharper code formatter
  • define linter / formatter rules as appropriate
  • run linter as part of build step

NuGet Icon not configured properly do display both on NuGet site and Nuget PackageManager within Visual Studio

After discovering stackoverflow "NuGet Package Icon Not getting Displayed" it appears that the PackageIcon csproj directive is not respected by the Nuget PackageManager within Visual Studio a documented issue that appears to be getting attention.

  • In theory icon and iconUrl are deprecated, but supported by both NuGet site and Nuget PackageManager within Visual Studio
  • Embedded icon, packageIcon is not supported by Nuget PackageManager within Visual Studio, but is supported by the NuGet site.

I would have to assume embedding and iconUrl will conflict, but experimentation is required.

[TechDebt] Clean up csproj file replacing deprecated configuration

Warnings are generated on packing due to deprecated configuration

  • warning NU5125: The 'licenseUrl' element will be deprecated. Consider using the 'license' element instead. [XXXX\Arcus\src\Arcus\Arcus.csproj]
  • warning NU5048: The 'PackageIconUrl'/'iconUrl' element is deprecated. Consider using the 'PackageIcon'/'icon' element instead. Learn more at https://aka.ms/deprecateIconUrl [XXX\Arcus\src\Arcus\Arcus.csproj]

[Feature Request] MacAddress shold be able to map to EUI-64 bytes for legacy support

Description

A legacy use of a MAC Address is to convert it to a EUI-64.

This will allow us to also support the legacy modification of a EUI-64 as the least-significant 64 bits of a unicast network address or link-local address when stateless address autoconfiguration is used.

Eg. MAC Address to IPv6

Proposed solutions

There are several sources that say several things about this mapping; it is unclear which is "most" correct, or what the variants imply.

It seems odd that each of the 3 below mentioned very specifically outlining differing rules for what would seem to be the same operation. While IEEE is the definitive source, I'd like to determine the reasoning of the other implementations before moving forward. The differing schemes may be perfectly valid in the appropriate place.

All this for a known legacy operation 🤷

Networking Engineering StackExchange

(current implementation)
Answer to "What are EUI-48 and EUI-64?"
states that the insertion bytes should be [0xFF, 0xFE] and 7th bit should be inverted.

Wikipedia entry for "Mac Address"

Mac Address. Citation Note 6
states that the insertion bytes should be [0xFF, 0xFE] if the source is a EUI-48
and that the insertion bytes should be [0xFF, 0xFF] if the source is a MAC-48
(no inversion of any bits mentioned)

IEE

IEEE in "Guidelines for Use of Extended Unique Identifier (EUI), Organizationally Unique Identifier (OUI), and Company ID (CID)" section "Mapping an EUI-48 to an EUI-64" (pg 15)
states that the insertion bytes should be [0xFF, 0xFE] or [0xFF, 0xFF]
(no inversion of any bits mentioned)

Can you help?

Maybe? Gotta clear some things up and do some research

Code

What follows is the "StackExchange" implementation. This exists simply because it is what I first encountered before researching further. By no means is it the "correct" solution, it is simply correct as to the implied spec.

/// <summary>Gets a mapping of the Mac Address as a EUI-64</summary>
/// <remarks><para>Note that this mapping is considered deprecated, and is implemented for legacy needs</para></remarks>
/// <remarks><para>The implementation of this method is under question</para></remarks>
/// <returns>an array of bytes representing the EUI-64 of the MAC Address</returns>
[NotNull]
[Obsolete("This method is obsolete until the desired output can be verified")]
public byte[] GetEui64AddressBytes()
{
   // To generate a EUI-64 from the EUI-48
   // - divided EUI-48 int two 3-byte parts; OUI & CID
   // - insert the value 0xFFFE between the two parts (24th bit)
   // - Invert the 7th bit of the result

   var eui64 = new byte[8];
   Array.Copy(this._address, 0, eui64, 0, 3);  // first 3 bytes od address
   eui64[3] = 0xFF;
   eui64[4] = 0xFE;
   Array.Copy(this._address, 3, eui64, 5, 3);  // last 3 bytes of address

   // invert the 7th bit
   if ((eui64[0] & 0b0000_0010) != 0)  // 7th bit (big-endian) is set, it should be cleared
   {
         eui64[0] &= 0b1111_1101;    // clear the 7th bit
   }
   else  // 7th bit (big-endian) is not set, it should be set
   {
         eui64[0] |= 0b0000_0010;    // set the 7th bit
   }

   return eui64;
}

Tests

public static IEnumerable<object[]> GetEui64AddressBytes_Test_Values()
{
   yield return new object[] { new byte[] { 0x02, 0x21, 0x86, 0xFF, 0xFE, 0xB5, 0x6E, 0x10 }, MacAddress.Parse("00:21:86:B5:6E:10") };
   yield return new object[] { new byte[] { 0xFD, 0x21, 0x86, 0xFF, 0xFE, 0xB5, 0x6E, 0x10 }, MacAddress.Parse("FF:21:86:B5:6E:10") };
   yield return new object[] { new byte[] { 0xC2, 0xFF, 0xEE, 0xFF, 0xFE, 0xCA, 0xFE, 0x00 }, MacAddress.Parse("C0:FF:EE:CA:FE:00") };
}

[Theory]
[MemberData(nameof(GetEui64AddressBytes_Test_Values))]
public void GetEui64AddressBytes_Test(byte[] expected, MacAddress input)
{
   // Arrange
   // Act
   var result = input.GetEui64AddressBytes();

   // Assert
   Assert.IsType<byte[]>(result);
   var addressBytes = input.GetAddressBytes();

   Assert.Equal(8, result.Length);
   Assert.NotEqual(expected[0] & 0b10, addressBytes[0] & 0b10);
   Assert.Equal(0xFF, result[3]);
   Assert.Equal(0xFE, result[4]);
   Assert.Equal(0, ByteArrayUtils.CompareUnsignedBigEndian(expected, result));
}

[BUG] Readme icon borked

Describe the bug

Iconography PR broke readme:
image

Expected behavior

An icon not a broken image tag

Introduce basic support for IPv4 classful networks

Description

Arcus is missing in-the-box support for Subnets defined by and expressing traits of the accepted IPv4 Classful Network. It is desired that Arcus should provide legacy support for A, B, C, with a possibility for D (multicasting) and E classful networks.

Arcus should:

  • Allow the Subnet object to be constructed, either via constructor or a factory, by issuing an appropriate IP Address and class specifier
  • Subnet should have a property dictating its class if it is IP4 and meets the appropriate class
  • It should be possible to translate between IP Address netmasks and class A, B, and C

Subnet and IPAddressRange should be serializable

Subnet and IPAddressRange should implement ISerializable, be decorated by SerializableAttribute and have custom serialize logic.

Subnet should serialize head address bytes and routing prefix
IPAddressRange should serialize head address bytes and tail address bytes

Addressing CA1036 for IPAddressRange and Subnet

CA1036 states that IPAddressRange and Subnet should override the comparison operators, specifically op_Equality, op_Inequality, op_LessThan and op_GreaterThan.

Add less than or equal to and greater than or equal to so as not to disappoint

[TechDebt] rename Git default branch to `main`

Description

"The Internet Engineering Task Force (IETF) points out that "Master-slave is an oppressive metaphor that will and should never become fully detached from history" as well as "In addition to being inappropriate and arcane, the master-slave metaphor is both technically and historically inaccurate." There's lots of more accurate options depending on context and it costs me nothing to change my vocabulary, especially if it is one less little speed bump to getting a new person excited about tech." - Scott Hanselman

Impact

This can/will affect builds and document generation. All external items pointing to master branch should be updated.

Fix readme

Readme should include the Arcus icon and link to Gulliver. Also the copyright notice is in a code block and looks ugly. License might also be code and need to change too.

[BUG] MAC address regular expression is wrong

Describe the bug

the RegEx

^(?:[0-9A-Fa-f]{2}([-: ]?))(?:[0-9A-Fa-f]{2}\1){4}[0-9A-Fa-f]{2}$|^(?:[0-9A-Fa-f]{4}\.){2}[0-9A-Fa-f]{4}$|^(?:[0-9A-Fa-f]{3}\.){3}[0-9A-Fa-f]{3}$

was (poorly) optimized to

^[\dA-F]{2}([ -:]?)(?:[\dA-F]{2}\1){4}[\dA-F]{2}$|^(?:[\dA-F]{4}\.){2}[\dA-F]{4}$|^(?:[\dA-F]{3}\.){3}[\dA-F]{3}$`

RegEx to Strings
regexp-tree

It is matching things like

48%57%82%1A%3A%E5
DA8698328B383C858
8F+23+1F+7D+C2+D8
7D6426E367C6F163A
65)E9)E0)5C)21)51
A9&4A&8D&E1&6A&48
200F70CB0250260CD
8F36E30A34936732D
C2$06$7C$6C$7F$0B

Expected behavior

It should match (and only match)

I’ve reviewed common formats and standards and I believe the following regex to be correct for the following formats

  • IEEE 802 format for printing MAC-48 addresses in six groups of two hexadecimal digits, separated by hyphens -
  • six groups of two hexadecimal digits separated by colons :
  • six groups of two hexadecimal digits separated by spaces
  • 12 hexadecimal digits with no separation
  • Cisco three groups of four hexadecimal digits separated by dots .
  • Cisco four groups of three hexadecimal digits separated by dots .

Bonus points if it groups the Hexadecimal Digits

More info may be found on Network Engineering Stackexchange What are the various standard and industry practice ways to express a 48-bit MAC address?

Proposed solutions

I'll figure something out

Can you help?

I'll figure something out

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.