static int usb_net_handle_dataout(USBNetState *s, USBPacket *p)

{

    int ret = p->len;

    int sz = sizeof(s->out_buf) - s->out_ptr;

    struct rndis_packet_msg_type *msg =

            (struct rndis_packet_msg_type *) s->out_buf;

    uint32_t len;



#ifdef TRAFFIC_DEBUG

    fprintf(stderr, "usbnet: data out len %u\n", p->len);

    {

        int i;

        fprintf(stderr, ":");

        for (i = 0; i < p->len; i++) {

            if (!(i & 15))

                fprintf(stderr, "\n%04x:", i);

            fprintf(stderr, " %02x", p->data[i]);

        }

        fprintf(stderr, "\n\n");

    }

#endif



    if (sz > ret)

        sz = ret;

    memcpy(&s->out_buf[s->out_ptr], p->data, sz);

    s->out_ptr += sz;



    if (!is_rndis(s)) {

        if (ret < 64) {

            qemu_send_packet(&s->nic->nc, s->out_buf, s->out_ptr);

            s->out_ptr = 0;

        }

        return ret;

    }

    len = le32_to_cpu(msg->MessageLength);

    if (s->out_ptr < 8 || s->out_ptr < len)

        return ret;

    if (le32_to_cpu(msg->MessageType) == RNDIS_PACKET_MSG) {

        uint32_t offs = 8 + le32_to_cpu(msg->DataOffset);

        uint32_t size = le32_to_cpu(msg->DataLength);

        if (offs + size <= len)

            qemu_send_packet(&s->nic->nc, s->out_buf + offs, size);

    }

    s->out_ptr -= len;

    memmove(s->out_buf, &s->out_buf[len], s->out_ptr);



    return ret;

}

static int usb_net_handle_dataout(USBNetState *s, USBPacket *p)

{

    int ret = p->len;

    int sz = sizeof(s->out_buf) - s->out_ptr;

    struct rndis_packet_msg_type *msg =

            (struct rndis_packet_msg_type *) s->out_buf;

    uint32_t len;



#ifdef TRAFFIC_DEBUG

    fprintf(stderr, "usbnet: data out len %u\n", p->len);

    {

        int i;

        fprintf(stderr, ":");

        for (i = 0; i < p->len; i++) {

            if (!(i & 15))

                fprintf(stderr, "\n%04x:", i);

            fprintf(stderr, " %02x", p->data[i]);

        }

        fprintf(stderr, "\n\n");

    }

#endif



    if (sz > ret)

        sz = ret;

    memcpy(&s->out_buf[s->out_ptr], p->data, sz);

    s->out_ptr += sz;



    if (!is_rndis(s)) {

        if (ret < 64) {

            qemu_send_packet(&s->nic->nc, s->out_buf, s->out_ptr);

            s->out_ptr = 0;

        }

        return ret;

    }

    len = le32_to_cpu(msg->MessageLength);

    if (s->out_ptr < 8 || s->out_ptr < len)

        return ret;

    if (le32_to_cpu(msg->MessageType) == RNDIS_PACKET_MSG) {

        uint32_t offs = 8 + le32_to_cpu(msg->DataOffset);

        uint32_t size = le32_to_cpu(msg->DataLength);

        if (offs + size <= len)

            qemu_send_packet(&s->nic->nc, s->out_buf + offs, size);

    }

    s->out_ptr -= len;

    memmove(s->out_buf, &s->out_buf[len], s->out_ptr);



    return ret;

}

        int i;         fprintf(stderr, ":");             if (!(i & 15))                 fprintf(stderr, "\n%04x:", i);             fprintf(stderr, " %02x", p->data[i]);         fprintf(stderr, "\n\n");         int i;         fprintf(stderr, ":");             if (!(i & 15))                 fprintf(stderr, "\n%04x:", i);             fprintf(stderr, " %02x", p->data[i]);         fprintf(stderr, "\n\n");     int ret = p->len;     fprintf(stderr, "usbnet: data out len %u\n", p->len);         int i;         fprintf(stderr, ":");         for (i = 0; i < p->len; i++) {             if (!(i & 15))                 fprintf(stderr, "\n%04x:", i);             fprintf(stderr, " %02x", p->data[i]);         fprintf(stderr, "\n\n");     memcpy(&s->out_buf[s->out_ptr], p->data, sz);
static int FUNC_0(USBNetState *VAR_0, USBPacket *VAR_1)

{

    int VAR_2 = VAR_1->len;

    int VAR_3 = sizeof(VAR_0->out_buf) - VAR_0->out_ptr;

    struct rndis_packet_msg_type *VAR_4 =

            (struct rndis_packet_msg_type *) VAR_0->out_buf;

    uint32_t len;



#ifdef TRAFFIC_DEBUG

    fprintf(stderr, "usbnet: data out len %u\n", VAR_1->len);

    {

        int i;

        fprintf(stderr, ":");

        for (i = 0; i < VAR_1->len; i++) {

            if (!(i & 15))

                fprintf(stderr, "\n%04x:", i);

            fprintf(stderr, " %02x", VAR_1->data[i]);

        }

        fprintf(stderr, "\n\n");

    }

#endif



    if (VAR_3 > VAR_2)

        VAR_3 = VAR_2;

    memcpy(&VAR_0->out_buf[VAR_0->out_ptr], VAR_1->data, VAR_3);

    VAR_0->out_ptr += VAR_3;



    if (!is_rndis(VAR_0)) {

        if (VAR_2 < 64) {

            qemu_send_packet(&VAR_0->nic->nc, VAR_0->out_buf, VAR_0->out_ptr);

            VAR_0->out_ptr = 0;

        }

        return VAR_2;

    }

    len = le32_to_cpu(VAR_4->MessageLength);

    if (VAR_0->out_ptr < 8 || VAR_0->out_ptr < len)

        return VAR_2;

    if (le32_to_cpu(VAR_4->MessageType) == RNDIS_PACKET_MSG) {

        uint32_t offs = 8 + le32_to_cpu(VAR_4->DataOffset);

        uint32_t size = le32_to_cpu(VAR_4->DataLength);

        if (offs + size <= len)

            qemu_send_packet(&VAR_0->nic->nc, VAR_0->out_buf + offs, size);

    }

    VAR_0->out_ptr -= len;

    memmove(VAR_0->out_buf, &VAR_0->out_buf[len], VAR_0->out_ptr);



    return VAR_2;

}

static int FUNC_0(USBNetState *VAR_0, USBPacket *VAR_1)
{ int VAR_2 = VAR_1->len; int VAR_3 = sizeof(VAR_0->out_buf) - VAR_0->out_ptr; struct rndis_packet_msg_type *VAR_4 =
(struct rndis_packet_msg_type *) VAR_0->out_buf; uint32_t len; #ifdef TRAFFIC_DEBUG
fprintf(stderr, "usbnet: data out len %u\n", VAR_1->len); { int i; fprintf(stderr, ":"); for (i = 0; i < VAR_1->len; i++) { if (!(i & 15))
fprintf(stderr, "\n%04x:", i); fprintf(stderr, " %02x", VAR_1->data[i]); } fprintf(stderr, "\n\n"); } #endif
if (VAR_3 > VAR_2)
VAR_3 = VAR_2; memcpy(&VAR_0->out_buf[VAR_0->out_ptr], VAR_1->data, VAR_3); VAR_0->out_ptr += VAR_3; if (!is_rndis(VAR_0)) { if (VAR_2 < 64) { qemu_send_packet(&VAR_0->nic->nc, VAR_0->out_buf, VAR_0->out_ptr); VAR_0->out_ptr = 0; } return VAR_2; } len = le32_to_cpu(VAR_4->MessageLength); if (VAR_0->out_ptr < 8 || VAR_0->out_ptr < len)
return VAR_2; if (le32_to_cpu(VAR_4->MessageType) == RNDIS_PACKET_MSG) { uint32_t offs = 8 + le32_to_cpu(VAR_4->DataOffset); uint32_t size = le32_to_cpu(VAR_4->DataLength); if (offs + size <= len)
qemu_send_packet(&VAR_0->nic->nc, VAR_0->out_buf + offs, size); } VAR_0->out_ptr -= len; memmove(VAR_0->out_buf, &VAR_0->out_buf[len], VAR_0->out_ptr); return VAR_2; }