diff options
| author | me_desk <me_desk@fb96df88-216d-11de-830c-f3023f12d8ac> | 2012-08-19 21:10:44 +0000 |
|---|---|---|
| committer | me_desk <me_desk@fb96df88-216d-11de-830c-f3023f12d8ac> | 2012-08-19 21:10:44 +0000 |
| commit | 45646fecc1af22471943422291a1a3e69f43e4e1 (patch) | |
| tree | c4042177742183c821a162d977d2824ba3cd4b51 | |
| parent | d1d557f2477439c7d3f81066123c51d6620be3d6 (diff) | |
| download | pica-pica-45646fecc1af22471943422291a1a3e69f43e4e1.tar.gz pica-pica-45646fecc1af22471943422291a1a3e69f43e4e1.zip | |
removed printf() and puts() debug output
git-svn-id: svn://localhost/project_picapica/trunk@173 fb96df88-216d-11de-830c-f3023f12d8ac
| -rwxr-xr-x | PICA_client.c | 60 | ||||
| -rwxr-xr-x | PICA_node.c | 75 |
2 files changed, 57 insertions, 78 deletions
diff --git a/PICA_client.c b/PICA_client.c index 8ac5f6b..e63dc2a 100755 --- a/PICA_client.c +++ b/PICA_client.c @@ -120,8 +120,8 @@ return 1; OPENSSL_free(DN_str); return 0; } - printf("my id is %u\n",*p_id);//debug - puts(DN_str);//debug + //printf("my id is %u\n",*p_id);//debug + //puts(DN_str);//debug OPENSSL_free(DN_str); return 1; @@ -195,7 +195,7 @@ if (mp) } else { - puts("callee CONNID");//debug + //puts("callee CONNID");//debug *(unsigned int*)(mp->tail) = chnl->peer_id;//вызвывающий *(unsigned int*)(mp->tail + 4) = chnl->conn->id;//вызываемый } @@ -218,7 +218,7 @@ chnl->ssl=SSL_new(chnl->conn->ctx); if (!chnl->ssl) { - puts("SSL_new !- 0");//debug + //puts("SSL_new !- 0");//debug err_ret=PICA_ERRSSL; goto error_ret; } @@ -227,7 +227,7 @@ ret=SSL_set_fd(chnl->ssl, chnl->sck_data); if (!ret) { - puts("SSL_set_fd returned 0");//debug + //puts("SSL_set_fd returned 0");//debug err_ret=PICA_ERRSSL; goto error_ret_; } @@ -239,12 +239,12 @@ ret=SSL_connect(chnl->ssl); else ret=SSL_accept(chnl->ssl); -printf("verify result:%i\n",(int)SSL_get_verify_result(chnl->ssl));//debug +//printf("verify result:%i\n",(int)SSL_get_verify_result(chnl->ssl));//debug if (ret!=1) { - printf("ret=%i of SSL_connect or accept\n",ret);//debug - printf("SSL_get_error says:%i\n",SSL_get_error(chnl->ssl,ret));//debug + //printf("ret=%i of SSL_connect or accept\n",ret);//debug + //printf("SSL_get_error says:%i\n",SSL_get_error(chnl->ssl,ret));//debug err_ret=PICA_ERRSSL; goto error_ret_; } @@ -263,7 +263,7 @@ DN_str=X509_NAME_oneline(X509_get_subject_name(chnl->peer_cert), 0, 0); if (!DN_str) { - puts("no DN_str");//debug + //puts("no DN_str");//debug err_ret=PICA_ERRSSL; goto error_ret_; } @@ -273,7 +273,7 @@ if (!get_id_fromsubjstr(DN_str,&tmp_uid) || tmp_uid!=chnl->peer_id) err_ret=PICA_ERRINVPEERCERT; goto error_ret_; } -puts(DN_str);//debug +//puts(DN_str);//debug OPENSSL_free(DN_str); @@ -391,7 +391,7 @@ static unsigned int procmsg_NOTFOUND(unsigned char* buf,unsigned int nb,void* p) struct PICA_conninfo *ci=(struct PICA_conninfo *)p; struct PICA_chaninfo *ipt,*rq=0; -puts("procmsg_NOTFOUND");//debug +//puts("procmsg_NOTFOUND");//debug ipt=ci->chan_list_end; while(ipt) @@ -407,10 +407,10 @@ while(ipt) if (!rq) return 0;// ERR_CHECK -левое сообщение, такой запрос не посылался -puts("procmsg_NOTFOUND_chkp0");//debug +//puts("procmsg_NOTFOUND_chkp0");//debug PICA_close_channel(rq); -puts("procmsg_NOTFOUND_chkp1");//debug +//puts("procmsg_NOTFOUND_chkp1");//debug callbacks.notfound_cb(*(unsigned int*)(buf+2)); return 1; @@ -453,7 +453,7 @@ char ipaddr_string[INET6_ADDRSTRLEN]; char temp_zeroswap; unsigned int port; -puts("CLNODELIST");//debug +//puts("CLNODELIST");//debug //callbacks.nodelist_cb(buf + 4, nb - 4); do @@ -504,7 +504,7 @@ do break; default: - puts("unknown node address type");//debug + //puts("unknown node address type");//debug return 0; } } @@ -700,7 +700,7 @@ if (ret!=1) ////<< ret=SSL_CTX_load_verify_locations(cid->ctx,CA_file,0/*"trustedCA/"*/); -printf("loadverifylocations ret=%i\n",ret);//debug +//printf("loadverifylocations ret=%i\n",ret);//debug SSL_CTX_set_client_CA_list(cid->ctx,SSL_load_client_CA_file(CA_file)); @@ -809,17 +809,17 @@ if (cid->init_resp_ok != 1) goto error_ret_5; } -printf("6\n");//debug +//printf("6\n");//debug ret=SSL_set_fd(cid->ssl_comm,cid->sck_comm); -printf("SSL_set_fd=%i\n",ret); +//printf("SSL_set_fd=%i\n",ret); ret=SSL_accept(cid->ssl_comm); if (ret!=1) { - printf("SSL_accept ret=%i\n SSL_get_error=%i\n",ret,SSL_get_error(cid->ssl_comm,ret));//debug + //printf("SSL_accept ret=%i\n SSL_get_error=%i\n",ret,SSL_get_error(cid->ssl_comm,ret));//debug //ERR_CHECK ret_err=PICA_ERRSSL; goto error_ret_5; @@ -1304,10 +1304,10 @@ void PICA_close_channel(struct PICA_chaninfo *chn) { struct PICA_chaninfo *ipt; -puts("PICA_close_channel");//debug +//puts("PICA_close_channel");//debug ipt=chn->conn->chan_list_head; -puts("PICA_close_channel_chkp0");//debug +//puts("PICA_close_channel_chkp0");//debug while(ipt) { if (ipt==chn) @@ -1327,7 +1327,7 @@ while(ipt) ipt=ipt->next; } -puts("PICA_close_channel_chkp1");//debug +//puts("PICA_close_channel_chkp1");//debug if (chn -> read_buf) free(chn -> read_buf); @@ -1338,25 +1338,25 @@ if (chn -> write_buf) if (chn->peer_cert) X509_free(chn->peer_cert); -puts("PICA_close_channel_chkp2");//debug +//puts("PICA_close_channel_chkp2");//debug if (chn->ssl) SSL_shutdown(chn->ssl); - puts("PICA_close_channel_chkp3");//debug + //puts("PICA_close_channel_chkp3");//debug if (chn->ssl) { - printf("3 SSL_free(%X)\n",chn->ssl);//debug + //printf("3 SSL_free(%X)\n",chn->ssl);//debug SSL_free(chn->ssl); } -puts("PICA_close_channel_chkp4");//debug +//puts("PICA_close_channel_chkp4");//debug SHUTDOWN(chn->sck_data); -puts("PICA_close_channel_chkp5");//debug +//puts("PICA_close_channel_chkp5");//debug CLOSE(chn->sck_data); -puts("PICA_close_channel_chkp6");//debug +//puts("PICA_close_channel_chkp6");//debug free(chn); -puts("PICA_close_channel_chkp7");//debug +//puts("PICA_close_channel_chkp7");//debug } void PICA_close_connection(struct PICA_conninfo *cid) @@ -1367,7 +1367,7 @@ while((ipt = cid->chan_list_head)) PICA_close_channel(ipt); SSL_shutdown(cid->ssl_comm); -printf("4 SSL_free(%X)\n",cid->ssl_comm);//debug +//printf("4 SSL_free(%X)\n",cid->ssl_comm);//debug SSL_free(cid->ssl_comm); SHUTDOWN(cid->sck_comm); CLOSE(cid->sck_comm); diff --git a/PICA_node.c b/PICA_node.c index d71d43f..5b39830 100755 --- a/PICA_node.c +++ b/PICA_node.c @@ -186,16 +186,13 @@ PICA_debug1("received CONNID"); caller_id=*((unsigned int*)(buf+2)); callee_id=*((unsigned int*)(buf+6)); -printf("CONNID: caller_id=%u callee_id=%u\n",caller_id,callee_id);//debug +PICA_debug1("CONNID: caller_id=%u callee_id=%u",caller_id,callee_id); link=cclink_list_search(caller_id,callee_id); if (!link) return 0; -puts("\ncclink found");//debug - -printf("link->state = %i\n", link->state);//debug if (link->state!=PICA_CCLINK_LOCAL_WAITCONNCLE && link->state!=PICA_CCLINK_LOCAL_WAITCONNCLR && link->state!=PICA_CCLINK_N2NCLR_WAITCONNCLR && link->state!=PICA_CCLINK_N2NCLE_WAITCONNCLE) @@ -213,7 +210,7 @@ else if (link->state==PICA_CCLINK_LOCAL_WAITCONNCLR || link->state==PICA_CCLINK_ if (nc->addr.sin_addr.s_addr!=c->addr.sin_addr.s_addr) { - puts("IP check failed");//debug + PICA_warn("CONNID: IP check failed. IP address of sender does not match IP in c2n connection"); return 0; } } @@ -226,7 +223,6 @@ if (link->state==PICA_CCLINK_LOCAL_WAITCONNCLE) } else { - puts("unable to send FOUND to caller");//debug cclink_list_delete(link); return 0; } @@ -241,7 +237,6 @@ if (link->state==PICA_CCLINK_N2NCLE_WAITCONNCLE) } else { - puts("unable to send N2NALLOW to caller node");//debug cclink_list_delete(link); return 0; } @@ -349,7 +344,6 @@ if (cclink_list_findwaitsearch(callee_id)/*search request for this id is already if ((mp = client_wbuf_push(i,PICA_PROTO_NOTFOUND,PICA_PROTO_NOTFOUND_SIZE))) { *((unsigned int*)mp->tail)=callee_id; - puts("sending NOTFOUND... put to senq q...");//debug } return 1; @@ -376,8 +370,7 @@ if (link->state!=PICA_CCLINK_LOCAL_WAITREP && return 0; cclink_setwaitconn(link); - -puts("procmsg_CONNALLOW - return 1");//debug + return 1; } @@ -462,7 +455,7 @@ PICA_debug1("received NEWNODE"); switch (buf[0]) { case PICA_PROTO_NEWNODE_IPV4: - printf("NEWNODE_IPV4: ip %.16s port %hu\n",inet_ntoa(*(struct in_addr*)(buf+2)),ntohs(*(uint16_t*)(buf+6)));//debug + PICA_debug1("NEWNODE_IPV4: ip %.16s port %hu\n",inet_ntoa(*(struct in_addr*)(buf+2)),ntohs(*(uint16_t*)(buf+6))); { struct PICA_nodeaddr_ipv4 na_ipv4; @@ -618,7 +611,7 @@ while(listleft) nlp=nodelink_list_addnew(&nc); send_newnode(nlp,my_addr); nodelink_attach_nodeaddr(nlp,na_ipv4.magick,&na_ipv4,sizeof(struct PICA_nodeaddr_ipv4)); - printf("LINKED NODE:%s\n",inet_ntoa(*(struct in_addr*)&na_ipv4.addr));//debug + PICA_debug1("LINKED NODE:%s\n",inet_ntoa(*(struct in_addr*)&na_ipv4.addr)); } na.port = ntohs(na_ipv4.port); @@ -930,8 +923,6 @@ struct cclink* cclink_list_add(struct client *clr,struct client *cle) { struct cclink *l; -puts("cclink_list_add");//debug - l=(struct cclink*)calloc(sizeof(struct cclink),1); if (!l) @@ -1070,7 +1061,6 @@ switch(ccl->state) return; } ccl->state = PICA_CCLINK_LOCAL_ACTIVE; - puts("caller cclink established");//debug break; case PICA_CCLINK_N2NCLR_WAITCONNCLR: ccl->sck_p1 = s; @@ -1203,7 +1193,7 @@ CLOSE(nc->sck); nc->sck=0; -nc->pos=0; printf("newconn_close: closing connection\n");//debug +nc->pos=0; } //функция ищет свободный элемент в массиве структур newconn и возвращает на него указатель @@ -1299,7 +1289,7 @@ struct client* client_tree_search(unsigned int id)//надо бы потести struct client* i_ptr; i_ptr=client_tree_root; -printf("client_tree_search: searching for %u...\n",id);//debug +PICA_debug1("client_tree_search: searching for %u...",id); while(i_ptr) { @@ -1312,7 +1302,7 @@ while(i_ptr) i_ptr=i_ptr->right; } -puts("client_tree_search- id not found");//debug +PICA_debug1("client_tree_search- id not found"); return 0; } @@ -1447,7 +1437,7 @@ else if (client_tree_search(ci->id) == ci) { client_tree_remove(ci); - client_tree_print(client_tree_root);//debug + client_tree_print(client_tree_root); } cclink_list_delete_by_client(ci); @@ -1565,13 +1555,11 @@ int nodelink_rbuf_grow(struct nodelink *nl) { unsigned char *p; -puts(__FUNCTION__);//debug - p=realloc(nl->r_buf,nl->buflen_r + DEFAULT_BUF_SIZE); if (!p) { - puts("out of memory");//debug + PICA_error("realloc() failed"); return 0; } nl->r_buf = p; @@ -1590,7 +1578,7 @@ if (!nl->w_buf) nl->w_buf=calloc(1,DEFAULT_BUF_SIZE ); if (!nl->w_buf) { - puts("out of memory");//debug + PICA_error("calloc() failed. Out of memory"); return 0; } nl->buflen_w=DEFAULT_BUF_SIZE; @@ -1636,13 +1624,11 @@ for (i=0;i<MAX_NEWCONNS;i++) if (t-newconns[i].tmst>NEWCONN_TIMEOUT) { newconn_close(newconns+i); - puts("closing by timeout(1): ");//debug } } else if ( newconns[i].tmst-t>NEWCONN_TIMEOUT) { newconn_close(newconns+i); - puts("closing by timeout(2): ");//debug } } } @@ -1672,7 +1658,6 @@ while(il) dl=il; il=il->next; cclink_list_delete(dl); - puts("inactive cclink closed by timeout");//debug continue; } } @@ -1694,8 +1679,6 @@ FD_SET(s,readfds); if (s > *nfds) *nfds=s; - -//printf("set_select_fd([socket %i ])\n",s);//debug } void listen_set_fds(fd_set *readfds,int *nfds) @@ -1762,7 +1745,6 @@ struct sockaddr_in addr; int addrsize = sizeof(struct sockaddr_in); if (FD_ISSET(listen_comm_sck,readfds)) { - puts("accept");//debug s = accept(listen_comm_sck,(struct sockaddr*)&addr,&addrsize); if (s >= 0) @@ -1771,12 +1753,11 @@ if (FD_ISSET(listen_comm_sck,readfds)) nc->sck = s; nc->addr = addr; - printf("accepted connection\n");//debug + PICA_info("accepted connection"); } else { perror("accept:");//debug - printf("accept error!\n");//debug //ERR_CHECK } } @@ -1795,7 +1776,7 @@ for (i=0;i<MAX_NEWCONNS;i++) if (ret<=0) { - perror("process_newconn_read - recv:");//debug + //perror("process_newconn_read - recv:");//debug newconn_close(newconns+i); continue; } @@ -1803,7 +1784,7 @@ for (i=0;i<MAX_NEWCONNS;i++) if(!PICA_processdatastream(newconns[i].buf,&(newconns[i].pos),newconns+i /*arg*/,_msginfo_newconn, MSGINFO_MSGSNUM(_msginfo_newconn) )) { - puts("processdatastream error\n");//debug + //puts("processdatastream error\n");//debug newconn_close(newconns+i); } //FD_CLR(newconns[i].sck,readfds); @@ -1880,7 +1861,7 @@ while(cc) && FD_ISSET(cc->sck_p1,readfds) && !cc->jam_p1p2 ) { ret=recv(cc->sck_p1,cc->buf_p1p2 + cc->bufpos_p1p2,cc->buflen_p1p2 - cc->bufpos_p1p2,0); - printf("DATA recv p1p2: ret=%i\n",ret);//debug + PICA_debug3("process_c2c_read: recv p1p2: ret=%i",ret); if (ret>0) { cc->bufpos_p1p2+=ret; @@ -1893,7 +1874,7 @@ while(cc) && FD_ISSET(cc->sck_p2,readfds) && !cc->jam_p2p1 ) { ret=recv(cc->sck_p2,cc->buf_p2p1 + cc->bufpos_p2p1,cc->buflen_p2p1 - cc->bufpos_p2p1,0); - printf("DATA recv p2p1: ret=%i\n",ret);//debug + PICA_debug3("process_c2c_read: recv p2p1: ret=%i\n",ret); if (ret>0) { cc->bufpos_p2p1+=ret; @@ -1950,7 +1931,7 @@ while(nl) if (kill_ptr) { - nodelink_list_delete(kill_ptr);puts("process_n2n_read - calling nodelink_list_delete");//debug + nodelink_list_delete(kill_ptr); kill_ptr=0; } } @@ -1978,7 +1959,7 @@ while(i_ptr) ret=SSL_write(i_ptr->ssl_comm,i_ptr->w_buf,i_ptr->btw_ssl); - printf("process_comm: write: ret of SSL_write=%i\n",ret);//debug + PICA_debug3("process_c2n_write: ret of SSL_write()=%i",ret); if (ret==i_ptr->btw_ssl) { @@ -1998,7 +1979,6 @@ while(i_ptr) break; case PICA_CLSTATE_SENDINGRESP: ret=send(i_ptr->sck_comm,i_ptr->w_buf,i_ptr->w_pos,0); - printf("process_comm: write: sendingresp w_pos=%u ret=%i\n",i_ptr->w_pos,ret);//debug if (!ret) kill_ptr=i_ptr; @@ -2014,13 +1994,12 @@ while(i_ptr) if (!i_ptr->w_pos) i_ptr->state=PICA_CLSTATE_TLSNEGOTIATION; - puts("SENDINGRESP");//debug break; case PICA_CLSTATE_TLSNEGOTIATION: i_ptr->w_pos=0; ret=SSL_connect(i_ptr->ssl_comm); - printf("wr SSL_connect=%i\n",ret);//debug + PICA_debug3("process_c2n_write: SSL_connect()=%i",ret); if (!ret) kill_ptr=i_ptr; @@ -2033,13 +2012,13 @@ while(i_ptr) { case SSL_ERROR_WANT_WRITE: i_ptr->w_pos=1; - printf("wr WANT_WRITE\n");//debug + PICA_debug3("SSL_ERROR_WANT_WRITE"); break; case SSL_ERROR_WANT_READ: - printf("wr WANT_READ\n");//debug + PICA_debug3("SSL_ERROR_WANT_READ"); break; default: - printf("wr SSL_get_error=%i",eret);//debug + PICA_debug3("SSL_get_error() = %i", eret); kill_ptr=i_ptr; } } @@ -2070,7 +2049,7 @@ while(i_ptr) PICA_error("Unable to get client id from certificate, or certificate is invalid"); kill_ptr=i_ptr; } - printf("user id=%u\n",i_ptr->id);//debug + PICA_debug2("user id=%u",i_ptr->id); #warning "see comments below" //сделать проверку названия сети!!!!---------------------------<<<<<<<<<<<<<<<<<<<<<< @@ -2082,7 +2061,7 @@ while(i_ptr) else { ret=client_tree_add(i_ptr); - client_tree_print(client_tree_root);//debug + client_tree_print(client_tree_root); } if (!ret) { @@ -2138,7 +2117,7 @@ while(cc) else ret=send(cc->sck_p2,cc->buf_p1p2,cc->bufpos_p1p2,MSG_NOSIGNAL); - printf("DATA send p1p2: ret=%i\n",ret);//debug + PICA_debug3("process_c2c_write: send p1p2: ret=%i",ret); if (ret>0) { if (ret < cc->bufpos_p1p2) @@ -2196,7 +2175,7 @@ while(cc) else ret=send(cc->sck_p1,cc->buf_p2p1,cc->bufpos_p2p1,MSG_NOSIGNAL); - printf("DATA send p2p1: ret=%i\n",ret);//debug + PICA_debug3("process_c2c_write: send p2p1: ret=%i",ret); if (ret>0) { if (ret < cc->bufpos_p2p1) @@ -2283,7 +2262,7 @@ while(nl) if (kill_ptr) { - nodelink_list_delete(kill_ptr);puts("process_n2n_write - calling nodelink_list_delete");//debug + nodelink_list_delete(kill_ptr); kill_ptr=0; } } |
