Browse Source

move proto bit helper func to steam.util

pull/18/merge
Rossen Georgiev 9 years ago
parent
commit
214258ee44
  1. 3
      steam/core/cm.py
  2. 16
      steam/core/msg.py
  3. 14
      steam/util/__init__.py

3
steam/core/cm.py

@ -19,10 +19,9 @@ from steam.enums import EResult, EUniverse
from steam.enums.emsg import EMsg
from steam.core import crypto
from steam.core.connection import TCPConnection
from steam.core.msg import is_proto, clear_proto_bit
from steam.core.msg import Msg, MsgProto
from steam.util.events import EventEmitter
from steam.util import ip_from_int
from steam.util import ip_from_int, is_proto, clear_proto_bit
logger = logging.getLogger("CMClient")

16
steam/core/msg.py

@ -5,6 +5,7 @@ from steam.enums.emsg import EMsg
from steam.protobufs import steammessages_base_pb2
from steam.protobufs import steammessages_clientserver_pb2
from steam.protobufs import steammessages_clientserver_2_pb2
from steam.util import set_proto_bit, clear_proto_bit
class MsgHdr:
@ -96,21 +97,6 @@ class ExtendedMsgHdr:
])
protobuf_mask = 0x80000000
def is_proto(emsg):
return (int(emsg) & protobuf_mask) > 0
def set_proto_bit(emsg):
return int(emsg) | protobuf_mask
def clear_proto_bit(emsg):
return int(emsg) & ~protobuf_mask
class MsgHdrProtoBuf:
_size = struct.calcsize("<II")

14
steam/util/__init__.py

@ -7,3 +7,17 @@ def ip_from_int(ip):
def ip_to_int(ip):
return struct.unpack(">L", socket.inet_aton(ip))[0]
protobuf_mask = 0x80000000
def is_proto(emsg):
return (int(emsg) & protobuf_mask) > 0
def set_proto_bit(emsg):
return int(emsg) | protobuf_mask
def clear_proto_bit(emsg):
return int(emsg) & ~protobuf_mask

Loading…
Cancel
Save