[SCTP]: Beginning of conversion to net-endian for embedded sctp_addr.
[linux-drm-fsl-dcu.git] / net / sctp / bind_addr.c
index f71549710f2e1b5b282446a334c3bba27ba552ea..b8115cb31ae330abfc78397559e7dd1322f98648 100644 (file)
@@ -53,7 +53,7 @@
 
 /* Forward declarations for internal helpers. */
 static int sctp_copy_one_addr(struct sctp_bind_addr *, union sctp_addr *,
-                             sctp_scope_t scope, unsigned int __nocast gfp,
+                             sctp_scope_t scope, gfp_t gfp,
                              int flags);
 static void sctp_bind_addr_clean(struct sctp_bind_addr *);
 
@@ -64,7 +64,7 @@ static void sctp_bind_addr_clean(struct sctp_bind_addr *);
  */
 int sctp_bind_addr_copy(struct sctp_bind_addr *dest, 
                        const struct sctp_bind_addr *src,
-                       sctp_scope_t scope, unsigned int __nocast gfp,
+                       sctp_scope_t scope, gfp_t gfp,
                        int flags)
 {
        struct sctp_sockaddr_entry *addr;
@@ -77,7 +77,7 @@ int sctp_bind_addr_copy(struct sctp_bind_addr *dest,
        /* Extract the addresses which are relevant for this scope.  */
        list_for_each(pos, &src->address_list) {
                addr = list_entry(pos, struct sctp_sockaddr_entry, list);
-               error = sctp_copy_one_addr(dest, &addr->a, scope,
+               error = sctp_copy_one_addr(dest, &addr->a_h, scope,
                                           gfp, flags);
                if (error < 0)
                        goto out;
@@ -91,7 +91,7 @@ int sctp_bind_addr_copy(struct sctp_bind_addr *dest,
                list_for_each(pos, &src->address_list) {
                        addr = list_entry(pos, struct sctp_sockaddr_entry,
                                          list);
-                       error = sctp_copy_one_addr(dest, &addr->a,
+                       error = sctp_copy_one_addr(dest, &addr->a_h,
                                                   SCTP_SCOPE_LINK, gfp,
                                                   flags);
                        if (error < 0)
@@ -146,7 +146,7 @@ void sctp_bind_addr_free(struct sctp_bind_addr *bp)
 
 /* Add an address to the bind address list in the SCTP_bind_addr structure. */
 int sctp_add_bind_addr(struct sctp_bind_addr *bp, union sctp_addr *new,
-                      unsigned int __nocast gfp)
+                      __u8 use_as_src, gfp_t gfp)
 {
        struct sctp_sockaddr_entry *addr;
 
@@ -155,13 +155,15 @@ int sctp_add_bind_addr(struct sctp_bind_addr *bp, union sctp_addr *new,
        if (!addr)
                return -ENOMEM;
 
-       memcpy(&addr->a, new, sizeof(*new));
+       memcpy(&addr->a_h, new, sizeof(*new));
 
        /* Fix up the port if it has not yet been set.
         * Both v4 and v6 have the port at the same offset.
         */
-       if (!addr->a.v4.sin_port)
-               addr->a.v4.sin_port = bp->port;
+       if (!addr->a_h.v4.sin_port)
+               addr->a_h.v4.sin_port = bp->port;
+
+       addr->use_as_src = use_as_src;
 
        INIT_LIST_HEAD(&addr->list);
        list_add_tail(&addr->list, &bp->address_list);
@@ -180,7 +182,7 @@ int sctp_del_bind_addr(struct sctp_bind_addr *bp, union sctp_addr *del_addr)
 
        list_for_each_safe(pos, temp, &bp->address_list) {
                addr = list_entry(pos, struct sctp_sockaddr_entry, list);
-               if (sctp_cmp_addr_exact(&addr->a, del_addr)) {
+               if (sctp_cmp_addr_exact(&addr->a_h, del_addr)) {
                        /* Found the exact match. */
                        list_del(pos);
                        kfree(addr);
@@ -200,7 +202,7 @@ int sctp_del_bind_addr(struct sctp_bind_addr *bp, union sctp_addr *del_addr)
  */
 union sctp_params sctp_bind_addrs_to_raw(const struct sctp_bind_addr *bp,
                                         int *addrs_len,
-                                        unsigned int __nocast gfp)
+                                        gfp_t gfp)
 {
        union sctp_params addrparms;
        union sctp_params retval;
@@ -235,8 +237,8 @@ union sctp_params sctp_bind_addrs_to_raw(const struct sctp_bind_addr *bp,
 
        list_for_each(pos, &bp->address_list) {
                addr = list_entry(pos, struct sctp_sockaddr_entry, list);
-               af = sctp_get_af_specific(addr->a.v4.sin_family);
-               len = af->to_addr_param(&addr->a, &rawaddr);
+               af = sctp_get_af_specific(addr->a_h.v4.sin_family);
+               len = af->to_addr_param(&addr->a_h, &rawaddr);
                memcpy(addrparms.v, &rawaddr, len);
                addrparms.v += len;
                addrparms_len += len;
@@ -252,7 +254,7 @@ end_raw:
  * address parameters).
  */
 int sctp_raw_to_bind_addrs(struct sctp_bind_addr *bp, __u8 *raw_addr_list,
-                          int addrs_len, __u16 port, unsigned int __nocast gfp)
+                          int addrs_len, __u16 port, gfp_t gfp)
 {
        union sctp_addr_param *rawaddr;
        struct sctp_paramhdr *param;
@@ -274,7 +276,7 @@ int sctp_raw_to_bind_addrs(struct sctp_bind_addr *bp, __u8 *raw_addr_list,
                }
 
                af->from_addr_param(&addr, rawaddr, port, 0);
-               retval = sctp_add_bind_addr(bp, &addr, gfp);
+               retval = sctp_add_bind_addr(bp, &addr, 1, gfp);
                if (retval) {
                        /* Can't finish building the list, clean up. */
                        sctp_bind_addr_clean(bp);
@@ -303,7 +305,7 @@ int sctp_bind_addr_match(struct sctp_bind_addr *bp,
 
        list_for_each(pos, &bp->address_list) {
                laddr = list_entry(pos, struct sctp_sockaddr_entry, list);
-               if (opt->pf->cmp_addr(&laddr->a, addr, opt))
+               if (opt->pf->cmp_addr(&laddr->a_h, addr, opt))
                        return 1;
        }
 
@@ -330,18 +332,20 @@ union sctp_addr *sctp_find_unmatch_addr(struct sctp_bind_addr     *bp,
                
                addr_buf = (union sctp_addr *)addrs;
                for (i = 0; i < addrcnt; i++) {
+                       union sctp_addr tmp;
                        addr = (union sctp_addr *)addr_buf;
                        af = sctp_get_af_specific(addr->v4.sin_family);
                        if (!af) 
                                return NULL;
+                       flip_to_h(&tmp, addr);
 
-                       if (opt->pf->cmp_addr(&laddr->a, addr, opt))
+                       if (opt->pf->cmp_addr(&laddr->a_h, &tmp, opt))
                                break;
 
                        addr_buf += af->sockaddr_len;
                }
                if (i == addrcnt)
-                       return &laddr->a;
+                       return &laddr->a_h;
        }
 
        return NULL;
@@ -350,7 +354,7 @@ union sctp_addr *sctp_find_unmatch_addr(struct sctp_bind_addr       *bp,
 /* Copy out addresses from the global local address list. */
 static int sctp_copy_one_addr(struct sctp_bind_addr *dest, 
                              union sctp_addr *addr,
-                             sctp_scope_t scope, unsigned int __nocast gfp,
+                             sctp_scope_t scope, gfp_t gfp,
                              int flags)
 {
        int error = 0;
@@ -367,7 +371,7 @@ static int sctp_copy_one_addr(struct sctp_bind_addr *dest,
                    (((AF_INET6 == addr->sa.sa_family) &&
                      (flags & SCTP_ADDR6_ALLOWED) &&
                      (flags & SCTP_ADDR6_PEERSUPP))))
-                       error = sctp_add_bind_addr(dest, addr, gfp);
+                       error = sctp_add_bind_addr(dest, addr, 1, gfp);
        }
 
        return error;