Print this page
inet_pton


   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */



  25 
  26 #include <sys/systm.h>
  27 #include <rpc/auth.h>
  28 #include <rpc/clnt.h>
  29 #include <nfs/nfs4_kprot.h>
  30 #include <nfs/nfs4.h>
  31 #include <nfs/lm.h>
  32 #include <sys/cmn_err.h>
  33 #include <sys/disp.h>
  34 #include <sys/sdt.h>
  35 
  36 #include <sys/pathname.h>
  37 
  38 #include <sys/strsubr.h>
  39 #include <sys/ddi.h>
  40 
  41 #include <sys/vnode.h>
  42 #include <sys/sdt.h>
  43 #include <inet/common.h>
  44 #include <inet/ip.h>


 100                         k = i;
 101                         if (inet_pton(af, ua, ap) == 1) {
 102 
 103                                 c = 0;
 104 
 105                                 for (j = i+1; j < len; j++) {
 106                                         if (ua[j] == '.') {
 107                                                 port = c << 8;
 108                                                 c = 0;
 109                                         } else if (ua[j] >= '0' &&
 110                                             ua[j] <= '9') {
 111                                                 c *= 10;
 112                                                 c += ua[j] - '0';
 113                                         } else {
 114                                                 ua[k] = '.';
 115                                                 return (EINVAL);
 116                                         }
 117                                 }
 118                                 port += c;
 119 
 120 
 121                                 /* reset to network order */
 122                                 if (af == AF_INET) {
 123                                         *(uint32_t *)ap =
 124                                             htonl(*(uint32_t *)ap);
 125                                         *pp = htons(port);
 126                                 } else {
 127                                         int ix;
 128                                         uint16_t *sap;
 129 
 130                                         for (sap = ap, ix = 0; ix <
 131                                             sizeof (struct in6_addr) /
 132                                             sizeof (uint16_t); ix++)
 133                                                 sap[ix] = htons(sap[ix]);
 134 
 135                                         *pp = htons(port);
 136                                 }
 137 
 138                                 ua[k] = '.';
 139                                 return (0);
 140                         } else {
 141                                 ua[k] = '.';
 142                                 return (EINVAL);
 143                         }
 144                 }
 145         }
 146 
 147         return (EINVAL);
 148 }
 149 
 150 /*
 151  * Update the delegation policy with the
 152  * value of "new_policy"
 153  */
 154 void
 155 rfs4_set_deleg_policy(srv_deleg_policy_t new_policy)
 156 {




   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 /*
  26  * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
  27  */
  28 
  29 #include <sys/systm.h>
  30 #include <rpc/auth.h>
  31 #include <rpc/clnt.h>
  32 #include <nfs/nfs4_kprot.h>
  33 #include <nfs/nfs4.h>
  34 #include <nfs/lm.h>
  35 #include <sys/cmn_err.h>
  36 #include <sys/disp.h>
  37 #include <sys/sdt.h>
  38 
  39 #include <sys/pathname.h>
  40 
  41 #include <sys/strsubr.h>
  42 #include <sys/ddi.h>
  43 
  44 #include <sys/vnode.h>
  45 #include <sys/sdt.h>
  46 #include <inet/common.h>
  47 #include <inet/ip.h>


 103                         k = i;
 104                         if (inet_pton(af, ua, ap) == 1) {
 105 
 106                                 c = 0;
 107 
 108                                 for (j = i+1; j < len; j++) {
 109                                         if (ua[j] == '.') {
 110                                                 port = c << 8;
 111                                                 c = 0;
 112                                         } else if (ua[j] >= '0' &&
 113                                             ua[j] <= '9') {
 114                                                 c *= 10;
 115                                                 c += ua[j] - '0';
 116                                         } else {
 117                                                 ua[k] = '.';
 118                                                 return (EINVAL);
 119                                         }
 120                                 }
 121                                 port += c;
 122 





 123                                 *pp = htons(port);











 124 
 125                                 ua[k] = '.';
 126                                 return (0);
 127                         } else {
 128                                 ua[k] = '.';
 129                                 return (EINVAL);
 130                         }
 131                 }
 132         }
 133 
 134         return (EINVAL);
 135 }
 136 
 137 /*
 138  * Update the delegation policy with the
 139  * value of "new_policy"
 140  */
 141 void
 142 rfs4_set_deleg_policy(srv_deleg_policy_t new_policy)
 143 {