Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Implement pffinddomain(), and use it as appropriate.
details: https://anonhg.NetBSD.org/src/rev/d07922055324
branches: trunk
changeset: 481788:d07922055324
user: thorpej <thorpej%NetBSD.org@localhost>
date: Sun Feb 06 02:54:15 2000 +0000
description:
Implement pffinddomain(), and use it as appropriate.
diffstat:
sys/kern/uipc_domain.c | 64 +++++++++++++++++++++++++++++--------------------
sys/sys/protosw.h | 3 +-
2 files changed, 40 insertions(+), 27 deletions(-)
diffs (130 lines):
diff -r 4664fae8e321 -r d07922055324 sys/kern/uipc_domain.c
--- a/sys/kern/uipc_domain.c Sun Feb 06 01:26:50 2000 +0000
+++ b/sys/kern/uipc_domain.c Sun Feb 06 02:54:15 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_domain.c,v 1.28 1999/08/05 04:04:28 sommerfeld Exp $ */
+/* $NetBSD: uipc_domain.c,v 1.29 2000/02/06 02:54:16 thorpej Exp $ */
/*
* Copyright (c) 1982, 1986, 1993
@@ -132,45 +132,57 @@
timeout(pfslowtimo, NULL, 1);
}
+struct domain *
+pffinddomain(family)
+ int family;
+{
+ struct domain *dp;
+
+ for (dp = domains; dp != NULL; dp = dp->dom_next)
+ if (dp->dom_family == family)
+ return (dp);
+ return (NULL);
+}
+
struct protosw *
pffindtype(family, type)
int family, type;
{
- register struct domain *dp;
- register struct protosw *pr;
+ struct domain *dp;
+ struct protosw *pr;
- for (dp = domains; dp; dp = dp->dom_next)
- if (dp->dom_family == family)
- goto found;
- return (0);
-found:
+ dp = pffinddomain(family);
+ if (dp == NULL)
+ return (NULL);
+
for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
if (pr->pr_type && pr->pr_type == type)
return (pr);
- return (0);
+
+ return (NULL);
}
struct protosw *
pffindproto(family, protocol, type)
int family, protocol, type;
{
- register struct domain *dp;
- register struct protosw *pr;
- struct protosw *maybe = 0;
+ struct domain *dp;
+ struct protosw *pr;
+ struct protosw *maybe = NULL;
if (family == 0)
- return (0);
- for (dp = domains; dp; dp = dp->dom_next)
- if (dp->dom_family == family)
- goto found;
- return (0);
-found:
+ return (NULL);
+
+ dp = pffinddomain(family);
+ if (dp == NULL)
+ return (NULL);
+
for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) {
if ((pr->pr_protocol == protocol) && (pr->pr_type == type))
return (pr);
if (type == SOCK_RAW && pr->pr_type == SOCK_RAW &&
- pr->pr_protocol == 0 && maybe == (struct protosw *)0)
+ pr->pr_protocol == 0 && maybe == NULL)
maybe = pr;
}
return (maybe);
@@ -186,8 +198,8 @@
size_t newlen;
struct proc *p;
{
- register struct domain *dp;
- register struct protosw *pr;
+ struct domain *dp;
+ struct protosw *pr;
int family, protocol;
/*
@@ -203,11 +215,11 @@
if (family == 0)
return (0);
- for (dp = domains; dp; dp = dp->dom_next)
- if (dp->dom_family == family)
- goto found;
- return (ENOPROTOOPT);
-found:
+
+ dp = pffinddomain(family);
+ if (dp == NULL)
+ return (ENOPROTOOPT);
+
switch (family) {
#ifdef IPSEC
case PF_KEY:
diff -r 4664fae8e321 -r d07922055324 sys/sys/protosw.h
--- a/sys/sys/protosw.h Sun Feb 06 01:26:50 2000 +0000
+++ b/sys/sys/protosw.h Sun Feb 06 02:54:15 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: protosw.h,v 1.20 2000/02/02 23:28:11 thorpej Exp $ */
+/* $NetBSD: protosw.h,v 1.21 2000/02/06 02:54:15 thorpej Exp $ */
/*-
* Copyright (c) 1982, 1986, 1993
@@ -257,6 +257,7 @@
struct sockaddr;
struct protosw *pffindproto __P((int, int, int));
struct protosw *pffindtype __P((int, int));
+struct domain *pffinddomain __P((int));
void pfctlinput __P((int, struct sockaddr *));
#endif /* _KERNEL */
Home |
Main Index |
Thread Index |
Old Index