ng_l2tp.c (180943) | ng_l2tp.c (184205) |
---|---|
1/*- 2 * Copyright (c) 2001-2002 Packet Design, LLC. 3 * All rights reserved. 4 * 5 * Subject to the following obligations and disclaimer of warranty, 6 * use and redistribution of this software, in source or object code 7 * forms, with or without modifications are expressly permitted by 8 * Packet Design; provided, however, that: --- 22 unchanged lines hidden (view full) --- 31 * USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY THEORY OF 32 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 34 * THE USE OF THIS SOFTWARE, EVEN IF PACKET DESIGN IS ADVISED OF 35 * THE POSSIBILITY OF SUCH DAMAGE. 36 * 37 * Author: Archie Cobbs <archie@freebsd.org> 38 * | 1/*- 2 * Copyright (c) 2001-2002 Packet Design, LLC. 3 * All rights reserved. 4 * 5 * Subject to the following obligations and disclaimer of warranty, 6 * use and redistribution of this software, in source or object code 7 * forms, with or without modifications are expressly permitted by 8 * Packet Design; provided, however, that: --- 22 unchanged lines hidden (view full) --- 31 * USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY THEORY OF 32 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 34 * THE USE OF THIS SOFTWARE, EVEN IF PACKET DESIGN IS ADVISED OF 35 * THE POSSIBILITY OF SUCH DAMAGE. 36 * 37 * Author: Archie Cobbs <archie@freebsd.org> 38 * |
39 * $FreeBSD: head/sys/netgraph/ng_l2tp.c 180943 2008-07-28 22:22:38Z mav $ | 39 * $FreeBSD: head/sys/netgraph/ng_l2tp.c 184205 2008-10-23 15:53:51Z des $ |
40 */ 41 42/* 43 * L2TP netgraph node type. 44 * 45 * This node type implements the lower layer of the 46 * L2TP protocol as specified in RFC 2661. 47 */ --- 311 unchanged lines hidden (view full) --- 359 */ 360static int 361ng_l2tp_constructor(node_p node) 362{ 363 priv_p priv; 364 int i; 365 366 /* Allocate private structure */ | 40 */ 41 42/* 43 * L2TP netgraph node type. 44 * 45 * This node type implements the lower layer of the 46 * L2TP protocol as specified in RFC 2661. 47 */ --- 311 unchanged lines hidden (view full) --- 359 */ 360static int 361ng_l2tp_constructor(node_p node) 362{ 363 priv_p priv; 364 int i; 365 366 /* Allocate private structure */ |
367 MALLOC(priv, priv_p, sizeof(*priv), M_NETGRAPH_L2TP, M_NOWAIT | M_ZERO); | 367 priv = malloc(sizeof(*priv), M_NETGRAPH_L2TP, M_NOWAIT | M_ZERO); |
368 if (priv == NULL) 369 return (ENOMEM); 370 NG_NODE_SET_PRIVATE(node, priv); 371 priv->node = node; 372 373 /* Apply a semi-reasonable default configuration */ 374 priv->conf.peer_win = 1; 375 priv->conf.rexmit_max = L2TP_MAX_REXMIT; --- 47 unchanged lines hidden (view full) --- 423 if (j == 16) 424 return (EINVAL); 425 session_id = (session_id << 4) | j; 426 } 427 if (hex[i] != '\0') 428 return (EINVAL); 429 430 /* Create hook private structure */ | 368 if (priv == NULL) 369 return (ENOMEM); 370 NG_NODE_SET_PRIVATE(node, priv); 371 priv->node = node; 372 373 /* Apply a semi-reasonable default configuration */ 374 priv->conf.peer_win = 1; 375 priv->conf.rexmit_max = L2TP_MAX_REXMIT; --- 47 unchanged lines hidden (view full) --- 423 if (j == 16) 424 return (EINVAL); 425 session_id = (session_id << 4) | j; 426 } 427 if (hex[i] != '\0') 428 return (EINVAL); 429 430 /* Create hook private structure */ |
431 MALLOC(hpriv, hookpriv_p, 432 sizeof(*hpriv), M_NETGRAPH_L2TP, M_NOWAIT | M_ZERO); | 431 hpriv = malloc( sizeof(*hpriv), M_NETGRAPH_L2TP, M_NOWAIT | M_ZERO); |
433 if (hpriv == NULL) 434 return (ENOMEM); 435 hpriv->conf.session_id = session_id; 436 hpriv->conf.control_dseq = L2TP_CONTROL_DSEQ; 437 hpriv->conf.enable_dseq = L2TP_ENABLE_DSEQ; 438 hpriv->hook = hook; 439 NG_HOOK_SET_PRIVATE(hook, hpriv); 440 hash = SESSHASH(hpriv->conf.session_id); --- 221 unchanged lines hidden (view full) --- 662 ng_l2tp_seq_reset(priv); 663 664 /* Free private data if neither timer is running */ 665 ng_uncallout(&seq->rack_timer, node); 666 ng_uncallout(&seq->xack_timer, node); 667 668 mtx_destroy(&seq->mtx); 669 | 432 if (hpriv == NULL) 433 return (ENOMEM); 434 hpriv->conf.session_id = session_id; 435 hpriv->conf.control_dseq = L2TP_CONTROL_DSEQ; 436 hpriv->conf.enable_dseq = L2TP_ENABLE_DSEQ; 437 hpriv->hook = hook; 438 NG_HOOK_SET_PRIVATE(hook, hpriv); 439 hash = SESSHASH(hpriv->conf.session_id); --- 221 unchanged lines hidden (view full) --- 661 ng_l2tp_seq_reset(priv); 662 663 /* Free private data if neither timer is running */ 664 ng_uncallout(&seq->rack_timer, node); 665 ng_uncallout(&seq->xack_timer, node); 666 667 mtx_destroy(&seq->mtx); 668 |
670 FREE(priv, M_NETGRAPH_L2TP); | 669 free(priv, M_NETGRAPH_L2TP); |
671 672 /* Unref node */ 673 NG_NODE_UNREF(node); 674 return (0); 675} 676 677/* 678 * Hook disconnection --- 7 unchanged lines hidden (view full) --- 686 /* Zero out hook pointer */ 687 if (hook == priv->ctrl) 688 priv->ctrl = NULL; 689 else if (hook == priv->lower) 690 priv->lower = NULL; 691 else { 692 const hookpriv_p hpriv = NG_HOOK_PRIVATE(hook); 693 LIST_REMOVE(hpriv, sessions); | 670 671 /* Unref node */ 672 NG_NODE_UNREF(node); 673 return (0); 674} 675 676/* 677 * Hook disconnection --- 7 unchanged lines hidden (view full) --- 685 /* Zero out hook pointer */ 686 if (hook == priv->ctrl) 687 priv->ctrl = NULL; 688 else if (hook == priv->lower) 689 priv->lower = NULL; 690 else { 691 const hookpriv_p hpriv = NG_HOOK_PRIVATE(hook); 692 LIST_REMOVE(hpriv, sessions); |
694 FREE(hpriv, M_NETGRAPH_L2TP); | 693 free(hpriv, M_NETGRAPH_L2TP); |
695 NG_HOOK_SET_PRIVATE(hook, NULL); 696 } 697 698 /* Go away if no longer connected to anything */ 699 if (NG_NODE_NUMHOOKS(node) == 0 && NG_NODE_IS_VALID(node)) 700 ng_rmnode_self(node); 701 return (0); 702} --- 899 unchanged lines hidden --- | 694 NG_HOOK_SET_PRIVATE(hook, NULL); 695 } 696 697 /* Go away if no longer connected to anything */ 698 if (NG_NODE_NUMHOOKS(node) == 0 && NG_NODE_IS_VALID(node)) 699 ng_rmnode_self(node); 700 return (0); 701} --- 899 unchanged lines hidden --- |