54 "SESSIONCHANGENOTIFICATION",
56 "SESSIONINITIALSTATENOTIFICATION",
63 : type_string(
"none"),
67 named_payload(nullptr),
97 _log(ltype,
"Packet:");
100 _log(ltype,
" Source:");
102 _log(ltype,
" Dest:");
105 _log(ltype,
" Payload:");
108 _log(ltype,
" Named Payload: None (null)");
110 _log(ltype,
" Named Payload:");
117 PyRep *packet = *in_packet;
118 *in_packet =
nullptr;
125 if (packet ==
nullptr) {
126 codelog(NET__PACKET_ERROR,
"PyPacket::Decode() - packet is null.");
138 if (ss->
decoded() ==
nullptr) {
139 codelog(NET__PACKET_ERROR,
"PyPacket::Decode() - unable to decode initial packet substream.");
148 codelog(NET__PACKET_ERROR,
"PyPacket::Decode() - packet body is not PyObject: %s", packet->
TypeString());
155 codelog(NET__PACKET_ERROR,
"PyPacket::Decode() - packet body does not contain a tuple");
160 if (tuple ==
nullptr) {
161 codelog(NET__PACKET_ERROR,
"PyPacket::Decode() - tuple is null.");
165 if (tuple->
items.size() != 7) {
166 codelog(NET__PACKET_ERROR,
"PyPacket::Decode() - packet body does not contain a tuple of length 7 (is %u)", tuple->
items.size());
171 if (!tuple->
items[0]->IsInt()) {
172 codelog(NET__PACKET_ERROR,
"PyPacket::Decode() - First main tuple element is not an integer");
218 if (!tuple->
items[4]->IsTuple()) {
219 codelog(NET__PACKET_ERROR,
"PyPacket::Decode() - Fifth main tuple element is not a tuple");
226 if (tuple->
items[5]->IsNone()) {
228 }
else if (tuple->
items[5]->IsDict()) {
231 codelog(NET__PACKET_ERROR,
"PyPacket::Decode() - Sixth main tuple element is neither dict or none.");
287 fprintf(into,
"%sAny: service='%s' callID=%li", pfx,
service.c_str(),
callID);
293 fprintf(into,
"%sClient: clientID=%li service='%s' callID=%li", pfx,
objectID,
service.c_str(),
callID);
296 fprintf(into,
"%sBroadcast: broadcastID='%s' narrowcast=(not implemented) idtype='%s'", pfx,
service.c_str(),
bcast_idtype.c_str());
316 _log(ltype,
"%sBroadcast: broadcastID='%s' narrowcast=(not implemented) idtype='%s'", pfx,
service.c_str(),
bcast_idtype.c_str());
333 PyRep *base = in_object;
336 if (base ==
nullptr) {
337 codelog(NET__PACKET_ERROR,
"PyAddress::Decode() - base is null.");
342 codelog(NET__PACKET_ERROR,
"Invalid element type, expected object but got %s", base->
TypeString());
348 if (tuple ==
nullptr) {
349 codelog(NET__PACKET_ERROR,
"PyAddress::Decode() - tuple is null.");
353 if (tuple->
items.size() < 3) {
354 codelog(NET__PACKET_ERROR,
"Not enough elements in address tuple: %u", tuple->
items.size());
355 tuple->
Dump(NET__PACKET_ERROR,
" ");
362 if (!tuple->
items[0]->IsInt()) {
363 codelog(NET__PACKET_ERROR,
"Wrong type on address element (0)");
364 tuple->
items[0]->Dump(NET__PACKET_ERROR,
" ");
372 if (tuple->
items.size() != 3) {
373 codelog(NET__PACKET_ERROR,
"Invalid number of elements in Any address tuple: %lu", tuple->
items.size());
388 if (tuple->
items.size() != 4) {
389 codelog(NET__PACKET_ERROR,
"Invalid number of elements in Node address tuple: %lu", tuple->
items.size());
405 if (tuple->
items.size() != 4) {
406 codelog(NET__PACKET_ERROR,
"Invalid number of elements in Client address tuple: %lu", tuple->
items.size());
422 if (tuple->
items.size() != 4) {
423 codelog(NET__PACKET_ERROR,
"Invalid number of elements in Broadcast address tuple: %lu", tuple->
items.size());
430 if (!tuple->
items[1]->IsString()) {
431 codelog(NET__PACKET_ERROR,
"Invalid type %s for brodcastID", tuple->
items[1]->TypeString());
436 if (!tuple->
items[3]->IsString()) {
437 codelog(NET__PACKET_ERROR,
"Invalid type %s for idtype", tuple->
items[3]->TypeString());
534 return new PyObject(
"macho.MachoAddress", t );
582 _log(type,
"Call Stream:");
588 _log(type,
" Arguments:");
591 _log(type,
" Named Arguments: None");
593 _log(type,
" Named Arguments:");
600 in_payload =
nullptr;
607 if (payload ==
nullptr) {
608 codelog(NET__PACKET_ERROR,
"PyCallStream::Decode() - payload is null.");
612 if (type !=
"macho.CallReq") {
613 codelog(NET__PACKET_ERROR,
"PyCallStream::Decode() - packet payload has unknown string type '%s'", type.c_str());
618 if (payload->
items.size() != 1) {
619 codelog(NET__PACKET_ERROR,
"PyCallStream::Decode() - invalid tuple length %lu", payload->
items.size());
623 if (!payload->
items[0]->IsTuple()) {
624 codelog(NET__PACKET_ERROR,
"PyCallStream::Decode() - non tuple payload[0]");
630 if (payload2 ==
nullptr) {
631 codelog(NET__PACKET_ERROR,
"PyCallStream::Decode() - payload2 is null.");
637 if (payload2->
items.size() != 2) {
638 codelog(NET__PACKET_ERROR,
"PyCallStream::Decode() - invalid tuple2 length %lu", payload2->
items.size());
646 if (!payload2->
items[1]->IsSubStream()) {
647 codelog(NET__PACKET_ERROR,
"PyCallStream::Decode() - non-substream type");
655 codelog(NET__PACKET_ERROR,
"PyCallStream::Decode() - ss is null.");
662 if (ss->
decoded() ==
nullptr) {
663 codelog(NET__PACKET_ERROR,
"PyCallStream::Decode() - Unable to decode call stream");
671 codelog(NET__PACKET_ERROR,
"PyCallStream::Decode() - packet body does not contain a tuple");
679 if (maint ==
nullptr) {
680 codelog(NET__PACKET_ERROR,
"PyCallStream::Decode() - maint is null.");
683 if (maint->
items.size() != 4) {
684 codelog(NET__PACKET_ERROR,
"PyCallStream::Decode() - packet body has %lu elements, expected %d", maint->
items.size(), 4);
693 if (maint->
items[0]->IsInt()) {
696 }
else if (maint->
items[0]->IsString()) {
700 codelog(NET__PACKET_ERROR,
"PyCallStream::Decode() - maint->items[0] has invalid type %s", maint->
items[0]->TypeString());
701 codelog(NET__PACKET_ERROR,
" in:");
702 payload->
Dump(NET__PACKET_ERROR,
" ");
711 if (maint->
items[1]->IsString()) {
714 codelog(NET__PACKET_ERROR,
"PyCallStream::Decode() - maint->items[1] has non-string type");
715 maint->
items[1]->Dump(NET__PACKET_ERROR,
" --> ");
716 codelog(NET__PACKET_ERROR,
" in:");
717 payload->
Dump(NET__PACKET_ERROR,
" ");
726 if (!maint->
items[2]->IsTuple()) {
727 codelog(NET__PACKET_ERROR,
"PyCallStream::Decode() - argument list has non-tuple type");
728 maint->
items[2]->Dump(NET__PACKET_ERROR,
" --> ");
729 codelog(NET__PACKET_ERROR,
"in:");
730 payload->
Dump(NET__PACKET_ERROR,
" ");
740 if (maint->
items[3]->IsNone()) {
742 }
else if (maint->
items[3]->IsDict()) {
745 codelog(NET__PACKET_ERROR,
"PyCallStream::Decode() - tuple[3] has non-dict type");
746 maint->
items[3]->Dump(NET__PACKET_ERROR,
" --> ");
747 codelog(NET__PACKET_ERROR,
"in:");
748 payload->
Dump(NET__PACKET_ERROR,
" ");
795 : notifyType(
"NO TYPE SET"),
819 _log(type,
" Arguments:");
825 in_payload =
nullptr;
830 if (payload ==
nullptr) {
831 codelog(NET__PACKET_ERROR,
"EVENotificationStream::Decode() - payload is null.");
835 if (pkt_type !=
"macho.Notification") {
836 codelog(NET__PACKET_ERROR,
"EVENotificationStream::Decode() - notification payload has unknown string type %s", pkt_type.c_str());
842 if (payload->
items.size() != 2) {
843 codelog(NET__PACKET_ERROR,
"EVENotificationStream::Decode() - invalid tuple length %lu", payload->
items.size());
847 if (!payload->
items[0]->IsTuple()) {
848 codelog(NET__PACKET_ERROR,
"EVENotificationStream::Decode() - non-tuple payload[0]");
853 if (payload2 ==
nullptr) {
854 codelog(NET__PACKET_ERROR,
"EVENotificationStream::Decode() - payload2 is null.");
859 if (payload2->
items.size() != 2) {
860 codelog(NET__PACKET_ERROR,
"EVENotificationStream::Decode() - invalid tuple2 length %lu", payload2->
items.size());
868 if (!payload2->
items[1]->IsSubStream()) {
869 codelog(NET__PACKET_ERROR,
"EVENotificationStream::Decode() - non-substream type");
877 codelog(NET__PACKET_ERROR,
"EVENotificationStream::Decode() - ss is null.");
883 if (ss->decoded() ==
nullptr) {
884 codelog(NET__PACKET_ERROR,
"EVENotificationStream::Decode() - Unable to decode call stream");
891 if (!ss->decoded()->IsTuple()) {
892 codelog(NET__PACKET_ERROR,
"EVENotificationStream::Decode() - packet body does not contain a tuple");
900 if (robjt ==
nullptr) {
901 codelog(NET__PACKET_ERROR,
"EVENotificationStream::Decode() - robjt is null.");
907 if (robjt->
items.size() != 2) {
908 codelog(NET__PACKET_ERROR,
"EVENotificationStream::Decode() - packet body has %lu elements, expected %d", robjt->
items.size(), 2);
917 if (robjt->
items[0]->IsInt()) {
920 }
else if (robjt->
items[0]->IsString()) {
924 codelog(NET__PACKET_ERROR,
"EVENotificationStream::Decode() - main tuple[0] has invalid type %s", robjt->
items[0]->TypeString());
925 _log(NET__PACKET_ERROR,
" in:");
926 payload->
Dump( NET__PACKET_ERROR,
"" );
934 if (!robjt->
items[1]->IsTuple()) {
935 codelog(NET__PACKET_ERROR,
"EVENotificationStream::Decode() - main tuple[1] has non-tuple type %s", robjt->
items[0]->TypeString());
936 _log(NET__PACKET_ERROR,
" it is:");
937 payload->
Dump( NET__PACKET_ERROR,
"" );
946 if (subt ==
nullptr) {
947 codelog(NET__PACKET_ERROR,
"EVENotificationStream::Decode() - subt is null.");
954 if (subt->items.size() != 2) {
955 codelog(NET__PACKET_ERROR,
"EVENotificationStream::Decode() - packet body has %lu elements, expected %d", subt->items.size(), 2);
965 if (subt->items[0]->IsInt()) {
969 codelog(NET__PACKET_ERROR,
"EVENotificationStream::Decode() - sub tuple[0] has invalid type %s", subt->items[0]->TypeString());
970 _log(NET__PACKET_ERROR,
" in:");
971 payload->
Dump( NET__PACKET_ERROR,
"" );
980 if (!subt->items[1]->IsTuple()) {
981 codelog(NET__PACKET_ERROR,
"EVENotificationStream::Decode() - subt tuple[1] has non-tuple type %s", robjt->
items[0]->TypeString());
982 _log(NET__PACKET_ERROR,
" it is:");
983 payload->
Dump( NET__PACKET_ERROR,
"" );
static std::string StringContent(PyRep *pRep)
void Dump(LogType type, PyVisitor &dumper)
const char * MACHONETMSG_TYPE_NAMES[MACHONETMSG_TYPE_COUNT]
#define _log(type, fmt,...)
bool IsChecksumedStream() const
void operator=(const PyAddress &right)
bool visit(PyVisitor &v) const
Visits object.
void Dump(FILE *into, const char *pfx) const
Dumps object to file.
PyCallStream * Clone() const
PyRep * arguments() const
void Dump(FILE *into, const char *pfx) const
void Dump(LogType type, PyVisitor &dumper)
PySubStream * AsSubStream()
PyChecksumedStream * AsChecksumedStream()
PyRep * Clone() const
Clones object.
PyTuple * new_tuple(int64 arg1)
#define codelog(type, fmt,...)
void SetItem(size_t index, PyRep *object)
Stores Python object.
PyRep * Clone() const
Clones object.
bool Decode(const std::string &pkt_type, const std::string ¬ify_type, PyTuple *&payload)
void Dump(LogType type, PyVisitor &dumper)
bool Decode(PyRep *&object)
bool Decode(const std::string &type, PyTuple *&payload)
EVENotificationStream * Clone() const
bool _DecodeObjectID(PyRep *rep)
bool Decode(PyRep **packet)
const std::string & content() const
Get the PyString content.
bool visit(PyVisitor &v) const
Visits object.
bool _DecodeCallID(PyRep *rep)
std::string remoteObjectStr
static int64 IntegerValue(PyRep *pRep)
const char * TypeString() const
bool _DecodeService(PyRep *rep)
std::string remoteObjectStr