| 263 | return r |
| 264 | |
| 265 | def send(self, x): |
| 266 | # type: (Packet) -> int |
| 267 | if hasattr(x, "sent_time"): |
| 268 | x.sent_time = time.time() |
| 269 | |
| 270 | if self.kernel_packet_class == IPv46: |
| 271 | # IPv46 is an auto-detection wrapper; we should just push through |
| 272 | # packets normally if we got IP or IPv6. |
| 273 | if not isinstance(x, (IP, IPv6)): |
| 274 | x = IP() / x |
| 275 | elif not isinstance(x, self.kernel_packet_class): |
| 276 | x = self.kernel_packet_class() / x |
| 277 | |
| 278 | sx = raw(x) |
| 279 | |
| 280 | try: |
| 281 | r = self.outs.write(sx) |
| 282 | self.outs.flush() |
| 283 | return r |
| 284 | except socket.error: |
| 285 | log_runtime.error("%s send", |
| 286 | self.__class__.__name__, exc_info=True) |
| 287 | |
| 288 | |
| 289 | # Bindings # |