MCPcopy
hub / github.com/evilsocket/opensnitch / deserialize

Method deserialize

daemon/netlink/socket_linux.go:157–186  ·  view source on GitHub ↗
(b []byte)

Source from the content-addressed store, hash-verified

155}
156
157func (s *Socket) deserialize(b []byte) error {
158 if len(b) < sizeofSocket {
159 return fmt.Errorf("socket data short read (%d); want %d", len(b), sizeofSocket)
160 }
161 rb := readBuffer{Bytes: b}
162 s.Family = rb.Read()
163 s.State = rb.Read()
164 s.Timer = rb.Read()
165 s.Retrans = rb.Read()
166 s.ID.SourcePort = networkOrder.Uint16(rb.Next(2))
167 s.ID.DestinationPort = networkOrder.Uint16(rb.Next(2))
168 if s.Family == syscall.AF_INET6 {
169 s.ID.Source = net.IP(rb.Next(16))
170 s.ID.Destination = net.IP(rb.Next(16))
171 } else {
172 s.ID.Source = net.IPv4(rb.Read(), rb.Read(), rb.Read(), rb.Read())
173 rb.Next(12)
174 s.ID.Destination = net.IPv4(rb.Read(), rb.Read(), rb.Read(), rb.Read())
175 rb.Next(12)
176 }
177 s.ID.Interface = native.Uint32(rb.Next(4))
178 s.ID.Cookie[0] = native.Uint32(rb.Next(4))
179 s.ID.Cookie[1] = native.Uint32(rb.Next(4))
180 s.Expires = native.Uint32(rb.Next(4))
181 s.RQueue = native.Uint32(rb.Next(4))
182 s.WQueue = native.Uint32(rb.Next(4))
183 s.UID = native.Uint32(rb.Next(4))
184 s.INode = native.Uint32(rb.Next(4))
185 return nil
186}
187
188// SocketKill kills a connection
189func SocketKill(family, proto uint8, sockID SocketID) error {

Callers 1

netlinkRequestFunction · 0.95

Calls 2

ReadMethod · 0.95
NextMethod · 0.95

Tested by

no test coverage detected