Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem Capturing SIP Header

Status
Not open for further replies.

guillermoandres

Programmer
Jul 23, 2007
8
VE
Hi!. Right now I'm developing a simple SIP sniffer. I'm having problems capturing the SIP header. I'm using a socket to read from the NIC (fill a buffer). Then I use a pointer and these two fuctions to read from the receive buffer.

int captar_linea(char *sip_line)
{
u_int8_t count;
while(1)
{
if(*sip_line != 0x0d && *(sip_line+1) != 0x0a)
{
//printf("%c",*sip);
safeputchar(*(sip_line));
sip_line++;
count++;
}
else
{
printf("\n");
sip_line=sip_line+2;
count=count+2;
printf("\n");
break;
}
//printf("\n");
}
return count;
}


void safeputchar(int c)
{
unsigned char ch;
ch = (unsigned char)(c);
if ((ch == '\t') || (ch == '\r') || (ch == '\n'))
printf("",ch);
else if ((ch < 0x80 ) && isprint(ch))
printf("%c", ch);
else
printf(" 0x%x ",ch);
}

Is there a problem with this code?? I'm just getting well the Status Line.
 
printf("",ch);
Print with empty format?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top