Changeset 10303
- Timestamp:
- 01/24/15 23:00:07 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/module-gbox.c
r10295 r10303 474 474 static int8_t gbox_reinit_peer(struct gbox_peer *peer) 475 475 { 476 NULLFREE(peer->hostname); 476 477 peer->online = 0; 477 478 peer->ecm_idx = 0; … … 671 672 672 673 if(!(gbox_decode_cmd(data) == MSG_HELLO1)) 673 { 674 gbox_decompress(data, &payload_len); 675 } 674 { gbox_decompress(data, &payload_len); } 676 675 cs_log_dump_dbg(D_READER, data, payload_len, "decompressed data (%d bytes):", payload_len); 677 676 if ((data[11] & 0xf) != peer->next_hello) … … 684 683 return 0; 685 684 } 686 if ( (data[11] & 0xf) == 0) //is first packet685 if (!(data[11] & 0xf)) //is first packet 687 686 { 688 687 if(!peer->gbox.cards) … … 692 691 hostname_len = data[payload_len - 1]; 693 692 footer_len = hostname_len + 2; 693 if(!peer->hostname || memcmp(peer->hostname, data + payload_len - 1 - hostname_len, hostname_len)) 694 { 695 NULLFREE(peer->hostname); 696 if(!cs_malloc(&peer->hostname, hostname_len + 1)) 697 { 698 cs_writeunlock(&peer->lock); 699 return -1; 700 } 701 memcpy(peer->hostname, data + payload_len - 1 - hostname_len, hostname_len); 702 peer->hostname[hostname_len] = '\0'; 703 } 704 gbox_checkcode_recv(cli, data + payload_len - footer_len - checkcode_len - 1); 705 peer->gbox.minor_version = data[payload_len - footer_len - 1]; 706 peer->gbox.cpu_api = data[payload_len - footer_len]; 694 707 } 695 708 else … … 791 804 } // end while caid/provid 792 805 793 if(!(data[11] & 0xF)) // first packet. We've got peer hostname794 {795 NULLFREE(peer->hostname);796 if(!cs_malloc(&peer->hostname, hostname_len + 1))797 {798 cs_writeunlock(&peer->lock);799 return -1;800 }801 memcpy(peer->hostname, data + payload_len - 1 - hostname_len, hostname_len);802 peer->hostname[hostname_len] = '\0';803 804 gbox_checkcode_recv(cli, data + payload_len - footer_len - checkcode_len - 1);805 peer->gbox.minor_version = data[payload_len - footer_len - 1];806 peer->gbox.cpu_api = data[payload_len - footer_len];807 } // end if first hello packet808 809 806 if(data[11] & 0x80) //last packet 810 807 {
Note:
See TracChangeset
for help on using the changeset viewer.