blob: f98a3a609456982f70a9475d3841e50f2a2055ba [file] [log] [blame]
Chip Boling610117d2021-09-09 11:24:34 -05001/*
2 * Copyright (c) 2018 - present. Boling Consulting Solutions (bcsw.net)
3 * Copyright 2020-present Open Networking Foundation
4
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8
9 * http://www.apache.org/licenses/LICENSE-2.0
10
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18package meframe
19
20import (
21 "errors"
22 "github.com/google/gopacket"
Andrea Campanellae0cd8232021-10-15 15:10:23 +020023 . "github.com/opencord/omci-lib-go/v2"
24 me "github.com/opencord/omci-lib-go/v2/generated"
Chip Boling610117d2021-09-09 11:24:34 -050025)
26
27func RebootRequestFrame(m *me.ManagedEntity, opt options) (gopacket.SerializableLayer, error) {
28 if opt.frameFormat == ExtendedIdent {
29 return nil, errors.New("extended message set for this message type is not supported")
30 }
31 // Common for all MEs
32 meLayer := &RebootRequest{
33 MeBasePacket: MeBasePacket{
34 EntityClass: m.GetClassID(),
35 EntityInstance: m.GetEntityID(),
36 Extended: opt.frameFormat == ExtendedIdent,
37 },
38 RebootCondition: opt.mode,
39 }
40 return meLayer, nil
41}
42
43func RebootResponseFrame(m *me.ManagedEntity, opt options) (gopacket.SerializableLayer, error) {
44 if opt.frameFormat == ExtendedIdent {
45 return nil, errors.New("extended message set for this message type is not supported")
46 }
47 // Common for all MEs
48 meLayer := &RebootResponse{
49 MeBasePacket: MeBasePacket{
50 EntityClass: m.GetClassID(),
51 EntityInstance: m.GetEntityID(),
52 Extended: opt.frameFormat == ExtendedIdent,
53 },
54 Result: opt.result,
55 }
56 return meLayer, nil
57}