blob: c26825d56ea6c801fc1a313f142f3fc0998e89bd [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 "encoding/binary"
21
22 "github.com/google/gopacket"
23)
24
25// GenerateGuaranteedRate generates "Traffic Profile/Guaranteed Rate" message
26func GenerateGuaranteedRate(ecvalue []byte, trafficProfile []byte) gopacket.SerializableLayer {
27
28 tibitData := &TOAMSetRequest{
29 // IEEE 1904.2
30 Opcode: 0x03,
31 // OAM Protocol
32 Flags: 0x0050,
33 OAMPDUCode: 0xfe,
34 OUId: []byte{0x2a, 0xea, 0x15},
35 // TiBit OLT Management Interface
36 TOMIOpcode: 0x03,
37 // Correlation Tag
38 CTBranch: 0x0c,
39 CTType: 0x0c7a,
40 CTLength: 4,
41 CTInstance: getOltInstance(),
42 // Object Context
43 OCBranch: 0x0c,
44 OCType: 0x070f,
45 OCLength: 4,
46 OCInstance: binary.BigEndian.Uint32(trafficProfile),
47 // Vc
48 VcBranch: 0x7f,
49 VcLeaf: 0x0006,
50 VcLength: uint8(1 + len(ecvalue)), //
51 // EC
52 ECLength: uint8(len(ecvalue)), //
53 ECValue: ecvalue, //0x80
54 // End
55 EndBranch: 0x00,
56 }
57 return tibitData
58}