Skip to content
This repository has been archived by the owner on Sep 17, 2021. It is now read-only.

Initial commit - Added bash version of mac2ip calculator #4

Merged
merged 10 commits into from
Feb 12, 2016

Conversation

jasonkhanlar
Copy link
Member

No description provided.

@colindean
Copy link
Member

Can you change the commit summary to be something more indicative of the content of the commit? E.g. "Adds bash version of calculator" or something like that.

@@ -0,0 +1,127 @@
#!/bin/bash
#
# Script written for PittMesh by Jason Khanlar
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to claim copyright on this, put in a header something more like this:

© 2016 Jason Khanlar. All rights reserved.
Licensed under the terms of the MIT license.

PittMesh isn't an entity for the purposes of licensing. If you want to assign the copyright to @metamesh, that's fine: swap in Meta Mesh Wireless Communities for your name and add an authors block that looks like this:

AUTHORS
* Jason Khanlar

@jasonkhanlar jasonkhanlar changed the title Initial commit Initial commit - Added bash version of mac2ip calculator Feb 11, 2016
@jasonkhanlar
Copy link
Member Author

thump

@@ -0,0 +1,105 @@
#!/bin/bash
#
# � 2016 Meta Mesh Wireless Communications. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/Communications/Communities

@colindean
Copy link
Member

Almost there!

@jasonkhanlar
Copy link
Member Author

s_h_a_k_e

colindean added a commit that referenced this pull request Feb 12, 2016
Initial commit - Added bash version of mac2ip calculator
@colindean colindean merged commit 341e3df into master Feb 12, 2016
@colindean
Copy link
Member

Great work! Next (optional) step? Write a simple test script that checks the known good output of a few inputs.

@jasonkhanlar
Copy link
Member Author

What kind of inputs? What determines known good outputs?

@jasonkhanlar jasonkhanlar deleted the pm-commotion-mac2ip branch February 13, 2016 08:04
@jasonkhanlar jasonkhanlar restored the pm-commotion-mac2ip branch February 13, 2016 08:05
@colindean
Copy link
Member

If you know that the MAC address de:ad:be:ef:00:01 will always produce an IP of 100.64.87.1, then that's a test case†. Pick another three or four, figure them out by hand. Call the script and check its output for what you'd expect.

script_to_test=./mm-commotion-mac2ip
failure=0

test() {
  local mac=$1
  local ip=$2

  if [[ "$($script_to_test $mac)" != "$ip" ]]; then
    echo "$mac did not resolve to $ip"
    failure=1
  fi
}

test "de:ad:be:ef:00:01" "100.64.87.1"
test "d3-4d-B3-3F-10:11" "100.64.87.101"

if [[ $failure -gt 0 ]]; then 
  echo "There were failures."
  exit 1
fi
}

This eventually leads to a sort of generative test, where you can generate applicable MAC addresses at random and check the output against a known working implementation. This last bit is probably more work that is worth it for now, though.

† The MACs and IPs mentioned in this post are certainly not correctly paired.

@colindean colindean deleted the pm-commotion-mac2ip branch February 14, 2016 02:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants