FreeBSD/sbin/ipfw/ipv6.c
/* fills command for the extension header filtering */
fills command for the extension header filtering
fills command for the extension header filtering
int
fill_ext6hdr( ipfw_insn *cmd, char *av)
{
       int tok;
       char *s = av;
       cmd->arg1 = 0;
       while(s) {
	   av = strsep( &s, ",") ;
	   tok = match_token(ext6hdrcodes, av);
	   switch (tok) {
	   case EXT_FRAGMENT:
	       cmd->arg1 |= EXT_FRAGMENT;
	       break;
	   case EXT_HOPOPTS:
	       cmd->arg1 |= EXT_HOPOPTS;
	       break;
	   case EXT_ROUTING:
	       cmd->arg1 |= EXT_ROUTING;
	       break;
	   case EXT_DSTOPTS:
	       cmd->arg1 |= EXT_DSTOPTS;
	       break;
	   case EXT_AH:
	       cmd->arg1 |= EXT_AH;
	       break;
	   case EXT_ESP:
	       cmd->arg1 |= EXT_ESP;
	       break;
	   case EXT_RTHDR0:
	       cmd->arg1 |= EXT_RTHDR0;
	       break;
	   case EXT_RTHDR2:
	       cmd->arg1 |= EXT_RTHDR2;
	       break;
	   default:
	       errx( EX_DATAERR, "invalid option for ipv6 exten header" );
	       break;
	   }
       }
       if (cmd->arg1 == 0 )
	   return 0;
       cmd->opcode = O_EXT_HDR;
       cmd->len |= F_INSN_SIZE( ipfw_insn );
       return 1;
}
int fill_ext6hdr ( ipfw_insn * cmd , char * av ) { int tok ; char * s = av ; cmd -> arg1 = 0 ; while ( s ) { av = strsep ( & s , " " ) ; tok = match_token ( ext6hdrcodes , av ) ; switch ( tok ) { case EXT_FRAGMENT : cmd -> arg1 |= EXT_FRAGMENT ; break ; case EXT_HOPOPTS : cmd -> arg1 |= EXT_HOPOPTS ; break ; case EXT_ROUTING : cmd -> arg1 |= EXT_ROUTING ; break ; case EXT_DSTOPTS : cmd -> arg1 |= EXT_DSTOPTS ; break ; case EXT_AH : cmd -> arg1 |= EXT_AH ; break ; case EXT_ESP : cmd -> arg1 |= EXT_ESP ; break ; case EXT_RTHDR0 : cmd -> arg1 |= EXT_RTHDR0 ; break ; case EXT_RTHDR2 : cmd -> arg1 |= EXT_RTHDR2 ; break ; default : errx ( EX_DATAERR , " " ) ; break ; } } if ( cmd -> arg1 == 0 ) return 0 ; cmd -> opcode = O_EXT_HDR ; cmd -> len |= F_INSN_SIZE ( ipfw_insn ) ; return 1 ; }
fills command for the extension header filtering
fills command for the extension header filtering