Changeset 5052 for trunk/module-cccam.c
- Timestamp:
- 04/19/11 22:49:43 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/module-cccam.c
r5045 r5052 1711 1711 } 1712 1712 1713 static void chk_peer_node_for_oscam(struct cc_data *cc) 1714 { 1715 if (!cc->is_oscam_cccam) {//Allready discovered oscam-cccam: 1716 uint16_t sum = 0x1234; 1717 uint16_t recv_sum = (cc->peer_node_id[6] << 8) 1718 | cc->peer_node_id[7]; 1719 int32_t i; 1720 for (i = 0; i < 6; i++) { 1721 sum += cc->peer_node_id[i]; 1722 } 1723 //Create special data to detect oscam-cccam: 1724 cc->is_oscam_cccam = sum == recv_sum; 1725 } 1726 } 1727 1713 1728 int32_t cc_parse_msg(struct s_client *cl, uint8_t *buf, int32_t l) { 1714 1729 struct s_reader *rdr = (cl->typ == 'c') ? NULL : cl->reader; … … 1756 1771 cc->peer_node_id, 8), cc->remote_version, cc->remote_build); 1757 1772 1758 if (!cc->is_oscam_cccam) {//Allready discovered oscam-cccam: 1759 uint16_t sum = 0x1234; 1760 uint16_t recv_sum = (cc->peer_node_id[6] << 8) 1761 | cc->peer_node_id[7]; 1762 int32_t i; 1763 for (i = 0; i < 6; i++) { 1764 sum += cc->peer_node_id[i]; 1765 } 1766 //Create special data to detect oscam-cccam: 1767 cc->is_oscam_cccam = sum == recv_sum; 1768 } 1773 chk_peer_node_for_oscam(cc); 1769 1774 //Trick: when discovered partner is an Oscam Client, then we send him our version string: 1770 1775 if (cc->is_oscam_cccam) { … … 2553 2558 2554 2559 //This wakeups the reader: 2555 uchar dummy ;2560 uchar dummy = 0; 2556 2561 write_to_pipe(rdr->fd, PIP_ID_CIN, &dummy, sizeof(dummy)); 2557 2562 wakeup++; … … 2574 2579 int32_t cc_srv_connect(struct s_client *cl) { 2575 2580 int32_t i, wait_for_keepalive; 2576 uint32_t cmi;2577 2581 uint8_t buf[CC_MAXMSGSIZE]; 2578 2582 uint8_t data[16]; … … 2709 2713 2710 2714 2711 if (!cc->prefix) 2715 if (!cc->prefix) { 2712 2716 cc->prefix = cs_malloc(&cc->prefix, strlen(cl->account->usr)+20, QUITERROR); 2713 snprintf(cc->prefix, strlen(cl->account->usr)+20, "cccam(s) %s: ", cl->account->usr); 2717 snprintf(cc->prefix, strlen(cl->account->usr)+20, "cccam(s) %s: ", cl->account->usr); 2718 } 2714 2719 2715 2720 … … 2731 2736 cs_ddump_mask(D_CLIENT, buf, i, "cccam: cli data:"); 2732 2737 memcpy(cc->peer_node_id, buf + 24, 8); 2738 chk_peer_node_for_oscam(cc); 2733 2739 2734 2740 strncpy(cc->remote_version, (char*)buf+33, sizeof(cc->remote_version)-1); … … 2750 2756 //Wait for Partner detection (NOK1 with data) before reporting cards 2751 2757 //When Partner is detected, cccam220=1 is set. then we can report extended card data 2752 i = process_input(mbuf, sizeof(mbuf), 1); 2753 if (i<=0 && i != -9) 2754 return 0; //disconnected 2758 if (cc->is_oscam_cccam) { 2759 i = process_input(mbuf, sizeof(mbuf), 1); 2760 if (i<=0 && i != -9) 2761 return 0; //disconnected 2762 } 2763 2755 2764 if (cc->cccam220) 2756 2765 cs_debug_mask(D_CLIENT, "%s extended sid mode activated", getprefix()); … … 2762 2771 cs_ftime(&cc->ecm_time); 2763 2772 2764 cmi = 0;2773 time_t timeout = time(NULL); 2765 2774 wait_for_keepalive = 100; 2766 2775 cc->mode = CCCAM_MODE_NORMAL; … … 2770 2779 { 2771 2780 i = process_input(mbuf, sizeof(mbuf), 10); 2772 if (i == -9) { //timeout 10s 2773 cmi+=10; 2774 if (cmi >= cfg.cmaxidle) { 2775 //cs_debug_mask(D_TRACE, "client timeout user %s idle=%d client max idle=%d", usr, cmi, cfg.cmaxidle); 2776 if (cfg.cc_keep_connected || cl->account->ncd_keepalive) { 2777 if (cc_cmd_send(cl, NULL, 0, MSG_KEEPALIVE) < 0) 2778 break; 2779 if (wait_for_keepalive<3 || wait_for_keepalive == 100) { 2780 cs_debug_mask(D_CLIENT, "cccam: keepalive"); 2781 cc->answer_on_keepalive = time(NULL); 2782 wait_for_keepalive++; 2783 } 2784 else if (wait_for_keepalive<100) break; 2785 cmi = 0; 2786 } else { 2787 cs_debug_mask(D_CLIENT, "%s keepalive after maxidle is reached", 2788 getprefix()); 2789 break; //Disconnect client 2781 if (i <= 0 && i != -9) 2782 break; //Disconnected by client 2783 2784 //data is parsed! 2785 if (i == MSG_CW_ECM) 2786 timeout = time(NULL); 2787 else if (i == MSG_KEEPALIVE) { 2788 wait_for_keepalive = 0; 2789 timeout = time(NULL); 2790 } 2791 2792 //new timeout check: 2793 if (time(NULL)-timeout > (time_t)cfg.cmaxidle) { 2794 //cs_debug_mask(D_TRACE, "client timeout user %s idle=%d client max idle=%d", usr, cmi, cfg.cmaxidle); 2795 if (cfg.cc_keep_connected || cl->account->ncd_keepalive) { 2796 if (cc_cmd_send(cl, NULL, 0, MSG_KEEPALIVE) < 0) 2797 break; 2798 if (wait_for_keepalive<3 || wait_for_keepalive == 100) { 2799 cs_debug_mask(D_CLIENT, "cccam: keepalive"); 2800 cc->answer_on_keepalive = time(NULL); 2801 wait_for_keepalive++; 2790 2802 } 2791 } 2792 2793 } else if (i <= 0) 2794 break; //Disconnected by client 2795 else { //data is parsed! 2796 if (i == MSG_CW_ECM) 2797 cmi = 0; 2798 else if (i == MSG_KEEPALIVE) { 2799 wait_for_keepalive = 0; 2800 cmi = 0; 2803 else if (wait_for_keepalive<100) break; 2804 timeout = time(NULL); 2805 } else { 2806 cs_debug_mask(D_CLIENT, "%s keepalive after maxidle is reached", 2807 getprefix()); 2808 break; //Disconnect client 2801 2809 } 2802 2810 }
Note:
See TracChangeset
for help on using the changeset viewer.