blob: 6dd13d8cd5368222c88aae626c0decbebe33cb07 [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// GenerateOnuSystemInfo generates "ONU System Information" message
24func GenerateOnuSystemInfo(PkgType string) gopacket.SerializableLayer {
25
26 if PkgType == OnuPkgTypeA {
27 //TypeA
28 data := &TibitFrame{
29 Data: []byte{
30 0x03, 0x00, 0x50, 0xfe, 0x00, 0x10, 0x00, 0x01,
31 0xd7, 0x00, 0x06, 0x00, 0x00,
32 },
33 }
34
35 return data
36 } else if PkgType == OnuPkgTypeB {
37 //TypeB
38 data := &TibitFrame{
39 Data: []byte{
40 0x03, 0x00, 0x50, 0xfe, 0x90, 0x82, 0x60, 0x00,
41 0xca, 0xfe, 0x00, 0xb7, 0x00, 0x40, 0x00, 0x00,
42 },
43 }
44
45 return data
46 }
47
48 return nil
49}
50
51// GetOnuSerialNo returns a serial number
52func GetOnuSerialNo(pkgType string, data []byte) string {
53 if pkgType == OnuPkgTypeA {
54 // 030050fe00100002 00 - 07
55 // d70006404d493920 08 - 15
56 // 32304b2042303041 16 - 23
57 // 3730204130302031 24 - 31
58 // 3730382020202020
59 // 2000000030313233
60 // 3435363730313233
61 // 3435363738394041
62 // 42434445
63 return string(data[20:26])
64 }
65 return ""
66}
67
68// GetOnuManufacture returns a manufacture information
69func GetOnuManufacture(pkgType string, data []byte) string {
70 if pkgType == OnuPkgTypeA {
71 if data[16] == 0x32 && data[17] == 0x30 && data[18] == 0x4b {
72 return "FURUKAWA"
73 }
74 }
75 return ""
76}