gencode.c (17684) | gencode.c (17749) |
---|---|
1/* 2 * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that: (1) source code distributions 7 * retain the above copyright notice and this paragraph in its entirety, (2) 8 * distributions including binary code include the above copyright notice and --- 26 unchanged lines hidden (view full) --- 35#include <net/if.h> 36 37#include <netinet/in.h> 38#include <netinet/if_ether.h> 39 40#include <stdlib.h> 41#include <memory.h> 42#include <setjmp.h> | 1/* 2 * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that: (1) source code distributions 7 * retain the above copyright notice and this paragraph in its entirety, (2) 8 * distributions including binary code include the above copyright notice and --- 26 unchanged lines hidden (view full) --- 35#include <net/if.h> 36 37#include <netinet/in.h> 38#include <netinet/if_ether.h> 39 40#include <stdlib.h> 41#include <memory.h> 42#include <setjmp.h> |
43#include <net/if_llc.h> |
|
43#if __STDC__ 44#include <stdarg.h> 45#else 46#include <varargs.h> 47#endif 48 49#include "pcap-int.h" 50 51#include "ethertype.h" | 44#if __STDC__ 45#include <stdarg.h> 46#else 47#include <varargs.h> 48#endif 49 50#include "pcap-int.h" 51 52#include "ethertype.h" |
53#include "nlpid.h" |
|
52#include "gencode.h" 53#include <pcap-namedb.h> 54 55#include "gnuc.h" 56#ifdef HAVE_OS_PROTO_H 57#include "os-proto.h" 58#endif 59 --- 500 unchanged lines hidden (view full) --- 560 break; 561 562 case DLT_NULL: 563 /* XXX */ 564 if (proto == ETHERTYPE_IP) 565 return (gen_cmp(0, BPF_W, (bpf_int32)AF_INET)); 566 else 567 return gen_false(); | 54#include "gencode.h" 55#include <pcap-namedb.h> 56 57#include "gnuc.h" 58#ifdef HAVE_OS_PROTO_H 59#include "os-proto.h" 60#endif 61 --- 500 unchanged lines hidden (view full) --- 562 break; 563 564 case DLT_NULL: 565 /* XXX */ 566 if (proto == ETHERTYPE_IP) 567 return (gen_cmp(0, BPF_W, (bpf_int32)AF_INET)); 568 else 569 return gen_false(); |
570 case DLT_EN10MB: 571 /* 572 * Having to look at SAP's here is quite disgusting, 573 * but given an internal architecture that _knows_ that 574 * it's looking at IP on Ethernet... 575 */ 576 if (proto == LLC_ISO_LSAP) { 577 struct block *b0, *b1; 578 579 b0 = gen_cmp(off_linktype, BPF_H, (long)ETHERMTU); 580 b0->s.code = JMP(BPF_JGT); 581 gen_not(b0); 582 b1 = gen_cmp(off_linktype + 2, BPF_H, (long) 583 ((LLC_ISO_LSAP << 8) | LLC_ISO_LSAP)); 584 gen_and(b0, b1); 585 return b1; 586 } 587 break; |
|
568 } 569 return gen_cmp(off_linktype, BPF_H, (bpf_int32)proto); 570} 571 572static struct block * 573gen_hostop(addr, mask, dir, proto, src_off, dst_off) 574 bpf_u_int32 addr; 575 bpf_u_int32 mask; --- 255 unchanged lines hidden (view full) --- 831 bpf_error("LAT host filtering not implemented"); 832 833 case Q_MOPDL: 834 bpf_error("MOPDL host filtering not implemented"); 835 836 case Q_MOPRC: 837 bpf_error("MOPRC host filtering not implemented"); 838 | 588 } 589 return gen_cmp(off_linktype, BPF_H, (bpf_int32)proto); 590} 591 592static struct block * 593gen_hostop(addr, mask, dir, proto, src_off, dst_off) 594 bpf_u_int32 addr; 595 bpf_u_int32 mask; --- 255 unchanged lines hidden (view full) --- 851 bpf_error("LAT host filtering not implemented"); 852 853 case Q_MOPDL: 854 bpf_error("MOPDL host filtering not implemented"); 855 856 case Q_MOPRC: 857 bpf_error("MOPRC host filtering not implemented"); 858 |
859 case Q_ISO: 860 bpf_error("ISO host filtering not implemented"); 861 |
|
839 default: 840 abort(); 841 } 842 /* NOTREACHED */ 843} 844 845static struct block * 846gen_gateway(eaddr, alist, proto, dir) --- 65 unchanged lines hidden (view full) --- 912 b1 = gen_cmp(off_nl + 9, BPF_B, (bpf_int32)2); 913 gen_and(b0, b1); 914 break; 915 916#ifndef IPPROTO_IGRP 917#define IPPROTO_IGRP 9 918#endif 919 case Q_IGRP: | 862 default: 863 abort(); 864 } 865 /* NOTREACHED */ 866} 867 868static struct block * 869gen_gateway(eaddr, alist, proto, dir) --- 65 unchanged lines hidden (view full) --- 935 b1 = gen_cmp(off_nl + 9, BPF_B, (bpf_int32)2); 936 gen_and(b0, b1); 937 break; 938 939#ifndef IPPROTO_IGRP 940#define IPPROTO_IGRP 9 941#endif 942 case Q_IGRP: |
920 b0 = gen_linktype(ETHERTYPE_IP); | 943 b0 = gen_linktype(ETHERTYPE_IP); |
921 b1 = gen_cmp(off_nl + 9, BPF_B, (long)IPPROTO_IGRP); 922 gen_and(b0, b1); 923 break; 924 925 case Q_IP: 926 b1 = gen_linktype(ETHERTYPE_IP); 927 break; 928 --- 27 unchanged lines hidden (view full) --- 956 case Q_MOPDL: 957 b1 = gen_linktype(ETHERTYPE_MOPDL); 958 break; 959 960 case Q_MOPRC: 961 b1 = gen_linktype(ETHERTYPE_MOPRC); 962 break; 963 | 944 b1 = gen_cmp(off_nl + 9, BPF_B, (long)IPPROTO_IGRP); 945 gen_and(b0, b1); 946 break; 947 948 case Q_IP: 949 b1 = gen_linktype(ETHERTYPE_IP); 950 break; 951 --- 27 unchanged lines hidden (view full) --- 979 case Q_MOPDL: 980 b1 = gen_linktype(ETHERTYPE_MOPDL); 981 break; 982 983 case Q_MOPRC: 984 b1 = gen_linktype(ETHERTYPE_MOPRC); 985 break; 986 |
987 case Q_ISO: 988 b1 = gen_linktype(LLC_ISO_LSAP); 989 break; 990 991 case Q_ESIS: 992 b1 = gen_proto(ISO9542_ESIS, Q_ISO, Q_DEFAULT); 993 break; 994 995 case Q_ISIS: 996 b1 = gen_proto(ISO10589_ISIS, Q_ISO, Q_DEFAULT); 997 break; 998 |
|
964 default: 965 abort(); 966 } 967 return b1; 968} 969 970static struct block * 971gen_ipfrag() --- 148 unchanged lines hidden (view full) --- 1120 switch (proto) { 1121 case Q_DEFAULT: 1122 case Q_IP: 1123 b0 = gen_linktype(ETHERTYPE_IP); 1124 b1 = gen_cmp(off_nl + 9, BPF_B, (bpf_int32)v); 1125 gen_and(b0, b1); 1126 return b1; 1127 | 999 default: 1000 abort(); 1001 } 1002 return b1; 1003} 1004 1005static struct block * 1006gen_ipfrag() --- 148 unchanged lines hidden (view full) --- 1155 switch (proto) { 1156 case Q_DEFAULT: 1157 case Q_IP: 1158 b0 = gen_linktype(ETHERTYPE_IP); 1159 b1 = gen_cmp(off_nl + 9, BPF_B, (bpf_int32)v); 1160 gen_and(b0, b1); 1161 return b1; 1162 |
1163 case Q_ISO: 1164 b0 = gen_linktype(LLC_ISO_LSAP); 1165 b1 = gen_cmp(off_nl + 3, BPF_B, (long)v); 1166 gen_and(b0, b1); 1167 return b1; 1168 |
|
1128 case Q_ARP: 1129 bpf_error("arp does not encapsulate another protocol"); 1130 /* NOTREACHED */ 1131 1132 case Q_RARP: 1133 bpf_error("rarp does not encapsulate another protocol"); 1134 /* NOTREACHED */ 1135 --- 369 unchanged lines hidden (view full) --- 1505 case Q_ARP: 1506 case Q_RARP: 1507 case Q_ATALK: 1508 case Q_DECNET: 1509 case Q_SCA: 1510 case Q_LAT: 1511 case Q_MOPRC: 1512 case Q_MOPDL: | 1169 case Q_ARP: 1170 bpf_error("arp does not encapsulate another protocol"); 1171 /* NOTREACHED */ 1172 1173 case Q_RARP: 1174 bpf_error("rarp does not encapsulate another protocol"); 1175 /* NOTREACHED */ 1176 --- 369 unchanged lines hidden (view full) --- 1546 case Q_ARP: 1547 case Q_RARP: 1548 case Q_ATALK: 1549 case Q_DECNET: 1550 case Q_SCA: 1551 case Q_LAT: 1552 case Q_MOPRC: 1553 case Q_MOPDL: |
1513 /* XXX Note that we assume a fixed link link header here. */ | 1554 /* XXX Note that we assume a fixed link header here. */ |
1514 s = xfer_to_x(index); 1515 tmp = new_stmt(BPF_LD|BPF_IND|size); 1516 tmp->s.k = off_nl; 1517 sappend(s, tmp); 1518 sappend(index->s, s); 1519 1520 b = gen_proto_abbrev(proto); 1521 if (index->b) --- 211 unchanged lines hidden (view full) --- 1733 1734struct block * 1735gen_greater(n) 1736 int n; 1737{ 1738 return gen_len(BPF_JGE, n); 1739} 1740 | 1555 s = xfer_to_x(index); 1556 tmp = new_stmt(BPF_LD|BPF_IND|size); 1557 tmp->s.k = off_nl; 1558 sappend(s, tmp); 1559 sappend(index->s, s); 1560 1561 b = gen_proto_abbrev(proto); 1562 if (index->b) --- 211 unchanged lines hidden (view full) --- 1774 1775struct block * 1776gen_greater(n) 1777 int n; 1778{ 1779 return gen_len(BPF_JGE, n); 1780} 1781 |
1782/* 1783 * Actually, this is less than or equal. 1784 */ 1785 |
|
1741struct block * 1742gen_less(n) 1743 int n; 1744{ 1745 struct block *b; 1746 1747 b = gen_len(BPF_JGT, n); 1748 gen_not(b); --- 138 unchanged lines hidden --- | 1786struct block * 1787gen_less(n) 1788 int n; 1789{ 1790 struct block *b; 1791 1792 b = gen_len(BPF_JGT, n); 1793 gen_not(b); --- 138 unchanged lines hidden --- |