-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmac.go
33 lines (27 loc) · 913 Bytes
/
mac.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright 2020 Joakim Kennedy. All rights reserved. Use of
// this source code is governed by the included BSD license.
package stix2
import "fmt"
// MACAddress represents a single Media Access Control (MAC) address.
type MACAddress struct {
STIXCyberObservableObject
// Value specifies the value of a single MAC address.
Value string `json:"value"`
}
func (o *MACAddress) MarshalJSON() ([]byte, error) {
return marshalToJSONHelper(o)
}
// NewMACAddress creates a new MACAddress object.
func NewMACAddress(value string, opts ...STIXOption) (*MACAddress, error) {
if value == "" {
return nil, ErrInvalidParameter
}
base := newSTIXCyberObservableObject(TypeMACAddress)
obj := &MACAddress{
STIXCyberObservableObject: base,
Value: value,
}
err := applyOptions(obj, opts)
obj.ID = NewObservableIdentifier(fmt.Sprintf("[\"%s\"]", value), TypeMACAddress)
return obj, err
}