Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys more "const"



details:   https://anonhg.NetBSD.org/src/rev/b1a37defae98
branches:  trunk
changeset: 765907:b1a37defae98
user:      drochner <drochner%NetBSD.org@localhost>
date:      Thu Jun 09 19:54:18 2011 +0000

description:
more "const"

diffstat:

 sys/net/pfkeyv2.h     |   8 +++---
 sys/netipsec/ipsec.c  |  61 +++++++++++++++++++++++++-------------------------
 sys/netipsec/ipsec.h  |   8 +++---
 sys/netipsec/ipsec6.h |   6 ++--
 sys/netipsec/key.c    |  50 ++++++++++++++++++++--------------------
 sys/netipsec/key.h    |   4 +-
 6 files changed, 68 insertions(+), 69 deletions(-)

diffs (truncated from 453 to 300 lines):

diff -r a0ecb26cef5b -r b1a37defae98 sys/net/pfkeyv2.h
--- a/sys/net/pfkeyv2.h Thu Jun 09 19:11:06 2011 +0000
+++ b/sys/net/pfkeyv2.h Thu Jun 09 19:54:18 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pfkeyv2.h,v 1.29 2011/05/26 21:50:02 drochner Exp $    */
+/*     $NetBSD: pfkeyv2.h,v 1.30 2011/06/09 19:54:18 drochner Exp $    */
 /*     $KAME: pfkeyv2.h,v 1.36 2003/07/25 09:33:37 itojun Exp $        */
 
 /*
@@ -430,11 +430,11 @@
 /* Utilities */
 #define PFKEY_ALIGN8(a) (1 + (((a) - 1) | (8 - 1)))
 #define        PFKEY_EXTLEN(msg) \
-       PFKEY_UNUNIT64(((struct sadb_ext *)(void *)(msg))->sadb_ext_len)
+       PFKEY_UNUNIT64(((const struct sadb_ext *)(const void *)(msg))->sadb_ext_len)
 #define PFKEY_ADDR_PREFIX(ext) \
-       (((struct sadb_address *)(void *)(ext))->sadb_address_prefixlen)
+       (((const struct sadb_address *)(const void *)(ext))->sadb_address_prefixlen)
 #define PFKEY_ADDR_PROTO(ext) \
-       (((struct sadb_address *)(void *)(ext))->sadb_address_proto)
+       (((const struct sadb_address *)(const void *)(ext))->sadb_address_proto)
 #define PFKEY_ADDR_SADDR(ext) \
        ((struct sockaddr *)(void *)((char *)(void *)(ext) + \
        sizeof(struct sadb_address)))
diff -r a0ecb26cef5b -r b1a37defae98 sys/netipsec/ipsec.c
--- a/sys/netipsec/ipsec.c      Thu Jun 09 19:11:06 2011 +0000
+++ b/sys/netipsec/ipsec.c      Thu Jun 09 19:54:18 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ipsec.c,v 1.54 2011/06/08 16:24:50 dyoung Exp $        */
+/*     $NetBSD: ipsec.c,v 1.55 2011/06/09 19:54:18 drochner Exp $      */
 /*     $FreeBSD: /usr/local/www/cvsroot/FreeBSD/src/sys/netipsec/ipsec.c,v 1.2.2.2 2003/07/01 01:38:13 sam Exp $       */
 /*     $KAME: ipsec.c,v 1.103 2001/05/24 07:14:18 sakane Exp $ */
 
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.54 2011/06/08 16:24:50 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.55 2011/06/09 19:54:18 drochner Exp $");
 
 /*
  * IPsec controller part.
@@ -242,11 +242,11 @@
 #endif
 static void ipsec_delpcbpolicy (struct inpcbpolicy *);
 static struct secpolicy *ipsec_deepcopy_policy (const struct secpolicy *);
-static int ipsec_set_policy (struct secpolicy **,int , void *, size_t ,
-    kauth_cred_t );
+static int ipsec_set_policy (struct secpolicy **, int, const void *, size_t,
+    kauth_cred_t);
 static int ipsec_get_policy (struct secpolicy *, struct mbuf **);
 static void vshiftl (unsigned char *, int, int);
-static size_t ipsec_hdrsiz (struct secpolicy *);
+static size_t ipsec_hdrsiz (const struct secpolicy *);
 
 #ifdef __NetBSD__
 /*
@@ -481,7 +481,7 @@
  * NOTE: IPv6 mapped address concern is implemented here.
  */
 struct secpolicy *
-ipsec_getpolicy(struct tdb_ident *tdbi, u_int dir)
+ipsec_getpolicy(const struct tdb_ident *tdbi, u_int dir)
 {
        struct secpolicy *sp;
 
@@ -785,7 +785,7 @@
 #endif /* INET6 */
 
 static int
-ipsec4_setspidx_inpcb(struct mbuf *m ,struct inpcb *pcb)
+ipsec4_setspidx_inpcb(struct mbuf *m, struct inpcb *pcb)
 {
        int error;
 
@@ -1224,7 +1224,7 @@
 ipsec_deepcopy_policy(const struct secpolicy *src)
 {
        struct ipsecrequest *newchain = NULL;
-       struct ipsecrequest *p;
+       const struct ipsecrequest *p;
        struct ipsecrequest **q;
        struct ipsecrequest *r;
        struct secpolicy *dst;
@@ -1268,10 +1268,9 @@
        return dst;
 
 fail:
-       for (p = newchain; p; p = r) {
-               r = p->next;
-               free(p, M_SECA);
-               p = NULL;
+       for (q = &newchain; *q; q = &r) {
+               r = (*q)->next;
+               free(*q, M_SECA);
        }
        return NULL;
 }
@@ -1281,12 +1280,12 @@
 ipsec_set_policy(
        struct secpolicy **pcb_sp,
        int optname,
-       void *request,
+       const void *request,
        size_t len,
        kauth_cred_t cred
 )
 {
-       struct sadb_x_policy *xpl;
+       const struct sadb_x_policy *xpl;
        struct secpolicy *newsp = NULL;
        int error;
 
@@ -1295,11 +1294,11 @@
                return EINVAL;
        if (len < sizeof(*xpl))
                return EINVAL;
-       xpl = (struct sadb_x_policy *)request;
+       xpl = (const struct sadb_x_policy *)request;
 
        KEYDEBUG(KEYDEBUG_IPSEC_DUMP,
                printf("ipsec_set_policy: passed policy\n");
-               kdebug_sadb_x_policy((struct sadb_ext *)xpl));
+               kdebug_sadb_x_policy((const struct sadb_ext *)xpl));
 
        /* check policy type */
        /* ipsec_set_policy() accepts IPSEC, ENTRUST and BYPASS. */
@@ -1354,10 +1353,10 @@
 }
 
 int
-ipsec4_set_policy(struct inpcb *inp, int optname ,void *request,
+ipsec4_set_policy(struct inpcb *inp, int optname, const void *request,
                  size_t len, kauth_cred_t cred)
 {
-       struct sadb_x_policy *xpl;
+       const struct sadb_x_policy *xpl;
        struct secpolicy **pcb_sp;
 
        /* sanity check. */
@@ -1365,7 +1364,7 @@
                return EINVAL;
        if (len < sizeof(*xpl))
                return EINVAL;
-       xpl = (struct sadb_x_policy *)request;
+       xpl = (const struct sadb_x_policy *)request;
 
        IPSEC_ASSERT(inp->inp_sp != NULL,
                         ("ipsec4_set_policy(): null inp->in_sp"));
@@ -1388,10 +1387,10 @@
 }
 
 int
-ipsec4_get_policy(struct inpcb *inp, void *request, size_t len, 
+ipsec4_get_policy(struct inpcb *inp, const void *request, size_t len, 
                  struct mbuf **mp)
 {
-       struct sadb_x_policy *xpl;
+       const struct sadb_x_policy *xpl;
        struct secpolicy *pcb_sp;
 
        /* sanity check. */
@@ -1400,7 +1399,7 @@
        IPSEC_ASSERT(inp->inp_sp != NULL, ("ipsec4_get_policy: null inp_sp"));
        if (len < sizeof(*xpl))
                return EINVAL;
-       xpl = (struct sadb_x_policy *)request;
+       xpl = (const struct sadb_x_policy *)request;
 
        /* select direction */
        switch (xpl->sadb_x_policy_dir) {
@@ -1446,10 +1445,10 @@
 
 #ifdef INET6
 int
-ipsec6_set_policy(struct in6pcb *in6p, int optname, void *request,
+ipsec6_set_policy(struct in6pcb *in6p, int optname, const void *request,
                  size_t len, kauth_cred_t cred)
 {
-       struct sadb_x_policy *xpl;
+       const struct sadb_x_policy *xpl;
        struct secpolicy **pcb_sp;
 
        /* sanity check. */
@@ -1457,7 +1456,7 @@
                return EINVAL;
        if (len < sizeof(*xpl))
                return EINVAL;
-       xpl = (struct sadb_x_policy *)request;
+       xpl = (const struct sadb_x_policy *)request;
 
        /* select direction */
        switch (xpl->sadb_x_policy_dir) {
@@ -1477,10 +1476,10 @@
 }
 
 int
-ipsec6_get_policy(struct in6pcb *in6p, void *request, size_t len,
+ipsec6_get_policy(struct in6pcb *in6p, const void *request, size_t len,
                  struct mbuf **mp)
 {
-       struct sadb_x_policy *xpl;
+       const struct sadb_x_policy *xpl;
        struct secpolicy *pcb_sp;
 
        /* sanity check. */
@@ -1489,7 +1488,7 @@
        IPSEC_ASSERT(in6p->in6p_sp != NULL, ("ipsec6_get_policy: null in6p_sp"));
        if (len < sizeof(*xpl))
                return EINVAL;
-       xpl = (struct sadb_x_policy *)request;
+       xpl = (const struct sadb_x_policy *)request;
 
        /* select direction */
        switch (xpl->sadb_x_policy_dir) {
@@ -1795,9 +1794,9 @@
  * NOTE: SP passed is free in this function.
  */
 static size_t
-ipsec_hdrsiz(struct secpolicy *sp)
+ipsec_hdrsiz(const struct secpolicy *sp)
 {
-       struct ipsecrequest *isr;
+       const struct ipsecrequest *isr;
        size_t siz;
 
        KEYDEBUG(KEYDEBUG_IPSEC_DATA,
@@ -1843,7 +1842,7 @@
                        default:
                                ipseclog((LOG_ERR, "ipsec_hdrsiz: "
                                        "unknown AF %d in IPsec tunnel SA\n",
-                                       ((struct sockaddr *)&isr->saidx.dst)->sa_family));
+                                       ((const struct sockaddr *)&isr->saidx.dst)->sa_family));
                                break;
                        }
                }
diff -r a0ecb26cef5b -r b1a37defae98 sys/netipsec/ipsec.h
--- a/sys/netipsec/ipsec.h      Thu Jun 09 19:11:06 2011 +0000
+++ b/sys/netipsec/ipsec.h      Thu Jun 09 19:54:18 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ipsec.h,v 1.28 2011/06/08 16:24:50 dyoung Exp $        */
+/*     $NetBSD: ipsec.h,v 1.29 2011/06/09 19:54:18 drochner Exp $      */
 /*     $FreeBSD: /usr/local/www/cvsroot/FreeBSD/src/sys/netipsec/ipsec.h,v 1.2.4.2 2004/02/14 22:23:23 bms Exp $       */
 /*     $KAME: ipsec.h,v 1.53 2001/11/20 08:32:38 itojun Exp $  */
 
@@ -249,7 +249,7 @@
 #endif /* __NetBSD__ */
 
 struct tdb_ident;
-struct secpolicy *ipsec_getpolicy (struct tdb_ident*, u_int);
+struct secpolicy *ipsec_getpolicy (const struct tdb_ident*, u_int);
 struct inpcb;
 struct secpolicy *ipsec4_checkpolicy (struct mbuf *, u_int, u_int,
        int *, struct inpcb *);
@@ -286,8 +286,8 @@
 u_int ipsec_get_reqlevel (const struct ipsecrequest *);
 int ipsec_in_reject (const struct secpolicy *, const struct mbuf *);
 
-int ipsec4_set_policy (struct inpcb *, int, void *, size_t, kauth_cred_t);
-int ipsec4_get_policy (struct inpcb *, void *, size_t, struct mbuf **);
+int ipsec4_set_policy (struct inpcb *, int, const void *, size_t, kauth_cred_t);
+int ipsec4_get_policy (struct inpcb *, const void *, size_t, struct mbuf **);
 int ipsec4_delete_pcbpolicy (struct inpcb *);
 int ipsec4_in_reject (struct mbuf *, struct inpcb *);
 /*
diff -r a0ecb26cef5b -r b1a37defae98 sys/netipsec/ipsec6.h
--- a/sys/netipsec/ipsec6.h     Thu Jun 09 19:11:06 2011 +0000
+++ b/sys/netipsec/ipsec6.h     Thu Jun 09 19:54:18 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ipsec6.h,v 1.12 2009/05/10 02:13:07 elad Exp $ */
+/*     $NetBSD: ipsec6.h,v 1.13 2011/06/09 19:54:18 drochner Exp $     */
 /*     $FreeBSD: src/sys/netipsec/ipsec6.h,v 1.1.4.1 2003/01/24 05:11:35 sam Exp $     */
 /*     $KAME: ipsec.h,v 1.44 2001/03/23 08:08:47 itojun Exp $  */
 
@@ -62,8 +62,8 @@
 #define        key_freesp(_x)          KEY_FREESP(&_x)
 
 int ipsec6_delete_pcbpolicy (struct in6pcb *);
-int ipsec6_set_policy (struct in6pcb *, int, void *, size_t, kauth_cred_t);
-int ipsec6_get_policy (struct in6pcb *, void *, size_t, struct mbuf **);
+int ipsec6_set_policy (struct in6pcb *, int, const void *, size_t, kauth_cred_t);
+int ipsec6_get_policy (struct in6pcb *, const void *, size_t, struct mbuf **);
 struct secpolicy *ipsec6_checkpolicy (struct mbuf *, u_int, 
     u_int, int *, struct in6pcb *);
 struct secpolicy * ipsec6_check_policy(struct mbuf *, 
diff -r a0ecb26cef5b -r b1a37defae98 sys/netipsec/key.c
--- a/sys/netipsec/key.c        Thu Jun 09 19:11:06 2011 +0000
+++ b/sys/netipsec/key.c        Thu Jun 09 19:54:18 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: key.c,v 1.72 2011/06/06 16:48:35 drochner Exp $        */
+/*     $NetBSD: key.c,v 1.73 2011/06/09 19:54:18 drochner Exp $        */
 /*     $FreeBSD: src/sys/netipsec/key.c,v 1.3.2.3 2004/02/14 22:23:23 bms Exp $        */
 /*     $KAME: key.c,v 1.191 2001/06/27 10:46:49 sakane Exp $   */
        
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.72 2011/06/06 16:48:35 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.73 2011/06/09 19:54:18 drochner Exp $");



Home | Main Index | Thread Index | Old Index