-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathethernet.go
119 lines (95 loc) · 2.41 KB
/
ethernet.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
package shelly
import (
"context"
"github.com/mongoose-os/mos/common/mgrpc"
"github.com/mongoose-os/mos/common/mgrpc/frame"
)
type EthStatus struct {
// IP of the device in the network.
IP *string `json:"ip"`
}
type EthGetStatusRequest struct{}
func (r *EthGetStatusRequest) Method() string {
return "Eth.GetStatus"
}
func (r *EthGetStatusRequest) NewTypedResponse() *EthStatus {
return &EthStatus{}
}
func (r *EthGetStatusRequest) NewResponse() any {
return r.NewTypedResponse()
}
func (r *EthGetStatusRequest) Do(
ctx context.Context,
c mgrpc.MgRPC,
credsCallback mgrpc.GetCredsCallback,
) (
*EthStatus,
*frame.Response,
error,
) {
resp := r.NewTypedResponse()
raw, err := Do(ctx, c, credsCallback, r, resp)
return resp, raw, err
}
type EthConfig struct {
// Enable is true if the configuration is enabled, false otherwise.
Enable *bool `json:"enable,omitempty"`
// IPv4Mode Range of values: dhcp, static
IPv4Mode *string `json:"ipv4mode,omitempty"`
// IP to use when ipv4mode is static.
IP *string `json:"ip,omitempty"`
// Netmask to use when ipv4mode is static
Netmask *string `json:"netmask,omitempty"`
// GW is the gateway to use when ipv4mode is static
GW *string `json:"gw,omitempty"`
// Nameserver to use when ipv4mode is static
Nameserver *string `json:"nameserver,omitempty"`
}
type EthGetConfigRequest struct{}
func (r *EthGetConfigRequest) Method() string {
return "Eth.GetConfig"
}
func (r *EthGetConfigRequest) NewTypedResponse() *EthConfig {
return &EthConfig{}
}
func (r *EthGetConfigRequest) NewResponse() any {
return r.NewTypedResponse()
}
func (r *EthGetConfigRequest) Do(
ctx context.Context,
c mgrpc.MgRPC,
credsCallback mgrpc.GetCredsCallback,
) (
*EthConfig,
*frame.Response,
error,
) {
resp := r.NewTypedResponse()
raw, err := Do(ctx, c, credsCallback, r, resp)
return resp, raw, err
}
type EthSetConfigRequest struct {
Config EthConfig `json:"config"`
}
func (r *EthSetConfigRequest) Method() string {
return "Eth.SetConfig"
}
func (r *EthSetConfigRequest) NewTypedResponse() *SetConfigResponse {
return &SetConfigResponse{}
}
func (r *EthSetConfigRequest) NewResponse() any {
return r.NewTypedResponse()
}
func (r *EthSetConfigRequest) Do(
ctx context.Context,
c mgrpc.MgRPC,
credsCallback mgrpc.GetCredsCallback,
) (
*SetConfigResponse,
*frame.Response,
error,
) {
resp := r.NewTypedResponse()
raw, err := Do(ctx, c, credsCallback, r, resp)
return resp, raw, err
}