MCPcopy Create free account
hub / github.com/Edgio/vflow / decodeIPv6Header

Method decodeIPv6Header

packet/network.go:135–159  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

133}
134
135func (p *Packet) decodeIPv6Header() error {
136 if len(p.data) < IPv6HLen {
137 return errShortIPv6HeaderLength
138 }
139
140 var (
141 src net.IP = p.data[8:24]
142 dst net.IP = p.data[24:40]
143 )
144
145 p.L3 = IPv6Header{
146 Version: int(p.data[0]) >> 4,
147 TrafficClass: int(p.data[0]&0x0f)<<4 | int(p.data[1])>>4,
148 FlowLabel: int(p.data[1]&0x0f)<<16 | int(p.data[2])<<8 | int(p.data[3]),
149 PayloadLen: int(uint16(p.data[4])<<8 | uint16(p.data[5])),
150 NextHeader: int(p.data[6]),
151 HopLimit: int(p.data[7]),
152 Src: src.String(),
153 Dst: dst.String(),
154 }
155
156 p.data = p.data[IPv6HLen:]
157
158 return nil
159}
160
161func (p *Packet) decodeIPv4Header() error {
162 if len(p.data) < IPv4HLen {

Callers 2

DecoderMethod · 0.95
decodeEthernetHeaderMethod · 0.95

Calls 1

StringMethod · 0.80

Tested by

no test coverage detected