linux_socket.c (5a8a13e0fc8cb7ec0ee919168bd98fdbe6f3d88e) | linux_socket.c (3db2a84395a85f1a975b78ac44afaebc677da474) |
---|---|
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 --- 391 unchanged lines hidden (view full) --- 400 return (error); 401} 402 403/* Return 0 if IP_HDRINCL is set for the given socket. */ 404static int 405linux_check_hdrincl(struct thread *td, caddr_t *sg, int s) 406{ 407 struct getsockopt_args /* { | 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 --- 391 unchanged lines hidden (view full) --- 400 return (error); 401} 402 403/* Return 0 if IP_HDRINCL is set for the given socket. */ 404static int 405linux_check_hdrincl(struct thread *td, caddr_t *sg, int s) 406{ 407 struct getsockopt_args /* { |
408 int s; 409 int level; 410 int name; 411 caddr_t val; 412 int *avalsize; | 408 int s; 409 int level; 410 int name; 411 void * __restrict val; 412 socklen_t * __restrict avalsize; |
413 } */ bsd_args; | 413 } */ bsd_args; |
414 int error; 415 caddr_t val, valsize; 416 int size_val = sizeof val; 417 int optval; | 414 void * __restrict val; 415 socklen_t * __restrict valsize; 416 int error, optval, size_val; |
418 | 417 |
419 val = stackgap_alloc(sg, sizeof(int)); 420 valsize = stackgap_alloc(sg, sizeof(int)); | 418 val = stackgap_alloc(sg, sizeof(size_val)); 419 valsize = stackgap_alloc(sg, sizeof(socklen_t)); |
421 | 420 |
421 size_val = sizeof(val); |
|
422 if ((error = copyout(&size_val, valsize, sizeof(size_val)))) 423 return (error); 424 425 bsd_args.s = s; 426 bsd_args.level = IPPROTO_IP; 427 bsd_args.name = IP_HDRINCL; 428 bsd_args.val = val; | 422 if ((error = copyout(&size_val, valsize, sizeof(size_val)))) 423 return (error); 424 425 bsd_args.s = s; 426 bsd_args.level = IPPROTO_IP; 427 bsd_args.name = IP_HDRINCL; 428 bsd_args.val = val; |
429 bsd_args.avalsize = (int *)valsize; | 429 bsd_args.avalsize = valsize; |
430 if ((error = getsockopt(td, &bsd_args))) 431 return (error); 432 433 if ((error = copyin(val, &optval, sizeof(optval)))) 434 return (error); 435 436 return (optval == 0); 437} --- 258 unchanged lines hidden (view full) --- 696 int *namelen; 697}; 698 699static int 700linux_accept(struct thread *td, struct linux_accept_args *args) 701{ 702 struct linux_accept_args linux_args; 703 struct accept_args /* { | 430 if ((error = getsockopt(td, &bsd_args))) 431 return (error); 432 433 if ((error = copyin(val, &optval, sizeof(optval)))) 434 return (error); 435 436 return (optval == 0); 437} --- 258 unchanged lines hidden (view full) --- 696 int *namelen; 697}; 698 699static int 700linux_accept(struct thread *td, struct linux_accept_args *args) 701{ 702 struct linux_accept_args linux_args; 703 struct accept_args /* { |
704 int s; 705 caddr_t name; 706 int *anamelen; | 704 int s; 705 struct sockaddr * __restrict name; 706 socklen_t * __restrict anamelen; |
707 } */ bsd_args; 708 struct close_args /* { 709 int fd; 710 } */ c_args; 711 struct fcntl_args /* { | 707 } */ bsd_args; 708 struct close_args /* { 709 int fd; 710 } */ c_args; 711 struct fcntl_args /* { |
712 int fd; 713 int cmd; 714 long arg; | 712 int fd; 713 int cmd; 714 long arg; |
715 } */ f_args; 716 int error; 717 718 if ((error = copyin(args, &linux_args, sizeof(linux_args)))) 719 return (error); 720 721 bsd_args.s = linux_args.s; | 715 } */ f_args; 716 int error; 717 718 if ((error = copyin(args, &linux_args, sizeof(linux_args)))) 719 return (error); 720 721 bsd_args.s = linux_args.s; |
722 bsd_args.name = (caddr_t)linux_args.addr; 723 bsd_args.anamelen = linux_args.namelen; | 722 /* XXX: */ 723 bsd_args.name = (struct sockaddr * __restrict)linux_args.addr; 724 bsd_args.anamelen = linux_args.namelen; /* XXX */ |
724 error = oaccept(td, &bsd_args); 725 if (error) 726 return (error); 727 if (linux_args.addr) { 728 error = linux_sa_put(linux_args.addr); 729 if (error) { 730 c_args.fd = td->td_retval[0]; 731 (void)close(td, &c_args); --- 20 unchanged lines hidden (view full) --- 752 int *namelen; 753}; 754 755static int 756linux_getsockname(struct thread *td, struct linux_getsockname_args *args) 757{ 758 struct linux_getsockname_args linux_args; 759 struct getsockname_args /* { | 725 error = oaccept(td, &bsd_args); 726 if (error) 727 return (error); 728 if (linux_args.addr) { 729 error = linux_sa_put(linux_args.addr); 730 if (error) { 731 c_args.fd = td->td_retval[0]; 732 (void)close(td, &c_args); --- 20 unchanged lines hidden (view full) --- 753 int *namelen; 754}; 755 756static int 757linux_getsockname(struct thread *td, struct linux_getsockname_args *args) 758{ 759 struct linux_getsockname_args linux_args; 760 struct getsockname_args /* { |
760 int fdes; 761 caddr_t asa; 762 int *alen; | 761 int fdes; 762 struct sockaddr * __restrict asa; 763 socklen_t * __restrict alen; |
763 } */ bsd_args; 764 int error; 765 766 if ((error = copyin(args, &linux_args, sizeof(linux_args)))) 767 return (error); 768 769 bsd_args.fdes = linux_args.s; | 764 } */ bsd_args; 765 int error; 766 767 if ((error = copyin(args, &linux_args, sizeof(linux_args)))) 768 return (error); 769 770 bsd_args.fdes = linux_args.s; |
770 bsd_args.asa = (caddr_t) linux_args.addr; 771 bsd_args.alen = linux_args.namelen; | 771 /* XXX: */ 772 bsd_args.asa = (struct sockaddr * __restrict)linux_args.addr; 773 bsd_args.alen = linux_args.namelen; /* XXX */ |
772 error = ogetsockname(td, &bsd_args); 773 if (error) 774 return (error); 775 error = linux_sa_put(linux_args.addr); 776 if (error) 777 return (error); 778 return (0); 779} --- 157 unchanged lines hidden (view full) --- 937 int *fromlen; 938}; 939 940static int 941linux_recvfrom(struct thread *td, struct linux_recvfrom_args *args) 942{ 943 struct linux_recvfrom_args linux_args; 944 struct recvfrom_args /* { | 774 error = ogetsockname(td, &bsd_args); 775 if (error) 776 return (error); 777 error = linux_sa_put(linux_args.addr); 778 if (error) 779 return (error); 780 return (0); 781} --- 157 unchanged lines hidden (view full) --- 939 int *fromlen; 940}; 941 942static int 943linux_recvfrom(struct thread *td, struct linux_recvfrom_args *args) 944{ 945 struct linux_recvfrom_args linux_args; 946 struct recvfrom_args /* { |
945 int s; 946 caddr_t buf; 947 size_t len; 948 int flags; 949 caddr_t from; 950 int *fromlenaddr; | 947 int s; 948 caddr_t buf; 949 size_t len; 950 int flags; 951 struct sockaddr * __restrict from; 952 socklen_t * __restrict fromlenaddr; |
951 } */ bsd_args; 952 int error; 953 954 if ((error = copyin(args, &linux_args, sizeof(linux_args)))) 955 return (error); 956 957 bsd_args.s = linux_args.s; 958 bsd_args.buf = linux_args.buf; 959 bsd_args.len = linux_args.len; 960 bsd_args.flags = linux_to_bsd_msg_flags(linux_args.flags); | 953 } */ bsd_args; 954 int error; 955 956 if ((error = copyin(args, &linux_args, sizeof(linux_args)))) 957 return (error); 958 959 bsd_args.s = linux_args.s; 960 bsd_args.buf = linux_args.buf; 961 bsd_args.len = linux_args.len; 962 bsd_args.flags = linux_to_bsd_msg_flags(linux_args.flags); |
961 bsd_args.from = linux_args.from; 962 bsd_args.fromlenaddr = linux_args.fromlen; | 963 /* XXX: */ 964 bsd_args.from = (struct sockaddr * __restrict)linux_args.from; 965 bsd_args.fromlenaddr = linux_args.fromlen; /* XXX */ |
963 error = orecvfrom(td, &bsd_args); 964 if (error) 965 return (error); 966 if (linux_args.from) { 967 error = linux_sa_put((struct osockaddr *) linux_args.from); 968 if (error) 969 return (error); 970 } --- 257 unchanged lines hidden --- | 966 error = orecvfrom(td, &bsd_args); 967 if (error) 968 return (error); 969 if (linux_args.from) { 970 error = linux_sa_put((struct osockaddr *) linux_args.from); 971 if (error) 972 return (error); 973 } --- 257 unchanged lines hidden --- |