Δημοσιεύτηκε: 14 Μαρ 2012, 00:09
από utnubu
Καλησπέρα,
προσπαθώ να τραβήξω κάποιες πληροφορίες από ένα sip πακέτο με τον παρακάτω κώδικα.
Αυτό που παίρνω όταν τρέχω τον κώδικα είναι segmantation fault.
Αν κάποιος μπορεί να βοηθήσει,θα είμαι ευγνώμων. :bow:
Κώδικας: Επιλογή όλων


char * tch; /* Parsing pointer for strtok function */
char * from; /* "From" pointer */
char * contact; /* "Contact" pointer */
char * user; /* "User" pointer */
char * callid; /* "Call-ID" pointer */
char * payload; /* Packet's Payload */
tch = strtok (payload,"<>;\n\"");
while (tch != NULL)
{
if (strncmp(tch, "From",4)==0) /* Comparation of first 4 chars to "From" and if so collect it*/
{
tch = strtok (NULL, "<>;\n\"");
from = tch;
printf ("\n SIP From: %s \n", from);
}
if (strncmp(tch, "Contact",7)==0) /* Comparation of first 7 chars to "Contact" and if so collect it*/
{
tch = strtok (NULL, "<>;\n\"");
contact = tch;
printf (" SIP Contact: %s \n", contact);
}
if (strncmp(tch, "Authorization",13)==0) /* Comparation of first 13 chars to "Authorization" and if so collect it*/
{
tch = strtok (NULL, "<>;\n\"");
user = tch;
printf (" SIP User: %s \n", user);
}
if (strncmp(tch, "Call-ID",7)==0) /* Comparation of first 7 chars to "Call-ID" and if so collect it*/
{
callid = tch;
printf (" %s \n", callid);
}
tch = strtok (NULL, "<>;\n\"");
}