uipc_sockbuf.c (169236) | uipc_sockbuf.c (169624) |
---|---|
1/*- 2 * Copyright (c) 1982, 1986, 1988, 1990, 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 --- 16 unchanged lines hidden (view full) --- 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * @(#)uipc_socket2.c 8.1 (Berkeley) 6/10/93 30 */ 31 32#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1982, 1986, 1988, 1990, 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 --- 16 unchanged lines hidden (view full) --- 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * @(#)uipc_socket2.c 8.1 (Berkeley) 6/10/93 30 */ 31 32#include <sys/cdefs.h> |
33__FBSDID("$FreeBSD: head/sys/kern/uipc_sockbuf.c 169236 2007-05-03 14:42:42Z rwatson $"); | 33__FBSDID("$FreeBSD: head/sys/kern/uipc_sockbuf.c 169624 2007-05-16 20:41:08Z rwatson $"); |
34 35#include "opt_param.h" 36 37#include <sys/param.h> 38#include <sys/aio.h> /* for aio_swake proto */ 39#include <sys/kernel.h> 40#include <sys/lock.h> 41#include <sys/mbuf.h> --- 302 unchanged lines hidden (view full) --- 344 345void 346sbdestroy(struct sockbuf *sb, struct socket *so) 347{ 348 349 sbrelease_internal(sb, so); 350} 351 | 34 35#include "opt_param.h" 36 37#include <sys/param.h> 38#include <sys/aio.h> /* for aio_swake proto */ 39#include <sys/kernel.h> 40#include <sys/lock.h> 41#include <sys/mbuf.h> --- 302 unchanged lines hidden (view full) --- 344 345void 346sbdestroy(struct sockbuf *sb, struct socket *so) 347{ 348 349 sbrelease_internal(sb, so); 350} 351 |
352 | |
353/* 354 * Routines to add and remove data from an mbuf queue. 355 * 356 * The routines sbappend() or sbappendrecord() are normally called to append 357 * new mbufs to a socket buffer, after checking that adequate space is 358 * available, comparing the function sbspace() with the amount of data to be 359 * added. sbappendrecord() differs from sbappend() in that data supplied is 360 * treated as the beginning of a new record. To place a sender's address, --- 536 unchanged lines hidden (view full) --- 897sbdrop(struct sockbuf *sb, int len) 898{ 899 900 SOCKBUF_LOCK(sb); 901 sbdrop_locked(sb, len); 902 SOCKBUF_UNLOCK(sb); 903} 904 | 352/* 353 * Routines to add and remove data from an mbuf queue. 354 * 355 * The routines sbappend() or sbappendrecord() are normally called to append 356 * new mbufs to a socket buffer, after checking that adequate space is 357 * available, comparing the function sbspace() with the amount of data to be 358 * added. sbappendrecord() differs from sbappend() in that data supplied is 359 * treated as the beginning of a new record. To place a sender's address, --- 536 unchanged lines hidden (view full) --- 896sbdrop(struct sockbuf *sb, int len) 897{ 898 899 SOCKBUF_LOCK(sb); 900 sbdrop_locked(sb, len); 901 SOCKBUF_UNLOCK(sb); 902} 903 |
905 | |
906/* 907 * Maintain a pointer and offset pair into the socket buffer mbuf chain to 908 * avoid traversal of the entire socket buffer for larger offsets. 909 */ 910struct mbuf * 911sbsndptr(struct sockbuf *sb, u_int off, u_int len, u_int *moff) 912{ 913 struct mbuf *m, *ret; --- 62 unchanged lines hidden (view full) --- 976 SOCKBUF_UNLOCK(sb); 977} 978 979/* 980 * Create a "control" mbuf containing the specified data with the specified 981 * type for presentation on a socket buffer. 982 */ 983struct mbuf * | 904/* 905 * Maintain a pointer and offset pair into the socket buffer mbuf chain to 906 * avoid traversal of the entire socket buffer for larger offsets. 907 */ 908struct mbuf * 909sbsndptr(struct sockbuf *sb, u_int off, u_int len, u_int *moff) 910{ 911 struct mbuf *m, *ret; --- 62 unchanged lines hidden (view full) --- 974 SOCKBUF_UNLOCK(sb); 975} 976 977/* 978 * Create a "control" mbuf containing the specified data with the specified 979 * type for presentation on a socket buffer. 980 */ 981struct mbuf * |
984sbcreatecontrol(p, size, type, level) 985 caddr_t p; 986 register int size; 987 int type, level; | 982sbcreatecontrol(caddr_t p, int size, int type, int level) |
988{ | 983{ |
989 register struct cmsghdr *cp; | 984 struct cmsghdr *cp; |
990 struct mbuf *m; 991 992 if (CMSG_SPACE((u_int)size) > MCLBYTES) 993 return ((struct mbuf *) NULL); 994 if (CMSG_SPACE((u_int)size) > MLEN) 995 m = m_getcl(M_DONTWAIT, MT_CONTROL, 0); 996 else 997 m = m_get(M_DONTWAIT, MT_CONTROL); --- 17 unchanged lines hidden (view full) --- 1015 * generate an user-format data structure describing the socket buffer. Note 1016 * that the xsockbuf structure, since it is always embedded in a socket, does 1017 * not include a self pointer nor a length. We make this entry point public 1018 * in case some other mechanism needs it. 1019 */ 1020void 1021sbtoxsockbuf(struct sockbuf *sb, struct xsockbuf *xsb) 1022{ | 985 struct mbuf *m; 986 987 if (CMSG_SPACE((u_int)size) > MCLBYTES) 988 return ((struct mbuf *) NULL); 989 if (CMSG_SPACE((u_int)size) > MLEN) 990 m = m_getcl(M_DONTWAIT, MT_CONTROL, 0); 991 else 992 m = m_get(M_DONTWAIT, MT_CONTROL); --- 17 unchanged lines hidden (view full) --- 1010 * generate an user-format data structure describing the socket buffer. Note 1011 * that the xsockbuf structure, since it is always embedded in a socket, does 1012 * not include a self pointer nor a length. We make this entry point public 1013 * in case some other mechanism needs it. 1014 */ 1015void 1016sbtoxsockbuf(struct sockbuf *sb, struct xsockbuf *xsb) 1017{ |
1018 |
|
1023 xsb->sb_cc = sb->sb_cc; 1024 xsb->sb_hiwat = sb->sb_hiwat; 1025 xsb->sb_mbcnt = sb->sb_mbcnt; 1026 xsb->sb_mbmax = sb->sb_mbmax; 1027 xsb->sb_lowat = sb->sb_lowat; 1028 xsb->sb_flags = sb->sb_flags; 1029 xsb->sb_timeo = sb->sb_timeo; 1030} 1031 1032/* This takes the place of kern.maxsockbuf, which moved to kern.ipc. */ 1033static int dummy; 1034SYSCTL_INT(_kern, KERN_DUMMY, dummy, CTLFLAG_RW, &dummy, 0, ""); 1035SYSCTL_OID(_kern_ipc, KIPC_MAXSOCKBUF, maxsockbuf, CTLTYPE_ULONG|CTLFLAG_RW, 1036 &sb_max, 0, sysctl_handle_sb_max, "LU", "Maximum socket buffer size"); 1037SYSCTL_ULONG(_kern_ipc, KIPC_SOCKBUF_WASTE, sockbuf_waste_factor, CTLFLAG_RW, 1038 &sb_efficiency, 0, ""); | 1019 xsb->sb_cc = sb->sb_cc; 1020 xsb->sb_hiwat = sb->sb_hiwat; 1021 xsb->sb_mbcnt = sb->sb_mbcnt; 1022 xsb->sb_mbmax = sb->sb_mbmax; 1023 xsb->sb_lowat = sb->sb_lowat; 1024 xsb->sb_flags = sb->sb_flags; 1025 xsb->sb_timeo = sb->sb_timeo; 1026} 1027 1028/* This takes the place of kern.maxsockbuf, which moved to kern.ipc. */ 1029static int dummy; 1030SYSCTL_INT(_kern, KERN_DUMMY, dummy, CTLFLAG_RW, &dummy, 0, ""); 1031SYSCTL_OID(_kern_ipc, KIPC_MAXSOCKBUF, maxsockbuf, CTLTYPE_ULONG|CTLFLAG_RW, 1032 &sb_max, 0, sysctl_handle_sb_max, "LU", "Maximum socket buffer size"); 1033SYSCTL_ULONG(_kern_ipc, KIPC_SOCKBUF_WASTE, sockbuf_waste_factor, CTLFLAG_RW, 1034 &sb_efficiency, 0, ""); |