linux_socket.c (b40ce4165d5eb3a5de1515245055350ae3dbab8e) linux_socket.c (4730796ca1fe8ad0edc89e03a54da3267e4612b9)
1/*-
2 * Copyright (c) 1995 S�ren Schmidt
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 40 unchanged lines hidden (view full) ---

49#include <netinet/in_systm.h>
50#include <netinet/ip.h>
51
52#include <machine/../linux/linux.h>
53#include <machine/../linux/linux_proto.h>
54#include <compat/linux/linux_socket.h>
55#include <compat/linux/linux_util.h>
56
1/*-
2 * Copyright (c) 1995 S�ren Schmidt
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 40 unchanged lines hidden (view full) ---

49#include <netinet/in_systm.h>
50#include <netinet/ip.h>
51
52#include <machine/../linux/linux.h>
53#include <machine/../linux/linux_proto.h>
54#include <compat/linux/linux_socket.h>
55#include <compat/linux/linux_util.h>
56
57/*
58 * FreeBSD's socket calls require the sockaddr struct length to agree
59 * with the address family. Linux does not, so we must force it.
60 */
61static int
62linux_to_bsd_namelen(caddr_t name, int namelen)
63{
64 uint16_t family; /* XXX must match Linux sockaddr */
65
66 if (copyin(name, &family, sizeof(family)))
67 return namelen;
68
69 switch (family) {
70 case AF_INET:
71 return sizeof(struct sockaddr_in);
72 case AF_INET6:
73 return sizeof(struct sockaddr_in6);
74 }
75 return namelen;
76}
77
57#ifndef __alpha__
58static int
59linux_to_bsd_domain(int domain)
60{
61
62 switch (domain) {
63 case LINUX_AF_UNSPEC:
64 return (AF_UNSPEC);

--- 303 unchanged lines hidden (view full) ---

368 } */ bsd_args;
369 int error;
370
371 if ((error = copyin(args, &linux_args, sizeof(linux_args))))
372 return (error);
373
374 bsd_args.s = linux_args.s;
375 bsd_args.name = (caddr_t)linux_args.name;
78#ifndef __alpha__
79static int
80linux_to_bsd_domain(int domain)
81{
82
83 switch (domain) {
84 case LINUX_AF_UNSPEC:
85 return (AF_UNSPEC);

--- 303 unchanged lines hidden (view full) ---

389 } */ bsd_args;
390 int error;
391
392 if ((error = copyin(args, &linux_args, sizeof(linux_args))))
393 return (error);
394
395 bsd_args.s = linux_args.s;
396 bsd_args.name = (caddr_t)linux_args.name;
376 bsd_args.namelen = linux_args.namelen;
397 bsd_args.namelen = linux_to_bsd_namelen(bsd_args.name, linux_args.namelen);
377 return (bind(td, &bsd_args));
378}
379
380struct linux_connect_args {
381 int s;
382 struct sockaddr * name;
383 int namelen;
384};

--- 17 unchanged lines hidden (view full) ---

402 bcopy(args, &linux_args, sizeof(linux_args));
403#else
404 if ((error = copyin(args, &linux_args, sizeof(linux_args))))
405 return (error);
406#endif /* __alpha__ */
407
408 bsd_args.s = linux_args.s;
409 bsd_args.name = (caddr_t)linux_args.name;
398 return (bind(td, &bsd_args));
399}
400
401struct linux_connect_args {
402 int s;
403 struct sockaddr * name;
404 int namelen;
405};

--- 17 unchanged lines hidden (view full) ---

423 bcopy(args, &linux_args, sizeof(linux_args));
424#else
425 if ((error = copyin(args, &linux_args, sizeof(linux_args))))
426 return (error);
427#endif /* __alpha__ */
428
429 bsd_args.s = linux_args.s;
430 bsd_args.name = (caddr_t)linux_args.name;
410 bsd_args.namelen = linux_args.namelen;
431 bsd_args.namelen = linux_to_bsd_namelen(bsd_args.name, linux_args.namelen);
411 error = connect(td, &bsd_args);
412 if (error != EISCONN)
413 return (error);
414
415 /*
416 * Linux doesn't return EISCONN the first time it occurs,
417 * when on a non-blocking socket. Instead it returns the
418 * error getsockopt(SOL_SOCKET, SO_ERROR) would return on BSD.

--- 534 unchanged lines hidden ---
432 error = connect(td, &bsd_args);
433 if (error != EISCONN)
434 return (error);
435
436 /*
437 * Linux doesn't return EISCONN the first time it occurs,
438 * when on a non-blocking socket. Instead it returns the
439 * error getsockopt(SOL_SOCKET, SO_ERROR) would return on BSD.

--- 534 unchanged lines hidden ---