Browse code

core: Via parser now allows any token as Via transport field.

I├▒aki Baz Castillo authored on 13/09/2011 21:59:25
Showing 3 changed files
... ...
@@ -350,6 +350,8 @@ char* proto2a(enum sip_protos proto)
350 350
 			return "tls";
351 351
 		case PROTO_SCTP:
352 352
 			return "sctp";
353
+		case PROTO_OTHER:
354
+			return "other";
353 355
 	}
354 356
 	return "unknown";
355 357
 }
... ...
@@ -52,8 +52,8 @@
52 52
 
53 53
 #include "dprint.h"
54 54
 
55
-enum sip_protos { PROTO_NONE, PROTO_UDP, PROTO_TCP, PROTO_TLS, PROTO_SCTP };
56
-#define PROTO_LAST PROTO_SCTP
55
+enum sip_protos { PROTO_NONE, PROTO_UDP, PROTO_TCP, PROTO_TLS, PROTO_SCTP, PROTO_OTHER };
56
+#define PROTO_LAST PROTO_OTHER
57 57
 
58 58
 #ifdef USE_COMP
59 59
 enum comp_methods { COMP_NONE, COMP_SIGCOMP, COMP_SERGZ };
... ...
@@ -96,6 +96,7 @@ enum {
96 96
 	TCP_TLS1, TCP2, FIN_TCP,
97 97
 	          TLS2, FIN_TLS,
98 98
 	SCTP1, SCTP2, SCTP3, FIN_SCTP,
99
+	OTHER_PROTO,
99 100
 	L_PROTO, F_PROTO
100 101
 };
101 102
 
... ...
@@ -1371,6 +1372,25 @@ parse_again:
1371 1371
 						vb->proto=PROTO_SCTP;
1372 1372
 						state=F_HOST; /* start looking for host*/
1373 1373
 						goto main_via;
1374
+					case OTHER_PROTO:
1375
+						/* finished proto parsing */
1376
+						vb->transport.len=tmp-vb->transport.s;
1377
+						vb->proto=PROTO_OTHER;
1378
+						state=F_HOST; /* start looking for host*/
1379
+						goto main_via;
1380
+					case UDP1:
1381
+					case UDP2:
1382
+					case TCP_TLS1:
1383
+					case TCP2:
1384
+					case TLS2:
1385
+					case SCTP1:
1386
+					case SCTP2:
1387
+					case SCTP3:
1388
+						/* finished proto parsing */
1389
+						vb->transport.len=tmp-vb->transport.s;
1390
+						vb->proto=PROTO_OTHER;
1391
+						state=F_HOST; /* start looking for host*/
1392
+						goto main_via;
1374 1393
 					case FIN_SIP:
1375 1394
 						vb->name.len=tmp-vb->name.s;
1376 1395
 						state=L_VER;
... ...
@@ -1418,6 +1438,33 @@ parse_again:
1418 1418
 						state=F_LF;
1419 1419
 						saved_state=F_HOST; /* start looking for host*/
1420 1420
 						goto main_via;
1421
+					case FIN_SCTP:
1422
+						/* finished proto parsing */
1423
+						vb->transport.len=tmp-vb->transport.s;
1424
+						vb->proto=PROTO_SCTP;
1425
+						state=F_LF;
1426
+						saved_state=F_HOST; /* start looking for host*/
1427
+						goto main_via;
1428
+					case OTHER_PROTO:
1429
+						/* finished proto parsing */
1430
+						vb->transport.len=tmp-vb->transport.s;
1431
+						vb->proto=PROTO_OTHER;
1432
+						state=F_LF;
1433
+						saved_state=F_HOST; /* start looking for host*/
1434
+						goto main_via;
1435
+					case UDP1:
1436
+					case UDP2:
1437
+					case TCP_TLS1:
1438
+					case TCP2:
1439
+					case TLS2:
1440
+					case SCTP1:
1441
+					case SCTP2:
1442
+					case SCTP3:
1443
+						/* finished proto parsing */
1444
+						vb->transport.len=tmp-vb->transport.s;
1445
+						vb->proto=PROTO_OTHER;
1446
+						state=F_HOST; /* start looking for host*/
1447
+						goto main_via;
1421 1448
 					case FIN_SIP:
1422 1449
 						vb->name.len=tmp-vb->name.s;
1423 1450
 						state=F_LF;
... ...
@@ -1469,6 +1516,31 @@ parse_again:
1469 1469
 						state=F_CR;
1470 1470
 						saved_state=F_HOST;
1471 1471
 						goto main_via;
1472
+					case FIN_SCTP:
1473
+						vb->transport.len=tmp-vb->transport.s;
1474
+						vb->proto=PROTO_SCTP;
1475
+						state=F_CR;
1476
+						saved_state=F_HOST;
1477
+						goto main_via;
1478
+					case OTHER_PROTO:
1479
+						vb->transport.len=tmp-vb->transport.s;
1480
+						vb->proto=PROTO_OTHER;
1481
+						state=F_CR;
1482
+						saved_state=F_HOST;
1483
+						goto main_via;
1484
+					case UDP1:
1485
+					case UDP2:
1486
+					case TCP_TLS1:
1487
+					case TCP2:
1488
+					case TLS2:
1489
+					case SCTP1:
1490
+					case SCTP2:
1491
+					case SCTP3:
1492
+						/* finished proto parsing */
1493
+						vb->transport.len=tmp-vb->transport.s;
1494
+						vb->proto=PROTO_OTHER;
1495
+						state=F_HOST; /* start looking for host*/
1496
+						goto main_via;
1472 1497
 					case FIN_SIP:
1473 1498
 						vb->name.len=tmp-vb->name.s;
1474 1499
 						state=F_CR;
... ...
@@ -1528,6 +1600,21 @@ parse_again:
1528 1528
 						state=SCTP1;
1529 1529
 						vb->transport.s=tmp;
1530 1530
 						break;
1531
+					case OTHER_PROTO:
1532
+						break;
1533
+					case UDP1:
1534
+					case UDP2:
1535
+					case FIN_UDP:
1536
+					case TCP_TLS1:
1537
+					case TCP2:
1538
+					case FIN_TCP:
1539
+					case FIN_TLS:
1540
+					case SCTP1:
1541
+					case SCTP2:
1542
+					case SCTP3:
1543
+					case FIN_SCTP:
1544
+						state=OTHER_PROTO;
1545
+						break;
1531 1546
 					default:
1532 1547
 						LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
1533 1548
 								" state %d\n", *tmp, state);
... ...
@@ -1540,6 +1627,22 @@ parse_again:
1540 1540
 					case SIP1:
1541 1541
 						state=SIP2;
1542 1542
 						break;
1543
+					case OTHER_PROTO:
1544
+						break;
1545
+					case UDP1:
1546
+					case UDP2:
1547
+					case FIN_UDP:
1548
+					case TCP_TLS1:
1549
+					case TCP2:
1550
+					case FIN_TCP:
1551
+					case TLS2:
1552
+					case FIN_TLS:
1553
+					case SCTP1:
1554
+					case SCTP2:
1555
+					case SCTP3:
1556
+					case FIN_SCTP:
1557
+						state=OTHER_PROTO;
1558
+						break;
1543 1559
 					default:
1544 1560
 						LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
1545 1561
 								" state %d\n", *tmp, state);
... ...
@@ -1562,6 +1665,19 @@ parse_again:
1562 1562
 					case SCTP3:
1563 1563
 						state=FIN_SCTP;
1564 1564
 						break;
1565
+					case OTHER_PROTO:
1566
+						break;
1567
+					case UDP1:
1568
+					case FIN_UDP:
1569
+					case TCP_TLS1:
1570
+					case FIN_TCP:
1571
+					case TLS2:
1572
+					case FIN_TLS:
1573
+					case SCTP1:
1574
+					case SCTP2:
1575
+					case FIN_SCTP:
1576
+						state=OTHER_PROTO;
1577
+						break;
1565 1578
 					default:
1566 1579
 						LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
1567 1580
 								" state %d\n", *tmp, state);
... ...
@@ -1575,6 +1691,22 @@ parse_again:
1575 1575
 						state=UDP1;
1576 1576
 						vb->transport.s=tmp;
1577 1577
 						break;
1578
+					case OTHER_PROTO:
1579
+						break;
1580
+					case UDP1:
1581
+					case UDP2:
1582
+					case FIN_UDP:
1583
+					case TCP_TLS1:
1584
+					case TCP2:
1585
+					case FIN_TCP:
1586
+					case TLS2:
1587
+					case FIN_TLS:
1588
+					case SCTP1:
1589
+					case SCTP2:
1590
+					case SCTP3:
1591
+					case FIN_SCTP:
1592
+						state=OTHER_PROTO;
1593
+						break;
1578 1594
 					default:
1579 1595
 						LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
1580 1596
 								" state %d\n", *tmp, state);
... ...
@@ -1587,6 +1719,21 @@ parse_again:
1587 1587
 					case UDP1:
1588 1588
 						state=UDP2;
1589 1589
 						break;
1590
+					case OTHER_PROTO:
1591
+						break;
1592
+					case UDP2:
1593
+					case FIN_UDP:
1594
+					case TCP_TLS1:
1595
+					case TCP2:
1596
+					case FIN_TCP:
1597
+					case TLS2:
1598
+					case FIN_TLS:
1599
+					case SCTP1:
1600
+					case SCTP2:
1601
+					case SCTP3:
1602
+					case FIN_SCTP:
1603
+						state=OTHER_PROTO;
1604
+						break;
1590 1605
 					default:
1591 1606
 						LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
1592 1607
 								" state %d\n", *tmp, state);
... ...
@@ -1603,6 +1750,21 @@ parse_again:
1603 1603
 					case SCTP2:
1604 1604
 						state=SCTP3;
1605 1605
 						break;
1606
+					case OTHER_PROTO:
1607
+						break;
1608
+					case UDP1:
1609
+					case UDP2:
1610
+					case FIN_UDP:
1611
+					case TCP_TLS1:
1612
+					case TCP2:
1613
+					case FIN_TCP:
1614
+					case TLS2:
1615
+					case FIN_TLS:
1616
+					case SCTP1:
1617
+					case SCTP3:
1618
+					case FIN_SCTP:
1619
+						state=OTHER_PROTO;
1620
+						break;
1606 1621
 					default:
1607 1622
 						LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
1608 1623
 								" state %d\n", *tmp, state);
... ...
@@ -1618,6 +1780,20 @@ parse_again:
1618 1618
 					case SCTP1:
1619 1619
 						state=SCTP2;
1620 1620
 						break;
1621
+					case OTHER_PROTO:
1622
+						break;
1623
+					case UDP1:
1624
+					case UDP2:
1625
+					case FIN_UDP:
1626
+					case TCP2:
1627
+					case FIN_TCP:
1628
+					case TLS2:
1629
+					case FIN_TLS:
1630
+					case SCTP2:
1631
+					case SCTP3:
1632
+					case FIN_SCTP:
1633
+						state=OTHER_PROTO;
1634
+						break;
1621 1635
 					default:
1622 1636
 						LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
1623 1637
 								" state %d\n", *tmp, state);
... ...
@@ -1630,6 +1806,21 @@ parse_again:
1630 1630
 					case TCP_TLS1:
1631 1631
 						state=TLS2;
1632 1632
 						break;
1633
+					case OTHER_PROTO:
1634
+						break;
1635
+					case UDP1:
1636
+					case UDP2:
1637
+					case FIN_UDP:
1638
+					case TCP2:
1639
+					case FIN_TCP:
1640
+					case TLS2:
1641
+					case FIN_TLS:
1642
+					case SCTP1:
1643
+					case SCTP2:
1644
+					case SCTP3:
1645
+					case FIN_SCTP:
1646
+						state=OTHER_PROTO;
1647
+						break;
1633 1648
 					default:
1634 1649
 						LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
1635 1650
 								" state %d\n", *tmp, state);
... ...
@@ -1643,6 +1834,22 @@ parse_again:
1643 1643
 						state=VER1;
1644 1644
 						vb->version.s=tmp;
1645 1645
 						break;
1646
+					case OTHER_PROTO:
1647
+						break;
1648
+					case UDP1:
1649
+					case UDP2:
1650
+					case FIN_UDP:
1651
+					case TCP_TLS1:
1652
+					case TCP2:
1653
+					case FIN_TCP:
1654
+					case TLS2:
1655
+					case FIN_TLS:
1656
+					case SCTP1:
1657
+					case SCTP2:
1658
+					case SCTP3:
1659
+					case FIN_SCTP:
1660
+						state=OTHER_PROTO;
1661
+						break;
1646 1662
 					default:
1647 1663
 						LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
1648 1664
 								" state %d\n", *tmp, state);
... ...
@@ -1654,6 +1861,22 @@ parse_again:
1654 1654
 					case VER1:
1655 1655
 						state=VER2;
1656 1656
 						break;
1657
+					case OTHER_PROTO:
1658
+						break;
1659
+					case UDP1:
1660
+					case UDP2:
1661
+					case FIN_UDP:
1662
+					case TCP_TLS1:
1663
+					case TCP2:
1664
+					case FIN_TCP:
1665
+					case TLS2:
1666
+					case FIN_TLS:
1667
+					case SCTP1:
1668
+					case SCTP2:
1669
+					case SCTP3:
1670
+					case FIN_SCTP:
1671
+						state=OTHER_PROTO;
1672
+						break;
1657 1673
 					default:
1658 1674
 						LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
1659 1675
 								" state %d\n", *tmp, state);
... ...
@@ -1665,17 +1888,55 @@ parse_again:
1665 1665
 					case VER2:
1666 1666
 						state=FIN_VER;
1667 1667
 						break;
1668
+					case OTHER_PROTO:
1669
+						break;
1670
+					case UDP1:
1671
+					case UDP2:
1672
+					case FIN_UDP:
1673
+					case TCP_TLS1:
1674
+					case TCP2:
1675
+					case FIN_TCP:
1676
+					case TLS2:
1677
+					case FIN_TLS:
1678
+					case SCTP1:
1679
+					case SCTP2:
1680
+					case SCTP3:
1681
+					case FIN_SCTP:
1682
+						state=OTHER_PROTO;
1683
+						break;
1668 1684
 					default:
1669 1685
 						LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
1670 1686
 								" state %d\n", *tmp, state);
1671 1687
 						goto error;
1672 1688
 				}
1673 1689
 				break;
1674
-			
1675 1690
 			default:
1691
+				switch(state){
1692
+					case F_PROTO:
1693
+						state=OTHER_PROTO;
1694
+						vb->transport.s=tmp;
1695
+						break;
1696
+					case OTHER_PROTO:
1697
+						break;
1698
+					case UDP1:
1699
+					case UDP2:
1700
+					case FIN_UDP:
1701
+					case TCP_TLS1:
1702
+					case TCP2:
1703
+					case FIN_TCP:
1704
+					case TLS2:
1705
+					case FIN_TLS:
1706
+					case SCTP1:
1707
+					case SCTP2:
1708
+					case SCTP3:
1709
+					case FIN_SCTP:
1710
+						state=OTHER_PROTO;
1711
+						break;
1712
+					default:
1676 1713
 						LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
1677
-								" state %d\n", *tmp, state);
1714
+						" state %d\n", *tmp, state);
1678 1715
 						goto error;
1716
+				}
1679 1717
 				break;
1680 1718
 		}
1681 1719
 	} /* for tmp*/