当前位置: 首页>>代码示例>>C++>>正文


C++ PyRep::visit方法代码示例

本文整理汇总了C++中PyRep::visit方法的典型用法代码示例。如果您正苦于以下问题:C++ PyRep::visit方法的具体用法?C++ PyRep::visit怎么用?C++ PyRep::visit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyRep的用法示例。


在下文中一共展示了PyRep::visit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: tcp_callback

void tcp_callback (struct tcp_stream *a_tcp, void ** this_time_not_needed) {
    char buf[1024];
    strcpy (buf, adres (a_tcp->addr)); // we put conn params into buf

    if (a_tcp->nids_state == NIDS_JUST_EST) {

        //see if this is a stream we care about...
        if(a_tcp->addr.source != 26000 && a_tcp->addr.dest != 26000 &&
                a_tcp->addr.source != 26001 && a_tcp->addr.dest != 26001)
            return;

        a_tcp->client.collect++; // we want data received by a client
        a_tcp->server.collect++; // and by a server, too
        _log(COLLECT__TCP, "%s established", buf);
        return;
    }
    if (a_tcp->nids_state == NIDS_CLOSE) {
        // connection has been closed normally
        _log(COLLECT__TCP, "%s closing", buf);
        return;
    }
    if (a_tcp->nids_state == NIDS_RESET) {
        // connection has been closed by RST
        _log(COLLECT__TCP, "%s reset", buf);
        return;
    }

    if (a_tcp->nids_state == NIDS_DATA) {
        // new data has arrived; gotta determine in what direction
        // and if it's urgent or not

        struct half_stream *hlf;
        StreamPacketizer *sp;

        if (a_tcp->client.count_new) {
            // new data for client
            hlf = &a_tcp->client; // from now on, we will deal with hlf var,
            // which will point to client side of conn
            sp = &clientPacketizer;
            strcat (buf, "(<-)"); // symbolic direction of data
        } else {
            sp = &serverPacketizer;
            hlf = &a_tcp->server; // analogical
            strcat (buf, "(->)");
        }

        _log(COLLECT__TCP, "Data %s (len %d)", buf, hlf->count_new); // we print the connection parameters
        // (saddr, daddr, sport, dport) accompanied
        // by data flow direction (-> or <-)

        sp->InputBytes((const byte *) hlf->data, hlf->count_new);

        StreamPacketizer::Packet *p;
        while((p = sp->PopPacket()) != NULL) {
            //const PacketHeader *head = (const PacketHeader *) p->data;

            uint32 body_len = p->length;
            const byte *body = p->data;

            _log(COLLECT__RAW_HEX, "Raw Hex Dump of len %d:", body_len);
            _hex(COLLECT__RAW_HEX, body, body_len);

            PyRep *rep = InflateAndUnmarshal(body, body_len);
            if(rep == NULL) {
                printf("Failed to inflate or unmarshal!");
                delete p;
                continue;
            }

            if(is_log_enabled(COLLECT__PYREP_DUMP)) {
                //decode substreams to facilitate dumping better:
                SubStreamDecoder v;
                rep->visit(&v);
                //TODO: make dump use logsys.
                _log(COLLECT__PYREP_DUMP, "Unmarshaled PyRep:");
                PyLookupDump dumper(&CollectDispatcher->lookResolver, COLLECT__PYREP_DUMP);
                rep->visit(&dumper);
            }

            PyPacket *packet = new PyPacket;
            if(!packet->Decode(rep)) {
                _log(COLLECT__ERROR, "Failed to decode packet rep");
            } else {
                if(is_log_enabled(COLLECT__PACKET_DUMP)) {
                    //decode substreams to facilitate dumping better:
                    SubStreamDecoder v;
                    packet->payload->visit(&v);

                    //TODO: make dump use logsys.
                    _log(COLLECT__PACKET_DUMP, "Decoded message:");
                    PyLookupDump dumper(&CollectDispatcher->lookResolver, COLLECT__PACKET_DUMP);
                    packet->Dump(COLLECT__PACKET_DUMP, &dumper);


                    printf("\n\n");
                }
                fflush(stdout);

                CollectDispatcher->DispatchPacket(&packet);
            }
//.........这里部分代码省略.........
开发者ID:valador,项目名称:Evemu,代码行数:101,代码来源:EVEnids.cpp


注:本文中的PyRep::visit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。