Changeset 11702


Ignore:
Timestamp:
10/17/21 00:15:03 (7 weeks ago)
Author:
nautilus7
Message:

[gbox] whitespace cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/module-gbox.c

    r11696 r11702  
    357357        return -1;
    358358    }
    359    
     359
    360360    remove_peer_crd_file(proxy);
    361361    proxy->reader->tcp_connected = 0;
     
    366366}
    367367
    368 //gbox.net doesn't accept slots >18 
    369 static uint8_t calc_slot(uint8_t slot) 
     368//gbox.net doesn't accept slots >18
     369static uint8_t calc_slot(uint8_t slot)
    370370{
    371371    int8_t i;
    372372    uint8_t cslot = slot;
    373    
     373
    374374    for(i=0 ; i < 9 ; i++)
    375375    {
     
    408408                        { continue; }
    409409                    else
    410                     { 
     410                    {
    411411                        if(chk_ident_filter(gbox_get_caid(card->caprovid), gbox_get_provid(card->caprovid), &proxy->reader->ccc_gbx_reshare_ident))
    412412                        {
     
    424424                    }
    425425                    else
    426                     { 
     426                    {
    427427                        continue;
    428428                    }
     
    438438    }
    439439    return nbcards;
    440 } 
     440}
    441441
    442442void gbox_send(struct s_client *cli, uint8_t *buf, int32_t l)
     
    562562            snprintf(buff, sizeof(buff),"cards_to_%.24s", proxy->reader->label);
    563563            char *fname = get_gbox_tmp_fname(buff);
    564            
     564
    565565            FILE *fhandle = fopen(fname, "w");
    566566            if(!fhandle)
     
    595595                    *(++ptr) = ((card->lvl - 1) << 4) + card->dist + 1;
    596596
    597                         fprintf(fhandle, "#%03d Peer Crd to %04X - crd %08X - level %d - dist %d - slot %02d - crd owner %04X\n", ++sendcrds, peer->gbox.id, card->caprovid, card->lvl -1, card->dist + 1, calc_slot(card->id.slot), card->id.peer); 
     597                        fprintf(fhandle, "#%03d Peer Crd to %04X - crd %08X - level %d - dist %d - slot %02d - crd owner %04X\n", ++sendcrds, peer->gbox.id, card->caprovid, card->lvl -1, card->dist + 1, calc_slot(card->id.slot), card->id.peer);
    598598                }
    599599                else if(card->type == GBOX_CARD_TYPE_CCCAM)
     
    602602                        { continue; }
    603603                    else
    604                     { 
     604                    {
    605605                        if(chk_ident_filter(gbox_get_caid(card->caprovid), gbox_get_provid(card->caprovid), &proxy->reader->ccc_gbx_reshare_ident))
    606606                        {
     
    618618                        *(++ptr) = ((proxy->reader->gbox_cccam_reshare) << 4) + card->dist + 1;
    619619
    620                             fprintf(fhandle, "#%03d CCCM crd to %04X - crd %08X - level %d - dist %d - slot %02d - crd owner %04X\n", ++sendcrds, peer->gbox.id, card->caprovid, proxy->reader->gbox_cccam_reshare, card->dist + 1, calc_slot(card->id.slot), card->id.peer); 
     620                            fprintf(fhandle, "#%03d CCCM crd to %04X - crd %08X - level %d - dist %d - slot %02d - crd owner %04X\n", ++sendcrds, peer->gbox.id, card->caprovid, proxy->reader->gbox_cccam_reshare, card->dist + 1, calc_slot(card->id.slot), card->id.peer);
    621621                        }
    622622                        else
     
    637637                    *(++ptr) = ((proxy->reader->gbox_reshare - 1) << 4) + card->dist + 1;
    638638
    639                         fprintf(fhandle, "#%03d Locl Crd to %04X - crd %08X - level %d - dist %d - slot %02d - crd owner %04X\n", ++sendcrds, peer->gbox.id, card->caprovid, proxy->reader->gbox_reshare - 1, card->dist + 1, calc_slot(card->id.slot), card->id.peer); 
     639                        fprintf(fhandle, "#%03d Locl Crd to %04X - crd %08X - level %d - dist %d - slot %02d - crd owner %04X\n", ++sendcrds, peer->gbox.id, card->caprovid, proxy->reader->gbox_reshare - 1, card->dist + 1, calc_slot(card->id.slot), card->id.peer);
    640640                    }
    641641                    else
     
    676676        fclose(fhandle);
    677677    } // end if > HelloL
    678     else 
     678    else
    679679        {
    680680            GBOX_CARDS_ITER *gci = gbox_cards_iter_create();
     
    892892    {
    893893        if (updcrc)
    894             { 
     894            {
    895895                cs_log_dump_dbg(D_READER, peer->checkcode, 7, "-> old checkcode from %04X %s:", peer->gbox.id, cli->reader->label);
    896896                cs_log_dump_dbg(D_READER, checkcode, 7, "-> new checkcode from %04X %s:", peer->gbox.id, cli->reader->label);
    897                 memcpy(peer->checkcode, checkcode, 7); 
     897                memcpy(peer->checkcode, checkcode, 7);
    898898            }
    899899        return 1;
     
    986986        if(peer->hostname && memcmp(peer->hostname, data + payload_len - 1 - hostname_len, hostname_len))
    987987            {
    988                 cs_log("WARNING - Received Hello from Peer %04X - hostname in cfg is different to received hostname", peer->gbox.id); 
     988                cs_log("WARNING - Received Hello from Peer %04X - hostname in cfg is different to received hostname", peer->gbox.id);
    989989            }
    990990
     
    10021002        diffcheck=gbox_checkcode_recvd(cli, data + payload_len - footer_len - 1, 1);
    10031003            if(diffcheck)
    1004                 { 
     1004                {
    10051005                    peer->crd_crc_change = 1;
    1006                     cs_log_dbg(D_READER,"-> first packet of hello from %04X - diffcheck=1 -> peer-card changed", peer->gbox.id); 
     1006                    cs_log_dbg(D_READER,"-> first packet of hello from %04X - diffcheck=1 -> peer-card changed", peer->gbox.id);
    10071007                }
    10081008        peer->gbox.minor_version = data[payload_len - footer_len - 1 + 7];
     
    10171017        { return -1; }
    10181018    else
    1019         { 
    1020             peer->total_cards += cards_number; 
     1019        {
     1020            peer->total_cards += cards_number;
    10211021            cs_log_dbg(D_READER,"-> Hello packet no. %d received - %d unfiltered card(s) - from %s %s", (data[11] & 0xF) + 1, cards_number, username(cli), cli->reader->device);
    10221022        }
     
    10521052                {
    10531053                    if(peer->crd_crc_change)
    1054                         { 
     1054                        {
    10551055                            peer->crd_crc_change = 0;
    10561056                            cs_log_dbg(D_READER,"-> last packet of HelloS from %04X, peer-card changed -> write shared cards.info", peer->gbox.id);
     
    10831083            {
    10841084                if(peer->crd_crc_change)
    1085                     { 
     1085                    {
    10861086                        peer->crd_crc_change = 0;
    10871087                        cs_log_dbg(D_READER,"-> last packet of HelloR from %04X, peer-card changed -> write shared cards.info", peer->gbox.id);
     
    13041304    }
    13051305
    1306     memcpy(er->ecm, data + 18, er->ecmlen); 
     1306    memcpy(er->ecm, data + 18, er->ecmlen);
    13071307
    13081308    er->gbox_ecm_src_peer = b2i(2, ecm + er->ecmlen); //boxid which ORIGINALLY broadcasted the ECM
     
    13101310    ere->gbox_rev = ecm[er->ecmlen + 3];
    13111311    ere->gbox_type = ecm[er->ecmlen + 4];
    1312     uint32_t caprovid = b2i(4, ecm + er->ecmlen + 5); 
     1312    uint32_t caprovid = b2i(4, ecm + er->ecmlen + 5);
    13131313    er->gbox_cw_src_peer = b2i(2, ecm + er->ecmlen + 10); //boxid to send ECM to (cw source peer)
    13141314    ere->gbox_slot = ecm[er->ecmlen + 12];
     
    13161316    er->gbox_crc = gbox_get_checksum(&er->ecm[0], er->ecmlen);
    13171317    er->gbox_ecm_dist = data[n - 15] + 1;
    1318    
     1318
    13191319    memcpy(&ere->gbox_routing_info[0], &data[n - 15 - er->gbox_ecm_dist + 1], er->gbox_ecm_dist - 1);
    1320    
     1320
    13211321    er->caid = gbox_get_caid(caprovid);
    13221322    er->prid = gbox_get_provid(caprovid);
     
    14791479            {
    14801480                gbox_send_hello(cl, GBOX_STAT_HELLOS);
    1481                 cl->last = time((time_t *)0); 
     1481                cl->last = time((time_t *)0);
    14821482            }
    14831483        }
     
    15021502        case MSG_HERE:
    15031503            cs_log_dbg(D_READER,"-> HERE? from %s %s - check reader port: %d might be wrong", username(proxy), proxy->reader->device, proxy->reader->r_port);
    1504             // todo: what to reply?? 
     1504            // todo: what to reply??
    15051505            break;
    15061506
     
    15521552        case MSG_CHECKCODE:
    15531553            diffcheck = gbox_checkcode_recvd(proxy, data + 10, 0);
    1554            
     1554
    15551555            if (cfg.log_hello)
    15561556            {
     
    15611561                cs_log_dbg(D_READER,"-> HelloC checkcode from %s - %s %s", username(proxy), proxy->reader->device, diffcheck ? "- crc diff":"");
    15621562            }
    1563            
     1563
    15641564            if(diffcheck)
    1565                 { 
     1565                {
    15661566                    gbox_write_share_cards_info(); //need that for gbox.net peer @ local crd change
    15671567                    cs_log_dbg(D_READER,"peer %s - %s checkcode changed", username(proxy), proxy->reader->device);
     
    16681668                gbox_add_card(local_gbox.id, gbox_get_caprovid(cl->reader->caid, 0), slot, DEFAULT_GBOX_RESHARE, 0, GBOX_CARD_TYPE_LOCAL, NULL);
    16691669                if(chk_is_betatunnel_caid(cl->reader->caid) == 1) // 1702 1722
    1670                     { 
     1670                    {
    16711671                        if(add_betatunnel_card(cl->reader->caid, gbox_next_free_slot(local_gbox.id)))
    1672                             { crdnb++; } 
     1672                            { crdnb++; }
    16731673                    }
    16741674            }
     
    17061706
    17071707                if(slot % 18 == 0)
    1708                     { 
     1708                    {
    17091709                        //offset++;
    17101710                        offset += (rand() % 18) +1;
     
    17371737            { cs_log("Local gbox cards initialized - cards: %d - filtered cccards: %d", crdnb - cccrdnb, cccrdnb); }
    17381738            else
    1739             { cs_log("Local gbox cards initialized - cards: %d", crdnb); } 
     1739            { cs_log("Local gbox cards initialized - cards: %d", crdnb); }
    17401740        }
    17411741    return (cccrdnb << 16) | (crdnb - cccrdnb);
     
    17811781        case MSG_GSMS:
    17821782        case MSG_GSMS_ACK:
    1783         case MSG_CW:   
     1783        case MSG_CW:
    17841784        case MSG_CHECKCODE:
    17851785        case MSG_ECM:
     
    20082008
    20092009    if(er->rc == E_NOTFOUND && cli->reader->gbox_force_remm && ere->gbox_rev >> 4)
    2010     { 
     2010    {
    20112011        gbox_send_remm_req(cli, er);
    20122012        return;
     
    20662066    // This copies the routing info from ECM to cw answer.
    20672067    memcpy(&buf[44], &ere->gbox_routing_info, er->gbox_ecm_dist - 1);
    2068     buf[44 + er->gbox_ecm_dist - 1] = er->gbox_ecm_dist - 1;    //act. dist 
     2068    buf[44 + er->gbox_ecm_dist - 1] = er->gbox_ecm_dist - 1;    //act. dist
    20692069/*
    20702070  uint8_t i;
    20712071        for(i = 0; i < er->gbox_ecm_dist; i++)
    2072         { 
     2072        {
    20732073            buf[44 +i] = i;
    20742074        }
     
    20812081    */
    20822082
    2083     if(ere->gbox_rev >> 4) 
     2083    if(ere->gbox_rev >> 4)
    20842084        { gbox_send_remm_req(cli, er); }
    20852085
     
    21312131    uint8_t send_buf[1024];
    21322132    int32_t buflen, len1;
    2133    
     2133
    21342134    len1 = er->ecmlen + 18; // length till end of ECM
    21352135
     
    21942194        uint8_t i;
    21952195        for(i = 0; i < er->gbox_ecm_dist + 1; i++)
    2196             { 
     2196            {
    21972197                send_buf[buflen] = i;
    21982198                buflen++;
     
    22292229            cs_log_dbg(D_READER, "Pending Card ID: %04X Slot: %02X time: %d", pending->id.peer, pending->id.slot, pending->pending_time);
    22302230            er->gbox_cw_src_peer = pending->id.peer;
    2231             cs_log_dbg(D_READER,"<- ECM (<-%d) - caid: %04X prov: %06X sid: %04X to cw-src-peer: %04X - ecm_src_peer: %04X", 
     2231            cs_log_dbg(D_READER,"<- ECM (<-%d) - caid: %04X prov: %06X sid: %04X to cw-src-peer: %04X - ecm_src_peer: %04X",
    22322232                gbox_get_crd_dist_lev(er->gbox_cw_src_peer) & 0xf, er->caid, er->prid, er->srvid, er->gbox_cw_src_peer, er->gbox_ecm_src_peer);
    22332233        }
     
    24432443{
    24442444    if(k > 8) //10s
    2445     {   
     2445    {
    24462446        struct s_client *cl;
    24472447        cs_readlock(__func__, &clientlist_lock);
     
    26732673
    26742674        startup++;
    2675        
     2675
    26762676        if(startup < GBOX_START_TIME)
    26772677            {
Note: See TracChangeset for help on using the changeset viewer.