blob: af11a665ecdef5ac06ce89657cc5e9baab0b5ea5 [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// GenerateSetTrafficProfile generates "Traffic Control/Traffic Profile" message
24func GenerateSetTrafficProfile(trafficControl []byte, trafficProfile []byte) gopacket.SerializableLayer {
25 tibitData := &setTrafficControlTrafficProfileReq{
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: 0x07c0,
42 OCLength: 4,
43 OCInstance: trafficControl,
44 // Vc
45 VcBranch: 0x7c,
46 VcLeaf: 0x0002,
47 VcLength: 9,
48 // EC OC
49 ECOC: []ECOCTrafficControlTrafficProfile{
50 {
51 EcOcLength: 8,
52 EcOcBranch: 0x0c,
53 EcOcType: 0x070f,
54 EcOcLength2: 4,
55 EcOcInstance: trafficProfile,
56 },
57 },
58 // End
59 EndBranch: 0x00,
60 }
61 return tibitData
62}