patch for 1.8.1
Peter Van Epp
vanepp at sfu.ca
Mon Jul 31 20:13:10 EDT 2000
Below is a patch file against the argus-1.8.1.gz distribution from the
ftp site. It includes both Carter's longjump and icmp fixes from the list
plus a patch to make 1.8.1 compile cleanly on FreeBSD 4.1-RELEASE (essentially
comment out a definition it was objecting to if the version is 4.1 or greater,
I checked that 4.0-RELEASE is still happy).
cd argus-1.8.1
patch -p < ../argus.patch
will apply it.
Peter Van Epp / Operations and Technical Support
Simon Fraser University, Burnaby, B.C. Canada
argus.patch:
*** common/argus_util.c.old Thu Apr 6 05:24:09 2000
--- common/argus_util.c Tue Jul 18 07:36:43 2000
***************
*** 1683,1689 ****
static int count_blocks(struct block *);
static void number_blks_r(struct block *);
static int count_stmts(struct block *);
! static void convert_code_r(struct block *);
static int n_blocks;
struct block **blocks;
--- 1683,1689 ----
static int count_blocks(struct block *);
static void number_blks_r(struct block *);
static int count_stmts(struct block *);
! static int convert_code_r(struct block *);
static int n_blocks;
struct block **blocks;
***************
*** 3392,3473 ****
*/
static struct bpf_insn *fstart;
static struct bpf_insn *ftail;
!
#ifdef BDEBUG
int bids[1000];
#endif
!
! static void
convert_code_r(p)
! struct block *p;
{
! struct bpf_insn *dst;
! struct slist *src;
! int slen;
! u_int off;
!
! if (p == 0 || isMarked(p))
! return;
! Mark(p);
!
! convert_code_r(JF(p));
! convert_code_r(JT(p));
!
! slen = slength(p->stmts);
! dst = ftail -= slen + 1;
!
! p->offset = dst - fstart;
!
! for (src = p->stmts; src; src = src->next) {
! if (src->s.code == NOP)
! continue;
! dst->code = (u_short)src->s.code;
! dst->k = src->s.k;
! ++dst;
! }
#ifdef BDEBUG
! bids[dst - fstart] = p->id + 1;
#endif
! dst->code = (u_short)p->s.code;
! dst->k = p->s.k;
! if (JT(p)) {
! off = JT(p)->offset - (p->offset + slen) - 1;
! if (off >= 256)
! bpf_error("long jumps not supported");
! dst->jt = off;
! off = JF(p)->offset - (p->offset + slen) - 1;
! if (off >= 256)
! bpf_error("long jumps not supported");
! dst->jf = off;
! }
}
!
/*
* Convert flowgraph intermediate representation to the
* BPF array representation. Set *lenp to the number of instructions.
*/
struct bpf_insn *
icode_to_fcode(root, lenp)
! struct block *root;
! int *lenp;
{
! int n;
! struct bpf_insn *fp;
!
! unMarkAll();
! n = *lenp = count_stmts(root);
!
! fp = (struct bpf_insn *)malloc(sizeof(*fp) * n);
! memset((char *)fp, 0, sizeof(*fp) * n);
! fstart = fp;
! ftail = fp + n;
- unMarkAll();
- convert_code_r(root);
- return fp;
- }
#ifdef BDEBUG
opt_dump(root)
--- 3392,3520 ----
*/
static struct bpf_insn *fstart;
static struct bpf_insn *ftail;
!
#ifdef BDEBUG
int bids[1000];
#endif
!
! /*
! * Returns true if successful. Returns false if a branch has
! * an offset that is too large. If so, we have marked that
! * branch so that on a subsequent iteration, it will be treated
! * properly.
! */
! static int
convert_code_r(p)
! struct block *p;
{
! struct bpf_insn *dst;
! struct slist *src;
! int slen;
! u_int off;
! int extrajmps; /* number of extra jumps inserted */
!
! if (p == 0 || isMarked(p))
! return (1);
! Mark(p);
!
! if (convert_code_r(JF(p)) == 0)
! return (0);
! if (convert_code_r(JT(p)) == 0)
! return (0);
!
! slen = slength(p->stmts);
! dst = ftail -= (slen + 1 + p->longjt + p->longjf);
! /* inflate length by any extra jumps */
!
! p->offset = dst - fstart;
!
! for (src = p->stmts; src; src = src->next) {
! if (src->s.code == NOP)
! continue;
! dst->code = (u_short)src->s.code;
! dst->k = src->s.k;
! ++dst;
! }
#ifdef BDEBUG
! bids[dst - fstart] = p->id + 1;
#endif
! dst->code = (u_short)p->s.code;
! dst->k = p->s.k;
! if (JT(p)) {
! extrajmps = 0;
! off = JT(p)->offset - (p->offset + slen) - 1;
! if (off >= 256) {
! /* offset too large for branch, must add a jump */
! if (p->longjt == 0) {
! /* mark this instruction and retry */
! p->longjt++;
! return(0);
! }
! /* branch if T to following jump */
! dst->jt = extrajmps;
! extrajmps++;
! dst[extrajmps].code = BPF_JMP|BPF_JA;
! dst[extrajmps].k = off - extrajmps;
! }
! else
! dst->jt = off;
! off = JF(p)->offset - (p->offset + slen) - 1;
! if (off >= 256) {
! /* offset too large for branch, must add a jump */
! if (p->longjf == 0) {
! /* mark this instruction and retry */
! p->longjf++;
! return(0);
! }
! /* branch if F to following jump */
! /* if two jumps are inserted, F goes to second one */
! dst->jf = extrajmps;
! extrajmps++;
! dst[extrajmps].code = BPF_JMP|BPF_JA;
! dst[extrajmps].k = off - extrajmps;
! }
! else
! dst->jf = off;
! }
! return (1);
}
!
/*
* Convert flowgraph intermediate representation to the
* BPF array representation. Set *lenp to the number of instructions.
*/
struct bpf_insn *
icode_to_fcode(root, lenp)
! struct block *root;
! int *lenp;
{
! int n;
! struct bpf_insn *fp;
!
! /*
! * Loop doing convert_codr_r() until no branches remain
! * with too-large offsets.
! */
! while (1) {
! unMarkAll();
! n = *lenp = count_stmts(root);
!
! fp = (struct bpf_insn *)malloc(sizeof(*fp) * n);
! memset((char *)fp, 0, sizeof(*fp) * n);
! fstart = fp;
! ftail = fp + n;
!
! unMarkAll();
! if (convert_code_r(root))
! break;
! free(fp);
! }
!
! return fp;
! }
#ifdef BDEBUG
opt_dump(root)
*** server/cons_icmp.c.orig Tue Jul 18 07:20:12 2000
--- server/cons_icmp.c Tue Jul 18 08:59:15 2000
***************
*** 127,133 ****
src = ip->ip_src.s_addr;
dst = ip->ip_dst.s_addr;
! if (len >= sizeof (struct icmp)) {
if (ICMP_INFOTYPE(icmp->icmp_type)) {
switch (icmp->icmp_type) {
case ICMP_ECHOREPLY:
--- 127,133 ----
src = ip->ip_src.s_addr;
dst = ip->ip_dst.s_addr;
! if (len >= ICMP_MINLEN) {
if (ICMP_INFOTYPE(icmp->icmp_type)) {
switch (icmp->icmp_type) {
case ICMP_ECHOREPLY:
*** include/gencode.h.old Tue Nov 30 07:50:50 1999
--- include/gencode.h Tue Jul 18 07:35:11 2000
***************
*** 153,158 ****
--- 153,160 ----
struct slist *stmts; /* side effect stmts */
struct stmt s; /* branch stmt */
int mark;
+ int longjt; /* jt branch requires long jump */
+ int longjf; /* jf branch requires long jump */
int level;
int offset;
int sense;
*** common/addrtoname.c.orig Mon Jul 31 15:56:08 2000
--- common/addrtoname.c Mon Jul 31 16:00:59 2000
***************
*** 60,66 ****
--- 60,68 ----
#ifdef ETHER_SERVICE
struct ether_addr;
#ifndef linux
+ #if __FreeBSD_cc_version < 410000
extern int ether_ntohost(char *, struct ether_addr *);
+ #endif
#endif
#endif
More information about the argus
mailing list