![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Modularizando o src
Dependencies: EALib EthernetInterface_vz mbed-rtos mbed
Fork of header_main_colinas_V0-20-09-14 by
Diff: sip.cpp
- Revision:
- 100:09a23fcd3bdf
- Parent:
- 99:e80850c51106
- Child:
- 104:62646ef786a3
--- a/sip.cpp Mon Jan 19 18:00:42 2015 +0000 +++ b/sip.cpp Thu Feb 12 16:42:35 2015 +0000 @@ -2,10 +2,8 @@ void Sip::__init_sock__( void ){ sip_server.set_address( this->server_ip , this->server_port ); - //sock.set_blocking( false, 5 ); // verificar isso com mais cuidado depois sock.set_blocking( false, 0 ); sock.bind( this->my_port ); - //sock.init(); } void Sip::__end_sock__( void ){ @@ -169,35 +167,17 @@ } int Sip::registry(){ - if( debug_sip ) debug_msg("Registry %d", this->my_ext ); build_registry_package( buffer ); int sent = sock.sendTo( sip_server, buffer, strlen( buffer ) ); // > 400 - if( debug_sip ) debug_msg("Sent %i of %i bytes to ext %d -- port %d", sent, strlen( buffer ), my_ext, my_port ); + if( debug_sip ) send_msg("Registry ( %d, %d ) - Sent %i of %i bytes", this->my_ext, this->my_port , sent, strlen( buffer ) ); if( sent != strlen( buffer ) ){ sip_socket_send_failure++; } return( sent ); - - /* - if( decode_gettag( (unsigned char *)buffer, "cseq: ", out ) ){ - if(strlen( out ) > 7){ - if(strcasecmp("options",out+strlen(out)-7) == 0){ - // esse teste nao esta mais em uso, uma vez que na - // configuracao atual do asterisk nao existe - // mais o envio desse pacote - char ans[ 2000 ]; - build_reply_package( ans, (unsigned char*)buffer ); - //sock.sendTo( sip_server, ans, sizeof( 512 ) ); - sock.sendTo( sip_server, ans, strlen( ans ) ); - if( debug_sip ) send_msg( "sizeof( Registry reply pkg ) :: %d", strlen( ans ) ); - } - } - } - */ } VZ_call * Sip::invite(){ @@ -281,7 +261,6 @@ strcat( buffer, ":" ); itoa( my_port, itoa_buffer, 10 ); strcat( buffer, itoa_buffer ); - if( debug_sip ) debug_msg("Fixado na porta %s-", itoa_buffer ); strcat( buffer, ";branch=" ); strcat( buffer, branch ); strcat( buffer, "\r\nFrom: " ); @@ -442,7 +421,7 @@ strcat( header, SIP_ALLOW ); strcat( header, "\r\n" ); strcat( header, "Content-Type: application/sdp\r\n" ); - header[ SIP_MAXMSGSIZE - 1 ] = 0; + //header[ SIP_MAXMSGSIZE - 1 ] = 0; strcpy( body, "v=0\r\n" ); strcat( body, "o=- " ); @@ -507,7 +486,7 @@ strcat( body, "-" ); itoa( 11, itoa_buffer, 10 ); strcat( body, itoa_buffer ); - body[ SIP_MAXMSGSIZE - 1 ] = 0; + //body[ SIP_MAXMSGSIZE - 1 ] = 0; make_content_length( header, body, pkg ); return( pkg ); @@ -836,10 +815,11 @@ srand( seed ); int i; - for (i=0; i<size; i++) { + for( i = 0; i < size - 1; i++ ) { buffer[ i ] = fill_random_aux[ rand() & 0x3f ]; } - buffer[ size ] = 0; + + buffer[ size - 1 ] = 0; return( buffer ); }