blob: aae58ab7864af8b039db9a81edab26e819772d87 [file] [log] [blame]
Takahiro Suzukid7bf8202020-12-17 20:21:59 +09001/*
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
17package l2oam
18
19import (
20 "github.com/google/gopacket"
21)
22
23// GenerateSetAdminState generates "PON Port/Admin State" message
24func GenerateSetAdminState() gopacket.SerializableLayer {
25 tibitData := &TOAMSetRequest{
26 // IEEE 1904.2
27 Opcode: 0x03,
28 // OAM Protocol
29 Flags: 0x0050,
30 OAMPDUCode: 0xfe,
31 OUId: []byte{0x2a, 0xea, 0x15},
32 // TiBit OLT Management Interface
33 TOMIOpcode: 0x03,
34 // Correlation Tag
35 CTBranch: 0x0c,
36 CTType: 0x0c7a,
37 CTLength: 4,
38 CTInstance: getOltInstance(),
39 // Object Context
40 OCBranch: 0x0c,
41 OCType: 0x0007,
42 OCLength: 4,
43 OCInstance: 0x00000000,
44 // Vc
45 VcBranch: 0x07,
46 VcLeaf: 0x0001,
47 VcLength: 2,
48 // EC
49 ECLength: 1,
50 ECValue: []byte{0x01},
51 // End
52 EndBranch: 0x00,
53 }
54 return tibitData
55
56}
57
58// GenerateSetAdminStateDelete generates "PON Port/Admin State(for delete)" message
59func GenerateSetAdminStateDelete() gopacket.SerializableLayer {
60 tibitData := &TOAMSetRequest{
61 // IEEE 1904.2
62 Opcode: 0x03,
63 // OAM Protocol
64 Flags: 0x0050,
65 OAMPDUCode: 0xfe,
66 OUId: []byte{0x2a, 0xea, 0x15},
67 // TiBit OLT Management Interface
68 TOMIOpcode: 0x03,
69 // Correlation Tag
70 CTBranch: 0x0c,
71 CTType: 0x0c7a,
72 CTLength: 4,
73 CTInstance: getOltInstance(),
74 // Object Context
75 OCBranch: 0x0c,
76 OCType: 0x0007,
77 OCLength: 4,
78 OCInstance: 0x00000000,
79 // Vc
80 VcBranch: 0x07,
81 VcLeaf: 0x0001,
82 VcLength: 2,
83 // EC
84 ECLength: 1,
85 ECValue: []byte{0x02},
86 // End
87 EndBranch: 0x00,
88 }
89 return tibitData
90
91}