MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / extract_ftc_hdrs

Function extract_ftc_hdrs

parser/msg_parser.c:1422–1542  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1420 state=1;\
1421 }while(0)
1422int extract_ftc_hdrs( char *buf, int len, str *from, str *to, str *cseq,str *callid)
1423{
1424 char *end, *p;
1425 char *b;
1426 str *fill;
1427 int state;
1428 int flags;
1429 int flag;
1430
1431 p = buf;
1432 end = buf+len;
1433 state = 1;
1434 b = 0;
1435 flags = ((from!=0)?0x1:0) | ((to!=0)?0x2:0) | ((cseq!=0)?0x4:0)
1436 | ((callid!=0)?0x8:0);
1437 flag = 0;
1438 fill = 0;
1439
1440 LM_DBG("flags = %d\n",flags);
1441
1442 while(p<end) {
1443 switch (*p) {
1444 case '\n':
1445 case '\r':
1446 switch (state) {
1447 case 4: state=5;break;
1448 case 5: state=6;break;
1449 case 6: if(!(*p=='\n' && *(p-1)=='\r')) SET_FOUND(1);break;
1450 default : state=2;break;
1451 }
1452 break;
1453 case ' ':
1454 case '\t':
1455 switch (state) {
1456 case 4: case 6: state=5; break;
1457 case 2: state=1; break;/*folded line*/
1458 }
1459 break;
1460 case ':':
1461 switch (state) {
1462 case 4:case 5: state=5;if(flag==0x04)GET_CSEQ();break;
1463 case 6: SET_FOUND(1);break;/*found*/
1464 case 2: state=1;break;
1465 }
1466 break;
1467 case 'f':
1468 case 'F':
1469 if (state==5) break;
1470 if (state==6) SET_FOUND(2);/*found*/;
1471 if (state!=2) {state = 1;break;}
1472 /* hdr starting with 'f' */
1473 if (from==0) break;
1474 b = p;
1475 if (p+3<end && LC(p+1)=='r' && LC(p+2)=='o' && LC(p+3)=='m')
1476 p+=3;
1477 state = 4; /* "f" or "from" found */
1478 fill = from;
1479 flag = 0x1;

Callers 3

build_localFunction · 0.85
run_local_routeFunction · 0.85
dlg_onreplyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected