Chip Boling | 610117d | 2021-09-09 11:24:34 -0500 | [diff] [blame] | 1 | /* |
| 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 | |
| 18 | package meframe |
| 19 | |
| 20 | import ( |
| 21 | "errors" |
| 22 | "fmt" |
| 23 | "github.com/google/gopacket" |
| 24 | . "github.com/opencord/omci-lib-go" |
| 25 | me "github.com/opencord/omci-lib-go/generated" |
| 26 | ) |
| 27 | |
| 28 | func SetTableRequestFrame(m *me.ManagedEntity, opt options) (gopacket.SerializableLayer, error) { |
| 29 | if opt.frameFormat != ExtendedIdent { |
| 30 | return nil, errors.New("set table message type only supported with Extended OMCI Messaging") |
| 31 | } |
| 32 | if opt.frameFormat == ExtendedIdent { |
| 33 | return nil, errors.New("extended message set for this message type is not supported") |
| 34 | } |
| 35 | mask, err := checkAttributeMask(m, opt.attributeMask) |
| 36 | if err != nil { |
| 37 | return nil, err |
| 38 | } |
| 39 | // Common for all MEs |
| 40 | meLayer := &SetTableRequest{ |
| 41 | MeBasePacket: MeBasePacket{ |
| 42 | EntityClass: m.GetClassID(), |
| 43 | EntityInstance: m.GetEntityID(), |
| 44 | Extended: opt.frameFormat == ExtendedIdent, |
| 45 | }, |
| 46 | } |
| 47 | // Get payload space available |
| 48 | maxPayload := maxPacketAvailable(m, opt) |
| 49 | |
| 50 | // TODO: Lots of work to do |
| 51 | |
| 52 | fmt.Println(mask, maxPayload) |
| 53 | return meLayer, errors.New("todo: Not implemented") |
| 54 | } |
| 55 | |
| 56 | func SetTableResponseFrame(m *me.ManagedEntity, opt options) (gopacket.SerializableLayer, error) { |
| 57 | if opt.frameFormat != ExtendedIdent { |
| 58 | return nil, errors.New("set table message type only supported with Extended OMCI Message Set") |
| 59 | } |
| 60 | if opt.frameFormat == ExtendedIdent { |
| 61 | return nil, errors.New("extended message set for this message type is not supported") |
| 62 | } |
| 63 | mask, err := checkAttributeMask(m, opt.attributeMask) |
| 64 | if err != nil { |
| 65 | return nil, err |
| 66 | } |
| 67 | // Common for all MEs |
| 68 | meLayer := &SetTableResponse{ |
| 69 | MeBasePacket: MeBasePacket{ |
| 70 | EntityClass: m.GetClassID(), |
| 71 | EntityInstance: m.GetEntityID(), |
| 72 | Extended: true, |
| 73 | }, |
| 74 | } |
| 75 | // Get payload space available |
| 76 | maxPayload := maxPacketAvailable(m, opt) |
| 77 | |
| 78 | // TODO: Lots of work to do |
| 79 | |
| 80 | fmt.Println(mask, maxPayload) |
| 81 | return meLayer, errors.New("todo: Not implemented") |
| 82 | } |