Deleted Added
full compact
uipc_usrreq.c (126103) uipc_usrreq.c (126425)
1/*
2 * Copyright (c) 1982, 1986, 1989, 1991, 1993
3 * The Regents of the University of California. 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

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

29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * From: @(#)uipc_usrreq.c 8.3 (Berkeley) 1/4/94
34 */
35
36#include <sys/cdefs.h>
1/*
2 * Copyright (c) 1982, 1986, 1989, 1991, 1993
3 * The Regents of the University of California. 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

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

29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * From: @(#)uipc_usrreq.c 8.3 (Berkeley) 1/4/94
34 */
35
36#include <sys/cdefs.h>
37__FBSDID("$FreeBSD: head/sys/kern/uipc_usrreq.c 126103 2004-02-22 01:11:53Z cperciva $");
37__FBSDID("$FreeBSD: head/sys/kern/uipc_usrreq.c 126425 2004-03-01 03:14:23Z rwatson $");
38
39#include "opt_mac.h"
40
41#include <sys/param.h>
42#include <sys/domain.h>
43#include <sys/fcntl.h>
44#include <sys/malloc.h> /* XXX must be before <sys/file.h> */
45#include <sys/file.h>

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

122 return (EINVAL);
123
124 /*
125 * Pass back name of connected socket,
126 * if it was bound and we are still connected
127 * (our peer may have closed already!).
128 */
129 if (unp->unp_conn && unp->unp_conn->unp_addr) {
38
39#include "opt_mac.h"
40
41#include <sys/param.h>
42#include <sys/domain.h>
43#include <sys/fcntl.h>
44#include <sys/malloc.h> /* XXX must be before <sys/file.h> */
45#include <sys/file.h>

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

122 return (EINVAL);
123
124 /*
125 * Pass back name of connected socket,
126 * if it was bound and we are still connected
127 * (our peer may have closed already!).
128 */
129 if (unp->unp_conn && unp->unp_conn->unp_addr) {
130 *nam = dup_sockaddr((struct sockaddr *)unp->unp_conn->unp_addr,
131 1);
130 *nam = sodupsockaddr(
131 (struct sockaddr *)unp->unp_conn->unp_addr, M_WAITOK);
132 } else {
132 } else {
133 *nam = dup_sockaddr((struct sockaddr *)&sun_noname, 1);
133 *nam = sodupsockaddr((struct sockaddr *)&sun_noname,
134 M_WAITOK);
134 }
135 return (0);
136}
137
138static int
139uipc_attach(struct socket *so, int proto, struct thread *td)
140{
141 struct unpcb *unp = sotounpcb(so);

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

215static int
216uipc_peeraddr(struct socket *so, struct sockaddr **nam)
217{
218 struct unpcb *unp = sotounpcb(so);
219
220 if (unp == 0)
221 return (EINVAL);
222 if (unp->unp_conn && unp->unp_conn->unp_addr)
135 }
136 return (0);
137}
138
139static int
140uipc_attach(struct socket *so, int proto, struct thread *td)
141{
142 struct unpcb *unp = sotounpcb(so);

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

216static int
217uipc_peeraddr(struct socket *so, struct sockaddr **nam)
218{
219 struct unpcb *unp = sotounpcb(so);
220
221 if (unp == 0)
222 return (EINVAL);
223 if (unp->unp_conn && unp->unp_conn->unp_addr)
223 *nam = dup_sockaddr((struct sockaddr *)unp->unp_conn->unp_addr,
224 1);
224 *nam = sodupsockaddr(
225 (struct sockaddr *)unp->unp_conn->unp_addr, M_WAITOK);
225 else {
226 /*
227 * XXX: It seems that this test always fails even when
228 * connection is established. So, this else clause is
229 * added as workaround to return PF_LOCAL sockaddr.
230 */
226 else {
227 /*
228 * XXX: It seems that this test always fails even when
229 * connection is established. So, this else clause is
230 * added as workaround to return PF_LOCAL sockaddr.
231 */
231 *nam = dup_sockaddr((struct sockaddr *)&sun_noname, 1);
232 *nam = sodupsockaddr((struct sockaddr *)&sun_noname,
233 M_WAITOK);
232 }
233 return (0);
234}
235
236static int
237uipc_rcvd(struct socket *so, int flags)
238{
239 struct unpcb *unp = sotounpcb(so);

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

436static int
437uipc_sockaddr(struct socket *so, struct sockaddr **nam)
438{
439 struct unpcb *unp = sotounpcb(so);
440
441 if (unp == 0)
442 return (EINVAL);
443 if (unp->unp_addr)
234 }
235 return (0);
236}
237
238static int
239uipc_rcvd(struct socket *so, int flags)
240{
241 struct unpcb *unp = sotounpcb(so);

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

438static int
439uipc_sockaddr(struct socket *so, struct sockaddr **nam)
440{
441 struct unpcb *unp = sotounpcb(so);
442
443 if (unp == 0)
444 return (EINVAL);
445 if (unp->unp_addr)
444 *nam = dup_sockaddr((struct sockaddr *)unp->unp_addr, 1);
446 *nam = sodupsockaddr((struct sockaddr *)unp->unp_addr,
447 M_WAITOK);
445 else
448 else
446 *nam = dup_sockaddr((struct sockaddr *)&sun_noname, 1);
449 *nam = sodupsockaddr((struct sockaddr *)&sun_noname,
450 M_WAITOK);
447 return (0);
448}
449
450struct pr_usrreqs uipc_usrreqs = {
451 uipc_abort, uipc_accept, uipc_attach, uipc_bind, uipc_connect,
452 uipc_connect2, pru_control_notsupp, uipc_detach, uipc_disconnect,
453 uipc_listen, uipc_peeraddr, uipc_rcvd, pru_rcvoob_notsupp,
454 uipc_send, uipc_sense, uipc_shutdown, uipc_sockaddr,

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

660 vput(nd.ni_dvp);
661 if (error) {
662 free(buf, M_TEMP);
663 return (error);
664 }
665 vp = nd.ni_vp;
666 vp->v_socket = unp->unp_socket;
667 unp->unp_vnode = vp;
451 return (0);
452}
453
454struct pr_usrreqs uipc_usrreqs = {
455 uipc_abort, uipc_accept, uipc_attach, uipc_bind, uipc_connect,
456 uipc_connect2, pru_control_notsupp, uipc_detach, uipc_disconnect,
457 uipc_listen, uipc_peeraddr, uipc_rcvd, pru_rcvoob_notsupp,
458 uipc_send, uipc_sense, uipc_shutdown, uipc_sockaddr,

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

664 vput(nd.ni_dvp);
665 if (error) {
666 free(buf, M_TEMP);
667 return (error);
668 }
669 vp = nd.ni_vp;
670 vp->v_socket = unp->unp_socket;
671 unp->unp_vnode = vp;
668 unp->unp_addr = (struct sockaddr_un *)dup_sockaddr(nam, 1);
672 unp->unp_addr = (struct sockaddr_un *)sodupsockaddr(nam, M_WAITOK);
669 VOP_UNLOCK(vp, 0, td);
670 vn_finished_write(mp);
671 free(buf, M_TEMP);
672 return (0);
673}
674
675static int
676unp_connect(so, nam, td)

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

719 error = ECONNREFUSED;
720 goto bad;
721 }
722 unp = sotounpcb(so);
723 unp2 = sotounpcb(so2);
724 unp3 = sotounpcb(so3);
725 if (unp2->unp_addr)
726 unp3->unp_addr = (struct sockaddr_un *)
673 VOP_UNLOCK(vp, 0, td);
674 vn_finished_write(mp);
675 free(buf, M_TEMP);
676 return (0);
677}
678
679static int
680unp_connect(so, nam, td)

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

723 error = ECONNREFUSED;
724 goto bad;
725 }
726 unp = sotounpcb(so);
727 unp2 = sotounpcb(so2);
728 unp3 = sotounpcb(so3);
729 if (unp2->unp_addr)
730 unp3->unp_addr = (struct sockaddr_un *)
727 dup_sockaddr((struct sockaddr *)
728 unp2->unp_addr, 1);
731 sodupsockaddr((struct sockaddr *)unp2->unp_addr,
732 M_WAITOK);
729
730 /*
731 * unp_peercred management:
732 *
733 * The connecter's (client's) credentials are copied
734 * from its process structure at the time of connect()
735 * (which is now).
736 */

--- 793 unchanged lines hidden ---
733
734 /*
735 * unp_peercred management:
736 *
737 * The connecter's (client's) credentials are copied
738 * from its process structure at the time of connect()
739 * (which is now).
740 */

--- 793 unchanged lines hidden ---