diff options
Diffstat (limited to 'include/linux/sunrpc/clnt.h')
-rw-r--r-- | include/linux/sunrpc/clnt.h | 155 |
1 files changed, 0 insertions, 155 deletions
diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h index 6a7c2619a355..4a4abde000cb 100644 --- a/include/linux/sunrpc/clnt.h +++ b/include/linux/sunrpc/clnt.h | |||
@@ -165,160 +165,5 @@ size_t rpc_peeraddr(struct rpc_clnt *, struct sockaddr *, size_t); | |||
165 | const char *rpc_peeraddr2str(struct rpc_clnt *, enum rpc_display_format_t); | 165 | const char *rpc_peeraddr2str(struct rpc_clnt *, enum rpc_display_format_t); |
166 | int rpc_localaddr(struct rpc_clnt *, struct sockaddr *, size_t); | 166 | int rpc_localaddr(struct rpc_clnt *, struct sockaddr *, size_t); |
167 | 167 | ||
168 | size_t rpc_ntop(const struct sockaddr *, char *, const size_t); | ||
169 | size_t rpc_pton(struct net *, const char *, const size_t, | ||
170 | struct sockaddr *, const size_t); | ||
171 | char * rpc_sockaddr2uaddr(const struct sockaddr *, gfp_t); | ||
172 | size_t rpc_uaddr2sockaddr(struct net *, const char *, const size_t, | ||
173 | struct sockaddr *, const size_t); | ||
174 | |||
175 | static inline unsigned short rpc_get_port(const struct sockaddr *sap) | ||
176 | { | ||
177 | switch (sap->sa_family) { | ||
178 | case AF_INET: | ||
179 | return ntohs(((struct sockaddr_in *)sap)->sin_port); | ||
180 | case AF_INET6: | ||
181 | return ntohs(((struct sockaddr_in6 *)sap)->sin6_port); | ||
182 | } | ||
183 | return 0; | ||
184 | } | ||
185 | |||
186 | static inline void rpc_set_port(struct sockaddr *sap, | ||
187 | const unsigned short port) | ||
188 | { | ||
189 | switch (sap->sa_family) { | ||
190 | case AF_INET: | ||
191 | ((struct sockaddr_in *)sap)->sin_port = htons(port); | ||
192 | break; | ||
193 | case AF_INET6: | ||
194 | ((struct sockaddr_in6 *)sap)->sin6_port = htons(port); | ||
195 | break; | ||
196 | } | ||
197 | } | ||
198 | |||
199 | #define IPV6_SCOPE_DELIMITER '%' | ||
200 | #define IPV6_SCOPE_ID_LEN sizeof("%nnnnnnnnnn") | ||
201 | |||
202 | static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1, | ||
203 | const struct sockaddr *sap2) | ||
204 | { | ||
205 | const struct sockaddr_in *sin1 = (const struct sockaddr_in *)sap1; | ||
206 | const struct sockaddr_in *sin2 = (const struct sockaddr_in *)sap2; | ||
207 | |||
208 | return sin1->sin_addr.s_addr == sin2->sin_addr.s_addr; | ||
209 | } | ||
210 | |||
211 | static inline bool __rpc_copy_addr4(struct sockaddr *dst, | ||
212 | const struct sockaddr *src) | ||
213 | { | ||
214 | const struct sockaddr_in *ssin = (struct sockaddr_in *) src; | ||
215 | struct sockaddr_in *dsin = (struct sockaddr_in *) dst; | ||
216 | |||
217 | dsin->sin_family = ssin->sin_family; | ||
218 | dsin->sin_addr.s_addr = ssin->sin_addr.s_addr; | ||
219 | return true; | ||
220 | } | ||
221 | |||
222 | #if IS_ENABLED(CONFIG_IPV6) | ||
223 | static inline bool __rpc_cmp_addr6(const struct sockaddr *sap1, | ||
224 | const struct sockaddr *sap2) | ||
225 | { | ||
226 | const struct sockaddr_in6 *sin1 = (const struct sockaddr_in6 *)sap1; | ||
227 | const struct sockaddr_in6 *sin2 = (const struct sockaddr_in6 *)sap2; | ||
228 | |||
229 | if (!ipv6_addr_equal(&sin1->sin6_addr, &sin2->sin6_addr)) | ||
230 | return false; | ||
231 | else if (ipv6_addr_type(&sin1->sin6_addr) & IPV6_ADDR_LINKLOCAL) | ||
232 | return sin1->sin6_scope_id == sin2->sin6_scope_id; | ||
233 | |||
234 | return true; | ||
235 | } | ||
236 | |||
237 | static inline bool __rpc_copy_addr6(struct sockaddr *dst, | ||
238 | const struct sockaddr *src) | ||
239 | { | ||
240 | const struct sockaddr_in6 *ssin6 = (const struct sockaddr_in6 *) src; | ||
241 | struct sockaddr_in6 *dsin6 = (struct sockaddr_in6 *) dst; | ||
242 | |||
243 | dsin6->sin6_family = ssin6->sin6_family; | ||
244 | dsin6->sin6_addr = ssin6->sin6_addr; | ||
245 | dsin6->sin6_scope_id = ssin6->sin6_scope_id; | ||
246 | return true; | ||
247 | } | ||
248 | #else /* !(IS_ENABLED(CONFIG_IPV6) */ | ||
249 | static inline bool __rpc_cmp_addr6(const struct sockaddr *sap1, | ||
250 | const struct sockaddr *sap2) | ||
251 | { | ||
252 | return false; | ||
253 | } | ||
254 | |||
255 | static inline bool __rpc_copy_addr6(struct sockaddr *dst, | ||
256 | const struct sockaddr *src) | ||
257 | { | ||
258 | return false; | ||
259 | } | ||
260 | #endif /* !(IS_ENABLED(CONFIG_IPV6) */ | ||
261 | |||
262 | /** | ||
263 | * rpc_cmp_addr - compare the address portion of two sockaddrs. | ||
264 | * @sap1: first sockaddr | ||
265 | * @sap2: second sockaddr | ||
266 | * | ||
267 | * Just compares the family and address portion. Ignores port, but | ||
268 | * compares the scope if it's a link-local address. | ||
269 | * | ||
270 | * Returns true if the addrs are equal, false if they aren't. | ||
271 | */ | ||
272 | static inline bool rpc_cmp_addr(const struct sockaddr *sap1, | ||
273 | const struct sockaddr *sap2) | ||
274 | { | ||
275 | if (sap1->sa_family == sap2->sa_family) { | ||
276 | switch (sap1->sa_family) { | ||
277 | case AF_INET: | ||
278 | return __rpc_cmp_addr4(sap1, sap2); | ||
279 | case AF_INET6: | ||
280 | return __rpc_cmp_addr6(sap1, sap2); | ||
281 | } | ||
282 | } | ||
283 | return false; | ||
284 | } | ||
285 | |||
286 | /** | ||
287 | * rpc_copy_addr - copy the address portion of one sockaddr to another | ||
288 | * @dst: destination sockaddr | ||
289 | * @src: source sockaddr | ||
290 | * | ||
291 | * Just copies the address portion and family. Ignores port, scope, etc. | ||
292 | * Caller is responsible for making certain that dst is large enough to hold | ||
293 | * the address in src. Returns true if address family is supported. Returns | ||
294 | * false otherwise. | ||
295 | */ | ||
296 | static inline bool rpc_copy_addr(struct sockaddr *dst, | ||
297 | const struct sockaddr *src) | ||
298 | { | ||
299 | switch (src->sa_family) { | ||
300 | case AF_INET: | ||
301 | return __rpc_copy_addr4(dst, src); | ||
302 | case AF_INET6: | ||
303 | return __rpc_copy_addr6(dst, src); | ||
304 | } | ||
305 | return false; | ||
306 | } | ||
307 | |||
308 | /** | ||
309 | * rpc_get_scope_id - return scopeid for a given sockaddr | ||
310 | * @sa: sockaddr to get scopeid from | ||
311 | * | ||
312 | * Returns the value of the sin6_scope_id for AF_INET6 addrs, or 0 if | ||
313 | * not an AF_INET6 address. | ||
314 | */ | ||
315 | static inline u32 rpc_get_scope_id(const struct sockaddr *sa) | ||
316 | { | ||
317 | if (sa->sa_family != AF_INET6) | ||
318 | return 0; | ||
319 | |||
320 | return ((struct sockaddr_in6 *) sa)->sin6_scope_id; | ||
321 | } | ||
322 | |||
323 | #endif /* __KERNEL__ */ | 168 | #endif /* __KERNEL__ */ |
324 | #endif /* _LINUX_SUNRPC_CLNT_H */ | 169 | #endif /* _LINUX_SUNRPC_CLNT_H */ |