Takahiro Suzuki | d7bf820 | 2020-12-17 20:21:59 +0900 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2020-present Open Networking Foundation |
| 3 | |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package l2oam |
| 18 | |
| 19 | import ( |
| 20 | "github.com/google/gopacket" |
| 21 | ) |
| 22 | |
| 23 | // GenerateL2switchingDomainActionLnletEntryUs generates "L2 Switching Domain/Action Add Inlet entry(upstream)" message |
| 24 | func GenerateL2switchingDomainActionLnletEntryUs(oc *TomiObjectContext, |
| 25 | pushTpidValue []byte, pushVidValue []byte, onuID *TomiObjectContext) gopacket.SerializableLayer { |
| 26 | |
| 27 | tibitData := &L2switchingDomainRequest{ |
| 28 | // IEEE 1904.2 |
| 29 | Opcode: 0x03, |
| 30 | // OAM Protocol |
| 31 | Flags: 0x0050, |
| 32 | OAMPDUCode: 0xfe, |
| 33 | OUId: []byte{0x2a, 0xea, 0x15}, |
| 34 | // TiBit OLT Management Interface |
| 35 | TOMIOpcode: 0x03, |
| 36 | // Correlation Tag |
| 37 | CTBranch: 0x0c, |
| 38 | CTType: 0x0c7a, |
| 39 | CTLength: 4, |
| 40 | CTInstance: getOltInstance(), |
| 41 | // Object Context |
| 42 | OCBranch: oc.Branch, |
| 43 | OCType: oc.Type, |
| 44 | OCLength: oc.Length, |
| 45 | OCInstance: oc.Instance, |
| 46 | // Vc |
| 47 | VcBranch: 0x5d, |
| 48 | VcLeaf: 0x7001, |
| 49 | VcLength: uint8(24 + len(pushTpidValue) + len(pushVidValue)), //27 |
| 50 | // Source OC |
| 51 | SOLength: 5, |
| 52 | SOBranch: 0x0c, |
| 53 | SOType: 0x0011, |
| 54 | SOValLength: 1, |
| 55 | SOInstance: uint8(onuID.Instance), |
| 56 | // TagMatchList |
| 57 | TMLLength: 7, |
| 58 | TMLList: []TpidVid{ |
| 59 | { |
| 60 | Length: 3, |
| 61 | TpIDLength: 0x80, |
| 62 | TpIDValue: []byte{0}, |
| 63 | VIdLength: 1, |
| 64 | VIdValue: []byte{0x00}, |
| 65 | }, |
| 66 | { |
| 67 | Length: 2, |
| 68 | TpIDLength: 0x80, |
| 69 | TpIDValue: []byte{0}, |
| 70 | VIdLength: 0x80, |
| 71 | VIdValue: []byte{0}, |
| 72 | }}, |
| 73 | // TagOpPop(UI) |
| 74 | TOPopLength: 1, |
| 75 | TOPopValue: 0x00, |
| 76 | // TagOpSetList |
| 77 | TOSLength: 3, |
| 78 | TOSList: []TpidVid{ |
| 79 | { |
| 80 | Length: 2, |
| 81 | TpIDLength: 0x80, |
| 82 | TpIDValue: []byte{0}, |
| 83 | VIdLength: 0x80, |
| 84 | VIdValue: []byte{0}, |
| 85 | }}, |
| 86 | // TagOpPushList |
| 87 | TOPushLength: uint8(3 + len(pushTpidValue) + len(pushVidValue)), //6 |
| 88 | TOPushList: []TpidVid{ |
| 89 | {Length: uint8(2 + len(pushTpidValue) + len(pushVidValue)), |
| 90 | TpIDLength: uint8(len(pushTpidValue)), |
| 91 | TpIDValue: pushTpidValue, |
| 92 | VIdLength: uint8(len(pushVidValue)), |
| 93 | VIdValue: pushVidValue}}, ///{Length: 5, TpIdLength: 2, TpIdValue: []byte{0x88, 0xa8}, VIdLength: 1, VIdValue: []byte{0x64}} |
| 94 | // End |
| 95 | EndBranch: 0x00, |
| 96 | } |
| 97 | |
| 98 | return tibitData |
| 99 | } |