+def imei_from_packet(packet: bytes) -> Optional[str]:
+ if proto_of_message(packet) == LOGIN.PROTO:
+ msg = parse_message(packet)
+ if isinstance(msg, LOGIN):
+ return msg.imei
+ return None
+
+
+def is_goodbye_packet(packet: bytes) -> bool:
+ return proto_of_message(packet) == HIBERNATION.PROTO
+
+