Zdravko Bozakov | 3d76214 | 2019-07-15 16:57:17 +0200 | [diff] [blame^] | 1 | package core |
| 2 | |
| 3 | type AniGAttributes int |
| 4 | const ( |
| 5 | _ = iota |
| 6 | SRIndication AniGAttributes = 0x8000 |
| 7 | TotalTcontNumber AniGAttributes = 0x4000 |
| 8 | GEMBlockLength AniGAttributes = 0x2000 |
| 9 | PiggybackDBAReporting AniGAttributes = 0x1000 |
| 10 | WholeONTDBAReporting AniGAttributes = 0x0800 |
| 11 | SFThreshold AniGAttributes = 0x0400 |
| 12 | SDThreshold AniGAttributes = 0x0200 |
| 13 | ARC AniGAttributes = 0x0100 |
| 14 | ARCInterval AniGAttributes = 0x0080 |
| 15 | OpticalSignalLevel AniGAttributes = 0x0040 |
| 16 | LowerOpticalThreshold AniGAttributes = 0x0020 |
| 17 | UpperOpticalThreshold AniGAttributes = 0x0010 |
| 18 | ONTResponseTime AniGAttributes = 0x0008 |
| 19 | TransmitOpticalLeval AniGAttributes = 0x0004 |
| 20 | LowerTransmitPowerThreshold AniGAttributes = 0x0002 |
| 21 | UpperTransmitPowerThreshold AniGAttributes = 0x0001 |
| 22 | ) |
| 23 | |
| 24 | type ANIGAttributeHandler func(*uint, []byte) ([]byte, error) |
| 25 | |
| 26 | var ANIGAttributeHandlers = map[AniGAttributes]ANIGAttributeHandler{ |
| 27 | SRIndication: GetSRIndication, |
| 28 | OpticalSignalLevel: GetOpticalSignalLevel, |
| 29 | LowerOpticalThreshold: GetLowerOpticalThreshold, |
| 30 | UpperOpticalThreshold: GetUpperOpticalThreshold, |
| 31 | TotalTcontNumber: GetTotalTcontNumber, |
| 32 | GEMBlockLength: GetGEMBlockLength, |
| 33 | PiggybackDBAReporting: GetPiggybackDBAReporting, |
| 34 | WholeONTDBAReporting: GetWholeONTDBAReporting, |
| 35 | SFThreshold: GetSFThreshold, |
| 36 | SDThreshold: GetSDThreshold, |
| 37 | ARC: GetARC, |
| 38 | ARCInterval: GetARCInterval, |
| 39 | ONTResponseTime: GetONTResponseTime, |
| 40 | TransmitOpticalLeval: GetTransmitOpticalLeval, |
| 41 | LowerTransmitPowerThreshold: GetLowerTransmitPowerThreshold, |
| 42 | UpperTransmitPowerThreshold: GetUpperTransmitPowerThreshold, |
| 43 | } |
| 44 | |
| 45 | |
| 46 | func GetANIGAttributes(pos *uint, pkt []byte, content OmciContent) ([]byte, error) { |
| 47 | AttributesMask := getAttributeMask(content) |
| 48 | |
| 49 | for index := uint(16); index>=1 ; index-- { |
| 50 | Attribute := 1 << (index - 1) |
| 51 | reqAttribute := Attribute & AttributesMask |
| 52 | |
| 53 | if reqAttribute != 0 { |
| 54 | pkt, _ = ANIGAttributeHandlers[AniGAttributes(reqAttribute)](pos, pkt) |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | pkt[8] = 0x00 // Command Processed Successfully |
| 59 | pkt[9] = uint8(AttributesMask >> 8) |
| 60 | pkt[10] = uint8(AttributesMask & 0x00FF) |
| 61 | |
| 62 | return pkt, nil |
| 63 | |
| 64 | } |
| 65 | |
| 66 | |
| 67 | func GetSRIndication(pos *uint, pkt []byte) ([]byte, error) { |
| 68 | pkt[*pos] = 0x01 |
| 69 | *pos++ |
| 70 | return pkt, nil |
| 71 | } |
| 72 | |
| 73 | func GetOpticalSignalLevel(pos *uint, pkt []byte) ([]byte, error) { |
| 74 | pkt[*pos] = 0xd7 |
| 75 | *pos++ |
| 76 | pkt[*pos] = 0xa9 |
| 77 | *pos++ |
| 78 | return pkt, nil |
| 79 | } |
| 80 | |
| 81 | func GetTotalTcontNumber(pos *uint, pkt []byte) ([]byte, error) { |
| 82 | pkt[*pos] = 0x08 |
| 83 | *pos++ |
| 84 | return pkt, nil |
| 85 | } |
| 86 | |
| 87 | func GetGEMBlockLength(pos *uint, pkt []byte) ([]byte, error) { |
| 88 | pkt[*pos] = 0x00 |
| 89 | *pos++ |
| 90 | pkt[*pos] = 0x30 |
| 91 | return pkt, nil |
| 92 | } |
| 93 | |
| 94 | func GetPiggybackDBAReporting (pos *uint, pkt []byte) ([]byte, error) { |
| 95 | pkt[*pos] = 0x00 |
| 96 | *pos++ |
| 97 | return pkt, nil |
| 98 | } |
| 99 | |
| 100 | func GetWholeONTDBAReporting(pos *uint, pkt []byte) ([]byte, error) { |
| 101 | pkt[*pos] = 0x00 |
| 102 | *pos++ |
| 103 | return pkt, nil |
| 104 | } |
| 105 | |
| 106 | func GetUpperOpticalThreshold(pos *uint, pkt []byte) ([]byte, error) { |
| 107 | pkt[*pos] = 0xff |
| 108 | *pos++ |
| 109 | return pkt, nil |
| 110 | } |
| 111 | |
| 112 | func GetSFThreshold(pos *uint, pkt []byte) ([]byte, error) { |
| 113 | pkt[*pos] = 0x03 |
| 114 | *pos++ |
| 115 | return pkt, nil |
| 116 | } |
| 117 | |
| 118 | func GetSDThreshold(pos *uint, pkt []byte) ([]byte, error) { |
| 119 | pkt[*pos] = 0x05 |
| 120 | *pos++ |
| 121 | return pkt, nil |
| 122 | } |
| 123 | |
| 124 | func GetARC(pos *uint, pkt []byte) ([]byte, error) { |
| 125 | pkt[*pos] = 0x00 |
| 126 | *pos++ |
| 127 | return pkt, nil |
| 128 | } |
| 129 | |
| 130 | func GetARCInterval(pos *uint, pkt []byte) ([]byte, error) { |
| 131 | pkt[*pos] = 0x00 |
| 132 | *pos++ |
| 133 | return pkt, nil |
| 134 | } |
| 135 | |
| 136 | func GetONTResponseTime(pos *uint, pkt []byte) ([]byte, error) { |
| 137 | pkt[*pos] = 0x00 |
| 138 | *pos++ |
| 139 | pkt[*pos] = 0x00 |
| 140 | *pos++ |
| 141 | return pkt, nil |
| 142 | } |
| 143 | |
| 144 | func GetLowerOpticalThreshold(pos *uint, pkt []byte) ([]byte, error) { |
| 145 | pkt[*pos] = 0xff |
| 146 | *pos++ |
| 147 | return pkt, nil |
| 148 | } |
| 149 | |
| 150 | func GetTransmitOpticalLeval(pos *uint, pkt []byte) ([]byte, error) { |
| 151 | pkt[*pos] = 0x07 |
| 152 | *pos++ |
| 153 | pkt[*pos] = 0x1e |
| 154 | *pos++ |
| 155 | return pkt, nil |
| 156 | } |
| 157 | |
| 158 | func GetLowerTransmitPowerThreshold(pos *uint, pkt []byte) ([]byte, error) { |
| 159 | pkt[*pos] = 0x81 |
| 160 | *pos++ |
| 161 | return pkt, nil |
| 162 | } |
| 163 | |
| 164 | func GetUpperTransmitPowerThreshold(pos *uint, pkt []byte) ([]byte, error) { |
| 165 | pkt[*pos] = 0x81 |
| 166 | *pos++ |
| 167 | return pkt, nil |
| 168 | } |