Deleted Added
full compact
ng_socket.c (109153) ng_socket.c (109623)
1
2/*
3 * ng_socket.c
4 *
5 * Copyright (c) 1996-1999 Whistle Communications, Inc.
6 * All rights reserved.
7 *
8 * Subject to the following obligations and disclaimer of warranty, use and

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

31 * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
34 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
35 * OF SUCH DAMAGE.
36 *
37 * Author: Julian Elischer <julian@freebsd.org>
38 *
1
2/*
3 * ng_socket.c
4 *
5 * Copyright (c) 1996-1999 Whistle Communications, Inc.
6 * All rights reserved.
7 *
8 * Subject to the following obligations and disclaimer of warranty, use and

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

31 * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
34 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
35 * OF SUCH DAMAGE.
36 *
37 * Author: Julian Elischer <julian@freebsd.org>
38 *
39 * $FreeBSD: head/sys/netgraph/ng_socket.c 109153 2003-01-13 00:33:17Z dillon $
39 * $FreeBSD: head/sys/netgraph/ng_socket.c 109623 2003-01-21 08:56:16Z alfred $
40 * $Whistle: ng_socket.c,v 1.28 1999/11/01 09:24:52 julian Exp $
41 */
42
43/*
44 * Netgraph socket nodes
45 *
46 * There are two types of netgraph sockets, control and data.
47 * Control sockets have a netgraph node, but data sockets are

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

219 if (addr == NULL) {
220 error = EDESTADDRREQ;
221 goto release;
222 }
223
224 /* Allocate an expendable buffer for the path, chop off
225 * the sockaddr header, and make sure it's NUL terminated */
226 len = sap->sg_len - 2;
40 * $Whistle: ng_socket.c,v 1.28 1999/11/01 09:24:52 julian Exp $
41 */
42
43/*
44 * Netgraph socket nodes
45 *
46 * There are two types of netgraph sockets, control and data.
47 * Control sockets have a netgraph node, but data sockets are

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

219 if (addr == NULL) {
220 error = EDESTADDRREQ;
221 goto release;
222 }
223
224 /* Allocate an expendable buffer for the path, chop off
225 * the sockaddr header, and make sure it's NUL terminated */
226 len = sap->sg_len - 2;
227 MALLOC(path, char *, len + 1, M_NETGRAPH_PATH, M_WAITOK);
227 MALLOC(path, char *, len + 1, M_NETGRAPH_PATH, 0);
228 if (path == NULL) {
229 error = ENOMEM;
230 goto release;
231 }
232 bcopy(sap->sg_data, path, len);
233 path[len] = '\0';
234
235 /* Move the actual message out of mbufs into a linear buffer.
236 * Start by adding up the size of the data. (could use mh_len?) */
237 for (len = 0, m0 = m; m0 != NULL; m0 = m0->m_next)
238 len += m0->m_len;
239
240 /* Move the data into a linear buffer as well. Messages are not
241 * delivered in mbufs. */
228 if (path == NULL) {
229 error = ENOMEM;
230 goto release;
231 }
232 bcopy(sap->sg_data, path, len);
233 path[len] = '\0';
234
235 /* Move the actual message out of mbufs into a linear buffer.
236 * Start by adding up the size of the data. (could use mh_len?) */
237 for (len = 0, m0 = m; m0 != NULL; m0 = m0->m_next)
238 len += m0->m_len;
239
240 /* Move the data into a linear buffer as well. Messages are not
241 * delivered in mbufs. */
242 MALLOC(msg, struct ng_mesg *, len + 1, M_NETGRAPH_MSG, M_WAITOK);
242 MALLOC(msg, struct ng_mesg *, len + 1, M_NETGRAPH_MSG, 0);
243 if (msg == NULL) {
244 error = ENOMEM;
245 goto release;
246 }
247 m_copydata(m, 0, len, (char *)msg);
248
249#ifdef TRACE_MESSAGES
250 do {

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

432 splx(s);
433 return (EINVAL);
434 }
435
436 namelen = 0; /* silence compiler ! */
437 if ( NG_NODE_HAS_NAME(pcbp->sockdata->node))
438 sg_len += namelen = strlen(NG_NODE_NAME(pcbp->sockdata->node));
439
243 if (msg == NULL) {
244 error = ENOMEM;
245 goto release;
246 }
247 m_copydata(m, 0, len, (char *)msg);
248
249#ifdef TRACE_MESSAGES
250 do {

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

432 splx(s);
433 return (EINVAL);
434 }
435
436 namelen = 0; /* silence compiler ! */
437 if ( NG_NODE_HAS_NAME(pcbp->sockdata->node))
438 sg_len += namelen = strlen(NG_NODE_NAME(pcbp->sockdata->node));
439
440 MALLOC(sg, struct sockaddr_ng *, sg_len, M_SONAME, M_WAITOK | M_ZERO);
440 MALLOC(sg, struct sockaddr_ng *, sg_len, M_SONAME, M_ZERO);
441
442 if (NG_NODE_HAS_NAME(pcbp->sockdata->node))
443 bcopy(NG_NODE_NAME(pcbp->sockdata->node), sg->sg_data, namelen);
444 splx(s);
445
446 sg->sg_len = sg_len;
447 sg->sg_family = AF_NETGRAPH;
448 *addr = (struct sockaddr *)sg;

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

465
466 /* Setup protocol control block */
467 if ((error = ng_attach_common(so, NG_CONTROL)) != 0)
468 return (error);
469 pcbp = sotongpcb(so);
470
471 /* Allocate node private info */
472 MALLOC(privdata, struct ngsock *,
441
442 if (NG_NODE_HAS_NAME(pcbp->sockdata->node))
443 bcopy(NG_NODE_NAME(pcbp->sockdata->node), sg->sg_data, namelen);
444 splx(s);
445
446 sg->sg_len = sg_len;
447 sg->sg_family = AF_NETGRAPH;
448 *addr = (struct sockaddr *)sg;

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

465
466 /* Setup protocol control block */
467 if ((error = ng_attach_common(so, NG_CONTROL)) != 0)
468 return (error);
469 pcbp = sotongpcb(so);
470
471 /* Allocate node private info */
472 MALLOC(privdata, struct ngsock *,
473 sizeof(*privdata), M_NETGRAPH_SOCK, M_WAITOK | M_ZERO);
473 sizeof(*privdata), M_NETGRAPH_SOCK, M_ZERO);
474 if (privdata == NULL) {
475 ng_detach_common(pcbp, NG_CONTROL);
476 return (ENOMEM);
477 }
478
479 /* Make the generic node components */
480 if ((error = ng_make_node_common(&typestruct, &privdata->node)) != 0) {
481 FREE(privdata, M_NETGRAPH_SOCK);

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

508 int error;
509
510 /* Standard socket setup stuff */
511 error = soreserve(so, ngpdg_sendspace, ngpdg_recvspace);
512 if (error)
513 return (error);
514
515 /* Allocate the pcb */
474 if (privdata == NULL) {
475 ng_detach_common(pcbp, NG_CONTROL);
476 return (ENOMEM);
477 }
478
479 /* Make the generic node components */
480 if ((error = ng_make_node_common(&typestruct, &privdata->node)) != 0) {
481 FREE(privdata, M_NETGRAPH_SOCK);

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

508 int error;
509
510 /* Standard socket setup stuff */
511 error = soreserve(so, ngpdg_sendspace, ngpdg_recvspace);
512 if (error)
513 return (error);
514
515 /* Allocate the pcb */
516 MALLOC(pcbp, struct ngpcb *, sizeof(*pcbp), M_PCB, M_WAITOK | M_ZERO);
516 MALLOC(pcbp, struct ngpcb *, sizeof(*pcbp), M_PCB, M_ZERO);
517 if (pcbp == NULL)
518 return (ENOMEM);
519 pcbp->type = type;
520
521 /* Link the pcb and the socket */
522 so->so_pcb = (caddr_t) pcbp;
523 pcbp->ng_socket = so;
524

--- 570 unchanged lines hidden ---
517 if (pcbp == NULL)
518 return (ENOMEM);
519 pcbp->type = type;
520
521 /* Link the pcb and the socket */
522 so->so_pcb = (caddr_t) pcbp;
523 pcbp->ng_socket = so;
524

--- 570 unchanged lines hidden ---