From owner-p4-projects@FreeBSD.ORG Thu Nov 2 20:42:45 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 785BA16A416; Thu, 2 Nov 2006 20:42:45 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 528DE16A407 for ; Thu, 2 Nov 2006 20:42:45 +0000 (UTC) (envelope-from piso@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7FD6343D5A for ; Thu, 2 Nov 2006 20:42:42 +0000 (GMT) (envelope-from piso@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id kA2KggDG051257 for ; Thu, 2 Nov 2006 20:42:42 GMT (envelope-from piso@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id kA2Kggex051251 for perforce@freebsd.org; Thu, 2 Nov 2006 20:42:42 GMT (envelope-from piso@freebsd.org) Date: Thu, 2 Nov 2006 20:42:42 GMT Message-Id: <200611022042.kA2Kggex051251@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to piso@freebsd.org using -f From: Paolo Pisati To: Perforce Change Reviews Cc: Subject: PERFORCE change 109070 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Nov 2006 20:42:45 -0000 http://perforce.freebsd.org/chv.cgi?CH=109070 Change 109070 by piso@piso_newluxor on 2006/11/02 20:42:13 -wrap at 80 cols -spacing Affected files ... .. //depot/projects/soc2005/libalias/sbin/ipfw/ipfw2.c#12 edit Differences ... ==== //depot/projects/soc2005/libalias/sbin/ipfw/ipfw2.c#12 (text+ko) ==== @@ -3443,7 +3443,8 @@ } static int -StrToAddrAndPortRange (const char* str, struct in_addr* addr, char* proto, port_range *portRange) +StrToAddrAndPortRange (const char* str, struct in_addr* addr, char* proto, + port_range *portRange) { char* ptr; @@ -3539,7 +3540,7 @@ /* Setup LSNAT server pool. */ if (sep) { int sof_spool = sizeof(struct cfg_spool); - struct cfg_spool *tmp; + struct cfg_spool *tmp; sep = strtok(tmp_spool_buf, ","); while (sep != NULL) { @@ -3602,12 +3603,14 @@ r->laddr.s_addr = INADDR_NONE; r->lport = ~0; numLocalPorts = 1; - /* Preserve av, copy spool servers to tmp_spool_buf. */ + /* Preserve av, copy spool servers to tmp_spool_buf. */ strncpy(tmp_spool_buf, *av, strlen(*av)+1); lsnat = 1; } else { - if (StrToAddrAndPortRange (*av, &r->laddr, protoName, &portRange) != 0) - errx(EX_DATAERR, "redirect_port: invalid local port range"); + if (StrToAddrAndPortRange (*av, &r->laddr, protoName, + &portRange) != 0) + errx(EX_DATAERR, "redirect_port:" + "invalid local port range"); r->lport = GETLOPORT(portRange); numLocalPorts = GETNUMPORTS(portRange); @@ -3622,12 +3625,15 @@ sep = strchr (*av, ':'); if (sep) { - if (StrToAddrAndPortRange (*av, &r->paddr, protoName, &portRange) != 0) - errx(EX_DATAERR, "redirect_port: invalid public port range"); + if (StrToAddrAndPortRange (*av, &r->paddr, protoName, + &portRange) != 0) + errx(EX_DATAERR, "redirect_port:" + "invalid public port range"); } else { r->paddr.s_addr = INADDR_ANY; if (StrToPortRange (*av, protoName, &portRange) != 0) - errx(EX_DATAERR, "redirect_port: invalid public port range"); + errx(EX_DATAERR, "redirect_port:" + "invalid public port range"); } r->pport = GETLOPORT(portRange); @@ -3644,8 +3650,10 @@ if (ac != 0 && !isalpha(**av)) { sep = strchr (*av, ':'); if (sep) { - if (StrToAddrAndPortRange (*av, &r->raddr, protoName, &portRange) != 0) - errx(EX_DATAERR, "redirect_port: invalid remote port range"); + if (StrToAddrAndPortRange (*av, &r->raddr, protoName, + &portRange) != 0) + errx(EX_DATAERR, "redirect_port:" + "invalid remote port range"); } else { SETLOPORT(portRange, 0); SETNUMPORTS(portRange, 1); @@ -3664,11 +3672,14 @@ * Make sure port ranges match up, then add the redirect ports. */ if (numLocalPorts != r->pport_cnt) - errx(EX_DATAERR, "redirect_port: port ranges must be equal in size"); + errx(EX_DATAERR, "redirect_port:" + "port ranges must be equal in size"); /* Remote port range is allowed to be '0' which means all ports. */ - if (r->rport_cnt != numLocalPorts && (r->rport_cnt != 1 || r->rport != 0)) - errx(EX_DATAERR, "redirect_port: remote port must be 0 or equal to local port range in size"); + if (r->rport_cnt != numLocalPorts && + (r->rport_cnt != 1 || r->rport != 0)) + errx(EX_DATAERR, "redirect_port: remote port must" + "be 0 or equal to local port range in size"); /* * Setup LSNAT server pool. @@ -3684,10 +3695,13 @@ goto nospace; len -= sof_spool; space += sof_spool; - if (StrToAddrAndPortRange(sep, &tmp->addr, protoName, &portRange) != 0) - errx(EX_DATAERR, "redirect_port: invalid local port range"); + if (StrToAddrAndPortRange(sep, &tmp->addr, protoName, + &portRange) != 0) + errx(EX_DATAERR, "redirect_port:" + "invalid local port range"); if (GETNUMPORTS(portRange) != 1) - errx(EX_DATAERR, "redirect_port: local port must be single in this context"); + errx(EX_DATAERR, "redirect_port: local port" + "must be single in this context"); tmp->port = GETLOPORT(portRange); r->spool_cnt++; /* Point to the next possible cfg_spool. */ @@ -3839,13 +3853,15 @@ if (!t->spool_cnt) { printf("%s:%u", inet_ntoa(t->laddr), t->lport); if (t->pport_cnt > 1) - printf("-%u", t->lport+t->pport_cnt-1); + printf("-%u", t->lport + + t->pport_cnt - 1); } else for (i=0; i < t->spool_cnt; i++) { s = (struct cfg_spool *)&buf[off]; if (i) printf(","); - printf("%s:%u", inet_ntoa(s->addr), s->port); + printf("%s:%u", inet_ntoa(s->addr), + s->port); off += sof_spool; } @@ -3853,15 +3869,16 @@ if (t->paddr.s_addr) printf("%s:", inet_ntoa(t->paddr)); printf("%u", t->pport); - if (!t->spool_cnt && t->pport_cnt>1) - printf("-%u", t->pport+t->pport_cnt-1); + if (!t->spool_cnt && t->pport_cnt > 1) + printf("-%u", t->pport + t->pport_cnt - 1); if (t->raddr.s_addr) { printf(" %s", inet_ntoa(t->raddr)); if (t->rport) { printf(":%u", t->rport); - if (!t->spool_cnt && t->rport_cnt>1) - printf("-%u", t->rport+t->rport_cnt-1); + if (!t->spool_cnt && t->rport_cnt > 1) + printf("-%u", t->rport + + t->rport_cnt - 1); } } break; @@ -3870,14 +3887,14 @@ printf(" redir_proto %s %s", p->p_name, inet_ntoa(t->laddr)); if (t->paddr.s_addr != 0) { - printf(" %s", inet_ntoa(t->paddr)); + printf(" %s", inet_ntoa(t->paddr)); if (t->raddr.s_addr) - printf(" %s", inet_ntoa(t->raddr)); + printf(" %s", inet_ntoa(t->raddr)); } break; default: errx(EX_DATAERR, "unknown redir mode"); - break; + break; } } printf("\n"); @@ -3890,7 +3907,7 @@ struct in_addr ip; int i, len = NAT_BUF_LEN; /* Offset in buf: save space for n at the beginning. */ - int off = sizeof(*n); + int off = sizeof(*n); char *id, buf[NAT_BUF_LEN]; /* Buffer for serialized data. */ memset(buf, 0, sizeof(buf)); @@ -5881,18 +5898,18 @@ if (e->mode == REDIR_ADDR || e->mode == REDIR_PORT || e->mode == REDIR_PROTO) i += sizeof(struct cfg_redir) + e->spool_cnt * - sizeof(struct cfg_spool); - } - } else { + sizeof(struct cfg_spool); + } + } else { for (i = 0; 1; i += LIBALIAS_BUF_SIZE + sizeof(int)) { p = &data[i]; - if (p == data + nbytes) + if (p == data + nbytes) break; bcopy(p, &r, sizeof(int)); - if (do_rule) - if (!(frule <= r && lrule >= r)) + if (do_rule) + if (!(frule <= r && lrule >= r)) continue; - printf("nat %u: %s\n", r, p+sizeof(int)); + printf("nat %u: %s\n", r, p+sizeof(int)); } } }