-
Notifications
You must be signed in to change notification settings - Fork 10
/
interfaces.go
130 lines (116 loc) · 4.63 KB
/
interfaces.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
//
// Copyright 2017, Rutger te Nijenhuis & Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package ciscoasa
import (
"encoding/json"
"net"
"strconv"
)
type interfaceService struct {
*Client
}
// SlaTracking represents an SlaTracking Settings.
type SlaTracking struct {
SlaId int `json:"slaId"`
TrackedIP string `json:"trackedIP"`
FrequencyInSeconds int `json:"frequencyInSeconds"`
DataSizeInBytes int `json:"dataSizeInBytes"`
ThresholdInMilliseconds int `json:"thresholdInMilliseconds"`
ToS int `json:"ToS"`
TimeoutInMilliseconds int `json:"timeoutInMilliseconds"`
NumPackets int `json:"numPackets"`
}
// DhcpClient represents an DHCP Settings.
type DhcpClient struct {
SetDefaultRoute bool `json:"setDefaultRoute"`
Metric int `json:"metric"`
PrimaryTrackId int `json:"primaryTrackId"`
TrackingEnabled bool `json:"trackingEnabled"`
SlaTrackingSettings *SlaTracking `json:"slaTrackingSettings"`
}
// Address represents a static IPv4/IPv6 address settings.
type Address struct {
Kind string `json:"kind"`
Value string `json:"value"`
}
// IPAddress represents an IP address settings.
type IPAddress struct {
IP *Address `json:"ip,omitempty"`
NetMask *Address `json:"netMask,omitempty"`
Kind string `json:"kind"`
DhcpOptionUsingMac bool `json:"dhcpOptionUsingMac,omitempty"`
DhcpBroadcast bool `json:"dhcpBroadcast,omitempty"`
DhcpClient *DhcpClient `json:"dhcpClient,omitempty"`
}
// UnmarshalJSON implements json.Unmarshaler interface.
func (ip *IPAddress) UnmarshalJSON(b []byte) error {
type alias IPAddress
if err := json.Unmarshal(b, (*alias)(ip)); err != nil {
ip = nil
}
return nil
}
func (ip *IPAddress) String() string {
n := net.IPMask(net.ParseIP(ip.NetMask.Value).To4())
b, _ := n.Size()
bitsize := strconv.Itoa(b)
return ip.IP.Value + "/" + bitsize
}
// nDiscoveryPrefix represents an nDiscoveryPrefix list.
type NDiscoveryPrefix struct {
OffLink bool `json:"offLink"`
NoAdvertise bool `json:"noAdvertise"`
PreferredLifetime int `json:"preferredLifetime"`
ValidLifetime int `json:"validLifetime"`
HasDuration bool `json:"hasDuration"`
DefaultPrefix bool `json:"defaultPrefix"`
Kind string `json:"kind"`
}
// Ipv6Address represents an Ipv6Address.
type Ipv6Address struct {
PrefixLength int `json:"prefixLength,omitempty"`
Standby *Address `json:"standby,omitempty"`
Address *Address `json:"address,omitempty"`
// IsEUI64 bool `json:"isEUI64"`
Kind string `json:"kind"`
}
// IPv6Info represents an IPv6 address.
type IPv6Info struct {
Enabled bool `json:"enabled"`
AutoConfig bool `json:"autoConfig"`
EnforceEUI64 bool `json:"enforceEUI64"`
ManagedAddressConfig bool `json:"managedAddressConfig"`
NsInterval int `json:"nsInterval"`
DadAttempts int `json:"dadAttempts"`
NDiscoveryPrefixList []*NDiscoveryPrefix `json:"nDiscoveryPrefixList,omitempty"`
OtherStatefulConfig bool `json:"otherStatefulConfig"`
RouterAdvertInterval int `json:"routerAdvertInterval"`
RouterAdvertIntervalUnit string `json:"routerAdvertIntervalUnit"`
RouterAdvertLifetime int `json:"routerAdvertLifetime"`
SuppressRouterAdvert bool `json:"suppressRouterAdvert"`
ReachableTime int `json:"reachableTime"`
LinkLocalAddress *Ipv6Address `json:"linkLocalAddress,omitempty"`
Ipv6Addresses []*Ipv6Address `json:"ipv6Addresses,omitempty"`
Kind string `json:"kind"`
}
// UnmarshalJSON implements json.Unmarshaler interface.
func (ip *IPv6Info) UnmarshalJSON(b []byte) error {
type alias IPv6Info
if err := json.Unmarshal(b, (*alias)(ip)); err != nil {
ip = nil
}
return nil
}