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 ¶
- Variables
- func ExtractOuiFromMac(macAddress string) (string, error)
- func FindAllMacAddresses(s string) ([]string, error)
- func FormatMacAddress(macAddress string, newFormat MacFormat) (string, error)
- func GetGroupSize(macAddress string) (int, error)
- type CaseOption
- type DelimiterOption
- type GroupSizeOption
- type MacFormat
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidCaseOption = errors.New("invalid case option")
var ErrInvalidDelimiterOption = errors.New("invalid delimiter option")
var ErrInvalidGroupSize = errors.New("invalid group size; must be 2, 4 or 6")
var ErrInvalidMacAddress = errors.New("invalid MAC address")
Errors returned by functions in this package
var ErrInvalidMacAddressLength = errors.New("invalid MAC address length; must be divisible by group size")
Functions ¶
func ExtractOuiFromMac ¶
ExtractOuiFromMac extracts the OUI assignment from a MAC address.
func FindAllMacAddresses ¶
FindAllMacAddresses returns a list of MAC addresses found in the input string.
func FormatMacAddress ¶
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
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.