(b []byte)
| 155 | } |
| 156 | |
| 157 | func (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 |
| 189 | func SocketKill(family, proto uint8, sockID SocketID) error { |
no test coverage detected