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 1372
 						vb->proto=PROTO_SCTP;
1372 1373
 						state=F_HOST; /* start looking for host*/
1373 1374
 						goto main_via;
1375
+					case OTHER_PROTO:
1376
+						/* finished proto parsing */
1377
+						vb->transport.len=tmp-vb->transport.s;
1378
+						vb->proto=PROTO_OTHER;
1379
+						state=F_HOST; /* start looking for host*/
1380
+						goto main_via;
1381
+					case UDP1:
1382
+					case UDP2:
1383
+					case TCP_TLS1:
1384
+					case TCP2:
1385
+					case TLS2:
1386
+					case SCTP1:
1387
+					case SCTP2:
1388
+					case SCTP3:
1389
+						/* finished proto parsing */
1390
+						vb->transport.len=tmp-vb->transport.s;
1391
+						vb->proto=PROTO_OTHER;
1392
+						state=F_HOST; /* start looking for host*/
1393
+						goto main_via;
1374 1394
 					case FIN_SIP:
1375 1395
 						vb->name.len=tmp-vb->name.s;
1376 1396
 						state=L_VER;
... ...
@@ -1418,6 +1438,33 @@ parse_again:
1418 1438
 						state=F_LF;
1419 1439
 						saved_state=F_HOST; /* start looking for host*/
1420 1440
 						goto main_via;
1441
+					case FIN_SCTP:
1442
+						/* finished proto parsing */
1443
+						vb->transport.len=tmp-vb->transport.s;
1444
+						vb->proto=PROTO_SCTP;
1445
+						state=F_LF;
1446
+						saved_state=F_HOST; /* start looking for host*/
1447
+						goto main_via;
1448
+					case OTHER_PROTO:
1449
+						/* finished proto parsing */
1450
+						vb->transport.len=tmp-vb->transport.s;
1451
+						vb->proto=PROTO_OTHER;
1452
+						state=F_LF;
1453
+						saved_state=F_HOST; /* start looking for host*/
1454
+						goto main_via;
1455
+					case UDP1:
1456
+					case UDP2:
1457
+					case TCP_TLS1:
1458
+					case TCP2:
1459
+					case TLS2:
1460
+					case SCTP1:
1461
+					case SCTP2:
1462
+					case SCTP3:
1463
+						/* finished proto parsing */
1464
+						vb->transport.len=tmp-vb->transport.s;
1465
+						vb->proto=PROTO_OTHER;
1466
+						state=F_HOST; /* start looking for host*/
1467
+						goto main_via;
1421 1468
 					case FIN_SIP:
1422 1469
 						vb->name.len=tmp-vb->name.s;
1423 1470
 						state=F_LF;
... ...
@@ -1469,6 +1516,31 @@ parse_again:
1469 1516
 						state=F_CR;
1470 1517
 						saved_state=F_HOST;
1471 1518
 						goto main_via;
1519
+					case FIN_SCTP:
1520
+						vb->transport.len=tmp-vb->transport.s;
1521
+						vb->proto=PROTO_SCTP;
1522
+						state=F_CR;
1523
+						saved_state=F_HOST;
1524
+						goto main_via;
1525
+					case OTHER_PROTO:
1526
+						vb->transport.len=tmp-vb->transport.s;
1527
+						vb->proto=PROTO_OTHER;
1528
+						state=F_CR;
1529
+						saved_state=F_HOST;
1530
+						goto main_via;
1531
+					case UDP1:
1532
+					case UDP2:
1533
+					case TCP_TLS1:
1534
+					case TCP2:
1535
+					case TLS2:
1536
+					case SCTP1:
1537
+					case SCTP2:
1538
+					case SCTP3:
1539
+						/* finished proto parsing */
1540
+						vb->transport.len=tmp-vb->transport.s;
1541
+						vb->proto=PROTO_OTHER;
1542
+						state=F_HOST; /* start looking for host*/
1543
+						goto main_via;
1472 1544
 					case FIN_SIP:
1473 1545
 						vb->name.len=tmp-vb->name.s;
1474 1546
 						state=F_CR;
... ...
@@ -1528,6 +1600,21 @@ parse_again:
1528 1600
 						state=SCTP1;
1529 1601
 						vb->transport.s=tmp;
1530 1602
 						break;
1603
+					case OTHER_PROTO:
1604
+						break;
1605
+					case UDP1:
1606
+					case UDP2:
1607
+					case FIN_UDP:
1608
+					case TCP_TLS1:
1609
+					case TCP2:
1610
+					case FIN_TCP:
1611
+					case FIN_TLS:
1612
+					case SCTP1:
1613
+					case SCTP2:
1614
+					case SCTP3:
1615
+					case FIN_SCTP:
1616
+						state=OTHER_PROTO;
1617
+						break;
1531 1618
 					default:
1532 1619
 						LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
1533 1620
 								" state %d\n", *tmp, state);
... ...
@@ -1540,6 +1627,22 @@ parse_again:
1540 1627
 					case SIP1:
1541 1628
 						state=SIP2;
1542 1629
 						break;
1630
+					case OTHER_PROTO:
1631
+						break;
1632
+					case UDP1:
1633
+					case UDP2:
1634
+					case FIN_UDP:
1635
+					case TCP_TLS1:
1636
+					case TCP2:
1637
+					case FIN_TCP:
1638
+					case TLS2:
1639
+					case FIN_TLS:
1640
+					case SCTP1:
1641
+					case SCTP2:
1642
+					case SCTP3:
1643
+					case FIN_SCTP:
1644
+						state=OTHER_PROTO;
1645
+						break;
1543 1646
 					default:
1544 1647
 						LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
1545 1648
 								" state %d\n", *tmp, state);
... ...
@@ -1562,6 +1665,19 @@ parse_again:
1562 1665
 					case SCTP3:
1563 1666
 						state=FIN_SCTP;
1564 1667
 						break;
1668
+					case OTHER_PROTO:
1669
+						break;
1670
+					case UDP1:
1671
+					case FIN_UDP:
1672
+					case TCP_TLS1:
1673
+					case FIN_TCP:
1674
+					case TLS2:
1675
+					case FIN_TLS:
1676
+					case SCTP1:
1677
+					case SCTP2:
1678
+					case FIN_SCTP:
1679
+						state=OTHER_PROTO;
1680
+						break;
1565 1681
 					default:
1566 1682
 						LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
1567 1683
 								" state %d\n", *tmp, state);
... ...
@@ -1575,6 +1691,22 @@ parse_again:
1575 1691
 						state=UDP1;
1576 1692
 						vb->transport.s=tmp;
1577 1693
 						break;
1694
+					case OTHER_PROTO:
1695
+						break;
1696
+					case UDP1:
1697
+					case UDP2:
1698
+					case FIN_UDP:
1699
+					case TCP_TLS1:
1700
+					case TCP2:
1701
+					case FIN_TCP:
1702
+					case TLS2:
1703
+					case FIN_TLS:
1704
+					case SCTP1:
1705
+					case SCTP2:
1706
+					case SCTP3:
1707
+					case FIN_SCTP:
1708
+						state=OTHER_PROTO;
1709
+						break;
1578 1710
 					default:
1579 1711
 						LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
1580 1712
 								" state %d\n", *tmp, state);
... ...
@@ -1587,6 +1719,21 @@ parse_again:
1587 1719
 					case UDP1:
1588 1720
 						state=UDP2;
1589 1721
 						break;
1722
+					case OTHER_PROTO:
1723
+						break;
1724
+					case UDP2:
1725
+					case FIN_UDP:
1726
+					case TCP_TLS1:
1727
+					case TCP2:
1728
+					case FIN_TCP:
1729
+					case TLS2:
1730
+					case FIN_TLS:
1731
+					case SCTP1:
1732
+					case SCTP2:
1733
+					case SCTP3:
1734
+					case FIN_SCTP:
1735
+						state=OTHER_PROTO;
1736
+						break;
1590 1737
 					default:
1591 1738
 						LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
1592 1739
 								" state %d\n", *tmp, state);
... ...
@@ -1603,6 +1750,21 @@ parse_again:
1603 1750
 					case SCTP2:
1604 1751
 						state=SCTP3;
1605 1752
 						break;
1753
+					case OTHER_PROTO:
1754
+						break;
1755
+					case UDP1:
1756
+					case UDP2:
1757
+					case FIN_UDP:
1758
+					case TCP_TLS1:
1759
+					case TCP2:
1760
+					case FIN_TCP:
1761
+					case TLS2:
1762
+					case FIN_TLS:
1763
+					case SCTP1:
1764
+					case SCTP3:
1765
+					case FIN_SCTP:
1766
+						state=OTHER_PROTO;
1767
+						break;
1606 1768
 					default:
1607 1769
 						LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
1608 1770
 								" state %d\n", *tmp, state);
... ...
@@ -1618,6 +1780,20 @@ parse_again:
1618 1780
 					case SCTP1:
1619 1781
 						state=SCTP2;
1620 1782
 						break;
1783
+					case OTHER_PROTO:
1784
+						break;
1785
+					case UDP1:
1786
+					case UDP2:
1787
+					case FIN_UDP:
1788
+					case TCP2:
1789
+					case FIN_TCP:
1790
+					case TLS2:
1791
+					case FIN_TLS:
1792
+					case SCTP2:
1793
+					case SCTP3:
1794
+					case FIN_SCTP:
1795
+						state=OTHER_PROTO;
1796
+						break;
1621 1797
 					default:
1622 1798
 						LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
1623 1799
 								" state %d\n", *tmp, state);
... ...
@@ -1630,6 +1806,21 @@ parse_again:
1630 1806
 					case TCP_TLS1:
1631 1807
 						state=TLS2;
1632 1808
 						break;
1809
+					case OTHER_PROTO:
1810
+						break;
1811
+					case UDP1:
1812
+					case UDP2:
1813
+					case FIN_UDP:
1814
+					case TCP2:
1815
+					case FIN_TCP:
1816
+					case TLS2:
1817
+					case FIN_TLS:
1818
+					case SCTP1:
1819
+					case SCTP2:
1820
+					case SCTP3:
1821
+					case FIN_SCTP:
1822
+						state=OTHER_PROTO;
1823
+						break;
1633 1824
 					default:
1634 1825
 						LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
1635 1826
 								" state %d\n", *tmp, state);
... ...
@@ -1643,6 +1834,22 @@ parse_again:
1643 1834
 						state=VER1;
1644 1835
 						vb->version.s=tmp;
1645 1836
 						break;
1837
+					case OTHER_PROTO:
1838
+						break;
1839
+					case UDP1:
1840
+					case UDP2:
1841
+					case FIN_UDP:
1842
+					case TCP_TLS1:
1843
+					case TCP2:
1844
+					case FIN_TCP:
1845
+					case TLS2:
1846
+					case FIN_TLS:
1847
+					case SCTP1:
1848
+					case SCTP2:
1849
+					case SCTP3:
1850
+					case FIN_SCTP:
1851
+						state=OTHER_PROTO;
1852
+						break;
1646 1853
 					default:
1647 1854
 						LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
1648 1855
 								" state %d\n", *tmp, state);
... ...
@@ -1654,6 +1861,22 @@ parse_again:
1654 1861
 					case VER1:
1655 1862
 						state=VER2;
1656 1863
 						break;
1864
+					case OTHER_PROTO:
1865
+						break;
1866
+					case UDP1:
1867
+					case UDP2:
1868
+					case FIN_UDP:
1869
+					case TCP_TLS1:
1870
+					case TCP2:
1871
+					case FIN_TCP:
1872
+					case TLS2:
1873
+					case FIN_TLS:
1874
+					case SCTP1:
1875
+					case SCTP2:
1876
+					case SCTP3:
1877
+					case FIN_SCTP:
1878
+						state=OTHER_PROTO;
1879
+						break;
1657 1880
 					default:
1658 1881
 						LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
1659 1882
 								" state %d\n", *tmp, state);
... ...
@@ -1665,17 +1888,55 @@ parse_again:
1665 1888
 					case VER2:
1666 1889
 						state=FIN_VER;
1667 1890
 						break;
1891
+					case OTHER_PROTO:
1892
+						break;
1893
+					case UDP1:
1894
+					case UDP2:
1895
+					case FIN_UDP:
1896
+					case TCP_TLS1:
1897
+					case TCP2:
1898
+					case FIN_TCP:
1899
+					case TLS2:
1900
+					case FIN_TLS:
1901
+					case SCTP1:
1902
+					case SCTP2:
1903
+					case SCTP3:
1904
+					case FIN_SCTP:
1905
+						state=OTHER_PROTO;
1906
+						break;
1668 1907
 					default:
1669 1908
 						LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
1670 1909
 								" state %d\n", *tmp, state);
1671 1910
 						goto error;
1672 1911
 				}
1673 1912
 				break;
1674
-			
1675 1913
 			default:
1914
+				switch(state){
1915
+					case F_PROTO:
1916
+						state=OTHER_PROTO;
1917
+						vb->transport.s=tmp;
1918
+						break;
1919
+					case OTHER_PROTO:
1920
+						break;
1921
+					case UDP1:
1922
+					case UDP2:
1923
+					case FIN_UDP:
1924
+					case TCP_TLS1:
1925
+					case TCP2:
1926
+					case FIN_TCP:
1927
+					case TLS2:
1928
+					case FIN_TLS:
1929
+					case SCTP1:
1930
+					case SCTP2:
1931
+					case SCTP3:
1932
+					case FIN_SCTP:
1933
+						state=OTHER_PROTO;
1934
+						break;
1935
+					default:
1676 1936
 						LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
1677
-								" state %d\n", *tmp, state);
1937
+						" state %d\n", *tmp, state);
1678 1938
 						goto error;
1939
+				}
1679 1940
 				break;
1680 1941
 		}
1681 1942
 	} /* for tmp*/