mac

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Copyright © 2023 Mikael Schultz <bitcanon@proton.me>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidCaseOption = errors.New("invalid case option")
View Source
var ErrInvalidDelimiterOption = errors.New("invalid delimiter option")
View Source
var ErrInvalidGroupSize = errors.New("invalid group size; must be 2, 4 or 6")
View Source
var ErrInvalidMacAddress = errors.New("invalid MAC address")

Errors returned by functions in this package

View Source
var ErrInvalidMacAddressLength = errors.New("invalid MAC address length; must be divisible by group size")

Functions

func ExtractOuiFromMac

func ExtractOuiFromMac(macAddress string) (string, error)

ExtractOuiFromMac extracts the OUI assignment from a MAC address.

func FindAllMacAddresses

func FindAllMacAddresses(s string) ([]string, error)

FindAllMacAddresses returns a list of MAC addresses found in the input string.

func FormatMacAddress

func FormatMacAddress(macAddress string, newFormat MacFormat) (string, error)

FormatMacAddress formats the MAC address with the specified case, delimiter and group size. The group size is the number of characters in each group. The delimiter is the character used to separate each group. Example: 00:00:5E:00:53:01 (Case: Upper, Delimiter: Colon, GroupSize: 2)

func GetGroupSize added in v1.2.0

func GetGroupSize(macAddress string) (int, error)

getGroupSize calculates the group size of the MAC address. The group size is the number of characters in each group. A delimiting character separates each group, and can be any character except alphanumeric characters.

Types

type CaseOption

type CaseOption int

CaseOption is used to specify the case of the MAC address.

const (
	OriginalCase CaseOption = iota
	Upper
	Lower
)

type DelimiterOption

type DelimiterOption int

DelimiterOption is used to specify the delimiter used in the MAC address.

const (
	OriginalDelim DelimiterOption = iota
	Colon
	Hyphen
	Dot
	None
)

type GroupSizeOption added in v1.2.0

type GroupSizeOption int

GroupSizeOption is used to specify the number of characters in each group.

const (
	OriginalGroupSize GroupSizeOption = iota
	GroupSizeTwo
	GroupSizeFour
	GroupSizeSix
)

type MacFormat

type MacFormat struct {
	Case      CaseOption
	Delimiter DelimiterOption
	GroupSize GroupSizeOption
}

MacFormat is used to specify the format of the MAC address.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL