*** 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

*** common/argus_parse.c.orig	Wed Apr  5 10:58:18 2000
--- common/argus_parse.c	Mon Jul 31 19:51:42 2000
***************
*** 734,740 ****
  
     if ((status & ARGUSCONTROL) &&  (status & CLOSE)) {
        argus_parse_complete();
-       exit(0);
     }
  }
  
--- 734,739 ----

