buildopts.c revision 153881
1/* $FreeBSD: head/contrib/ipfilter/lib/buildopts.c 153881 2005-12-30 11:52:26Z guido $ */ 2 3/* 4 * Copyright (C) 1993-2001 by Darren Reed. 5 * 6 * See the IPFILTER.LICENCE file for details on licencing. 7 * 8 * $Id: buildopts.c,v 1.6 2002/01/28 06:50:45 darrenr Exp $ 9 */ 10 11#include "ipf.h" 12 13 14u_32_t buildopts(cp, op, len) 15char *cp, *op; 16int len; 17{ 18 struct ipopt_names *io; 19 u_32_t msk = 0; 20 char *s, *t; 21 int inc; 22 23 for (s = strtok(cp, ","); s; s = strtok(NULL, ",")) { 24 if ((t = strchr(s, '='))) 25 *t++ = '\0'; 26 for (io = ionames; io->on_name; io++) { 27 if (strcasecmp(s, io->on_name) || (msk & io->on_bit)) 28 continue; 29 if ((inc = addipopt(op, io, len, t))) { 30 op += inc; 31 len += inc; 32 } 33 msk |= io->on_bit; 34 break; 35 } 36 if (!io->on_name) { 37 fprintf(stderr, "unknown IP option name %s\n", s); 38 return 0; 39 } 40 } 41 *op++ = IPOPT_EOL; 42 len++; 43 return len; 44} 45