Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support cisco-style MAC addresses #116

Closed
Sebbb opened this issue Jan 14, 2015 · 2 comments
Closed

Support cisco-style MAC addresses #116

Sebbb opened this issue Jan 14, 2015 · 2 comments
Assignees
Milestone

Comments

@Sebbb
Copy link

Sebbb commented Jan 14, 2015

Hi,

it would be great if you would also support cisco style MAC addresses as input for Pio::Mac.new out of the box.

They look e.g. like "002a.6abc.a12c"

A bit ugly but working for me (I added the elsif-part):

def parse_mac_string(mac)
  octet_regex = '[0-9a-fA-F][0-9a-fA-F]'
  if /^(#{ octet_regex }:){5}(#{ octet_regex })$/ =~ mac
    mac.gsub(':', '').hex
  elsif /^(#{ octet_regex+octet_regex }.){2}(#{ octet_regex+octet_regex })$/ =~ mac
    mac.gsub('.', '').hex
  else
    fail ArgumentError
  end
end
  • Sebbb
@yasuhito
Copy link
Member

@Sebbb I have merged the code into feature/cisco_mac branch (e9dcdc1). Please confirm that it works for you. Thanks.

@Sebbb
Copy link
Author

Sebbb commented Jan 15, 2015

Thanks, it works fine for me :)

yasuhito added a commit that referenced this issue Jan 15, 2015
Support Cisco-style MAC addresses (refs #116).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants