guillermoandres
Programmer
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.
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.