1/*- 2 * Copyright (c) 1982, 1986, 1989, 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * sendfile(2) and related extensions: 6 * Copyright (c) 1998, David Greenman. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 19 unchanged lines hidden (view full) --- 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 * @(#)uipc_syscalls.c 8.4 (Berkeley) 2/21/94 33 */ 34 35#include <sys/cdefs.h> |
36__FBSDID("$FreeBSD: head/sys/kern/uipc_syscalls.c 169624 2007-05-16 20:41:08Z rwatson $"); |
37 38#include "opt_sctp.h" 39#include "opt_compat.h" 40#include "opt_ktrace.h" 41#include "opt_mac.h" 42 43#include <sys/param.h> 44#include <sys/systm.h> --- 103 unchanged lines hidden (view full) --- 148 */ 149#if defined(COMPAT_43) 150#define COMPAT_OLDSOCK 151#endif 152 153int 154socket(td, uap) 155 struct thread *td; |
156 struct socket_args /* { |
157 int domain; 158 int type; 159 int protocol; 160 } */ *uap; 161{ 162 struct filedesc *fdp; 163 struct socket *so; 164 struct file *fp; --- 28 unchanged lines hidden (view full) --- 193 fdrop(fp, td); 194 return (error); 195} 196 197/* ARGSUSED */ 198int 199bind(td, uap) 200 struct thread *td; |
201 struct bind_args /* { |
202 int s; 203 caddr_t name; 204 int namelen; 205 } */ *uap; 206{ 207 struct sockaddr *sa; 208 int error; 209 --- 36 unchanged lines hidden (view full) --- 246 NET_UNLOCK_GIANT(); 247 return (error); 248} 249 250/* ARGSUSED */ 251int 252listen(td, uap) 253 struct thread *td; |
254 struct listen_args /* { |
255 int s; 256 int backlog; 257 } */ *uap; 258{ 259 struct socket *so; 260 struct file *fp; 261 int error; 262 --- 19 unchanged lines hidden (view full) --- 282} 283 284/* 285 * accept1() 286 */ 287static int 288accept1(td, uap, compat) 289 struct thread *td; |
290 struct accept_args /* { |
291 int s; 292 struct sockaddr * __restrict name; 293 socklen_t * __restrict anamelen; 294 } */ *uap; 295 int compat; 296{ 297 struct sockaddr *name; 298 socklen_t namelen; --- 216 unchanged lines hidden (view full) --- 515 return (accept1(td, uap, 1)); 516} 517#endif /* COMPAT_OLDSOCK */ 518 519/* ARGSUSED */ 520int 521connect(td, uap) 522 struct thread *td; |
523 struct connect_args /* { |
524 int s; 525 caddr_t name; 526 int namelen; 527 } */ *uap; 528{ 529 struct sockaddr *sa; 530 int error; 531 --- 66 unchanged lines hidden (view full) --- 598done2: 599 NET_UNLOCK_GIANT(); 600 return (error); 601} 602 603int 604socketpair(td, uap) 605 struct thread *td; |
606 struct socketpair_args /* { |
607 int domain; 608 int type; 609 int protocol; 610 int *rsv; 611 } */ *uap; 612{ |
613 struct filedesc *fdp = td->td_proc->p_fd; |
614 struct file *fp1, *fp2; 615 struct socket *so1, *so2; 616 int fd, error, sv[2]; 617 618#ifdef MAC 619 /* We might want to have a separate check for socket pairs. */ 620 error = mac_check_socket_create(td->td_ucred, uap->domain, uap->type, 621 uap->protocol); --- 63 unchanged lines hidden (view full) --- 685 (void)soclose(so1); 686done2: 687 NET_UNLOCK_GIANT(); 688 return (error); 689} 690 691static int 692sendit(td, s, mp, flags) |
693 struct thread *td; |
694 int s; |
695 struct msghdr *mp; |
696 int flags; 697{ 698 struct mbuf *control; 699 struct sockaddr *to; 700 int error; 701 702 if (mp->msg_name != NULL) { 703 error = getsockaddr(&to, mp->msg_name, mp->msg_namelen); --- 16 unchanged lines hidden (view full) --- 720 goto bad; 721 } 722 error = sockargs(&control, mp->msg_control, 723 mp->msg_controllen, MT_CONTROL); 724 if (error) 725 goto bad; 726#ifdef COMPAT_OLDSOCK 727 if (mp->msg_flags == MSG_COMPAT) { |
728 struct cmsghdr *cm; |
729 730 M_PREPEND(control, sizeof(*cm), M_TRYWAIT); 731 if (control == 0) { 732 error = ENOBUFS; 733 goto bad; 734 } else { 735 cm = mtod(control, struct cmsghdr *); 736 cm->cmsg_len = control->m_len; --- 92 unchanged lines hidden (view full) --- 829bad2: 830 NET_UNLOCK_GIANT(); 831 return (error); 832} 833 834int 835sendto(td, uap) 836 struct thread *td; |
837 struct sendto_args /* { |
838 int s; 839 caddr_t buf; 840 size_t len; 841 int flags; 842 caddr_t to; 843 int tolen; 844 } */ *uap; 845{ --- 14 unchanged lines hidden (view full) --- 860 error = sendit(td, uap->s, &msg, uap->flags); 861 return (error); 862} 863 864#ifdef COMPAT_OLDSOCK 865int 866osend(td, uap) 867 struct thread *td; |
868 struct osend_args /* { |
869 int s; 870 caddr_t buf; 871 int len; 872 int flags; 873 } */ *uap; 874{ 875 struct msghdr msg; 876 struct iovec aiov; --- 249 unchanged lines hidden (view full) --- 1126#endif 1127 } 1128 return (error); 1129} 1130 1131int 1132recvfrom(td, uap) 1133 struct thread *td; |
1134 struct recvfrom_args /* { |
1135 int s; 1136 caddr_t buf; 1137 size_t len; 1138 int flags; 1139 struct sockaddr * __restrict from; 1140 socklen_t * __restrict fromlenaddr; 1141 } */ *uap; 1142{ --- 32 unchanged lines hidden (view full) --- 1175 return (recvfrom(td, uap)); 1176} 1177#endif 1178 1179#ifdef COMPAT_OLDSOCK 1180int 1181orecv(td, uap) 1182 struct thread *td; |
1183 struct orecv_args /* { |
1184 int s; 1185 caddr_t buf; 1186 int len; 1187 int flags; 1188 } */ *uap; 1189{ 1190 struct msghdr msg; 1191 struct iovec aiov; --- 79 unchanged lines hidden (view full) --- 1271 free(iov, M_IOV); 1272 return (error); 1273} 1274 1275/* ARGSUSED */ 1276int 1277shutdown(td, uap) 1278 struct thread *td; |
1279 struct shutdown_args /* { |
1280 int s; 1281 int how; 1282 } */ *uap; 1283{ 1284 struct socket *so; 1285 struct file *fp; 1286 int error; 1287 --- 7 unchanged lines hidden (view full) --- 1295 NET_UNLOCK_GIANT(); 1296 return (error); 1297} 1298 1299/* ARGSUSED */ 1300int 1301setsockopt(td, uap) 1302 struct thread *td; |
1303 struct setsockopt_args /* { |
1304 int s; 1305 int level; 1306 int name; 1307 caddr_t val; 1308 int valsize; 1309 } */ *uap; 1310{ 1311 --- 47 unchanged lines hidden (view full) --- 1359 NET_UNLOCK_GIANT(); 1360 return(error); 1361} 1362 1363/* ARGSUSED */ 1364int 1365getsockopt(td, uap) 1366 struct thread *td; |
1367 struct getsockopt_args /* { |
1368 int s; 1369 int level; 1370 int name; 1371 void * __restrict val; 1372 socklen_t * __restrict avalsize; 1373 } */ *uap; 1374{ 1375 socklen_t valsize; --- 67 unchanged lines hidden (view full) --- 1443 1444/* 1445 * getsockname1() - Get socket name. 1446 */ 1447/* ARGSUSED */ 1448static int 1449getsockname1(td, uap, compat) 1450 struct thread *td; |
1451 struct getsockname_args /* { |
1452 int fdes; 1453 struct sockaddr * __restrict asa; 1454 socklen_t * __restrict alen; 1455 } */ *uap; 1456 int compat; 1457{ 1458 struct sockaddr *sa; 1459 socklen_t len; --- 79 unchanged lines hidden (view full) --- 1539 1540/* 1541 * getpeername1() - Get name of peer for connected socket. 1542 */ 1543/* ARGSUSED */ 1544static int 1545getpeername1(td, uap, compat) 1546 struct thread *td; |
1547 struct getpeername_args /* { |
1548 int fdes; 1549 struct sockaddr * __restrict asa; 1550 socklen_t * __restrict alen; 1551 } */ *uap; 1552 int compat; 1553{ 1554 struct sockaddr *sa; 1555 socklen_t len; --- 84 unchanged lines hidden (view full) --- 1640#endif /* COMPAT_OLDSOCK */ 1641 1642int 1643sockargs(mp, buf, buflen, type) 1644 struct mbuf **mp; 1645 caddr_t buf; 1646 int buflen, type; 1647{ |
1648 struct sockaddr *sa; 1649 struct mbuf *m; |
1650 int error; 1651 1652 if ((u_int)buflen > MLEN) { 1653#ifdef COMPAT_OLDSOCK 1654 if (type == MT_SONAME && (u_int)buflen <= 112) 1655 buflen = MLEN; /* unix domain compat. hack */ 1656 else 1657#endif --- 1011 unchanged lines hidden --- |