1/*- 2 * Copyright (c) 2001 Brian Somers <brian@Awfulhak.org> 3 * 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 --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/usr.sbin/ppp/ncp.c 81897 2001-08-18 19:07:13Z brian $ |
27 */ 28 29#include <sys/param.h> 30#include <netinet/in_systm.h> 31#include <netinet/in.h> 32#include <netinet/ip.h> 33#include <arpa/inet.h> 34#include <sys/socket.h> --- 50 unchanged lines hidden (view full) --- 85#include "route.h" 86#include "iface.h" 87#include "chat.h" 88#include "auth.h" 89#include "chap.h" 90#include "pap.h" 91#include "cbcp.h" 92#include "datalink.h" |
93 94 95static u_short default_urgent_tcp_ports[] = { 96 21, /* ftp */ 97 22, /* ssh */ 98 23, /* telnet */ 99 513, /* login */ 100 514, /* shell */ --- 27 unchanged lines hidden (view full) --- 128 129 130 mp_Init(&ncp->mp, bundle); 131 132 /* Send over the first physical link by default */ 133 ipcp_Init(&ncp->ipcp, bundle, &bundle->links->physical->link, 134 &bundle->fsm); 135#ifndef NOINET6 |
136 ipv6cp_Init(&ncp->ipv6cp, bundle, &bundle->links->physical->link, 137 &bundle->fsm); |
138#endif 139} 140 141void 142ncp_Destroy(struct ncp *ncp) 143{ 144 ipcp_Destroy(&ncp->ipcp); 145#ifndef NOINET6 |
146 ipv6cp_Destroy(&ncp->ipv6cp); |
147#endif 148 149 if (ncp->cfg.urgent.tcp.maxports) { 150 ncp->cfg.urgent.tcp.nports = ncp->cfg.urgent.tcp.maxports = 0; 151 free(ncp->cfg.urgent.tcp.port); 152 ncp->cfg.urgent.tcp.port = NULL; 153 } 154 if (ncp->cfg.urgent.udp.maxports) { --- 12 unchanged lines hidden (view full) --- 167 if (Enabled(bundle, OPT_IPCP)) { 168#endif 169 fsm_Up(&ncp->ipcp.fsm); 170 fsm_Open(&ncp->ipcp.fsm); 171 res++; 172#ifndef NOINET6 173 } 174 |
175 if (Enabled(bundle, OPT_IPV6CP)) { |
176 fsm_Up(&ncp->ipv6cp.fsm); 177 fsm_Open(&ncp->ipv6cp.fsm); 178 res++; 179 } 180#endif 181 182 return res; 183} --- 20 unchanged lines hidden (view full) --- 204 ipcp_IfaceAddrDeleted(&ncp->ipcp, addr); 205} 206 207void 208ncp_SetLink(struct ncp *ncp, struct link *l) 209{ 210 ipcp_SetLink(&ncp->ipcp, l); 211#ifndef NOINET6 |
212 ipv6cp_SetLink(&ncp->ipv6cp, l); |
213#endif 214} 215 216/* 217 * Enqueue a packet of the given address family. Nothing will make it 218 * down to the physical link level 'till ncp_FillPhysicalQueues() is used. 219 */ 220void --- 51 unchanged lines hidden (view full) --- 272 */ 273size_t 274ncp_QueueLen(struct ncp *ncp) 275{ 276 size_t result; 277 278 result = ipcp_QueueLen(&ncp->ipcp); 279#ifndef NOINET6 |
280 result += ipv6cp_QueueLen(&ncp->ipv6cp); |
281#endif 282 result += mp_QueueLen(&ncp->mp); /* Usually empty */ 283 284 return result; 285} 286 287/* 288 * Ditch all queued packets. This is usually done after our choked timer --- 10 unchanged lines hidden (view full) --- 299 struct mp *mp = &ncp->mp; 300 struct mqueue *q; 301 302 for (q = ipcp->Queue; q < ipcp->Queue + IPCP_QUEUES(ipcp); q++) 303 while (q->top) 304 m_freem(m_dequeue(q)); 305 306#ifndef NOINET6 |
307 for (q = ipv6cp->Queue; q < ipv6cp->Queue + IPV6CP_QUEUES(ipv6cp); q++) 308 while (q->top) 309 m_freem(m_dequeue(q)); |
310#endif 311 312 link_DeleteQueue(&mp->link); /* Usually empty anyway */ 313} 314 315/* 316 * Arrange that each of our links has at least one packet. We keep the 317 * number of packets queued at the link level to a minimum so that the --- 29 unchanged lines hidden (view full) --- 347 */ 348int 349ncp_PushPacket(struct ncp *ncp, int *af, struct link *l) 350{ 351 struct bundle *bundle = l->lcp.fsm.bundle; 352 int res; 353 354#ifndef NOINET6 |
355 if (*af == AF_INET) { |
356 if ((res = ipcp_PushPacket(&bundle->ncp.ipcp, l))) 357 *af = AF_INET6; 358 else 359 res = ipv6cp_PushPacket(&bundle->ncp.ipv6cp, l); 360 } else { 361 if ((res = ipv6cp_PushPacket(&bundle->ncp.ipv6cp, l))) 362 *af = AF_INET; 363 else --- 79 unchanged lines hidden (view full) --- 443 444int 445ncp_Show(struct cmdargs const *arg) 446{ 447 struct ncp *ncp = &arg->bundle->ncp; 448 int p; 449 450#ifndef NOINET6 |
451 prompt_Printf(arg->prompt, "Next queued AF: %s\n", 452 ncp->afq == AF_INET6 ? "inet6" : "inet"); |
453#endif 454 455 if (ncp->route) { 456 prompt_Printf(arg->prompt, "\n"); 457 route_ShowSticky(arg->prompt, ncp->route, "Sticky routes", 1); 458 } 459 460 prompt_Printf(arg->prompt, "\nDefaults:\n"); --- 36 unchanged lines hidden (view full) --- 497 498int 499ncp_LayersOpen(struct ncp *ncp) 500{ 501 int n; 502 503 n = !!(ncp->ipcp.fsm.state == ST_OPENED); 504#ifndef NOINET6 |
505 n += !!(ncp->ipv6cp.fsm.state == ST_OPENED); |
506#endif 507 508 return n; 509} 510 511int 512ncp_LayersUnfinished(struct ncp *ncp) 513{ 514 int n = 0; 515 516 if (ncp->ipcp.fsm.state > ST_CLOSED || 517 ncp->ipcp.fsm.state == ST_STARTING) 518 n++; 519 520#ifndef NOINET6 |
521 if (ncp->ipv6cp.fsm.state > ST_CLOSED || 522 ncp->ipv6cp.fsm.state == ST_STARTING) 523 n++; |
524#endif 525 526 return n; 527} 528 529void 530ncp_Close(struct ncp *ncp) 531{ 532 if (ncp->ipcp.fsm.state > ST_CLOSED || 533 ncp->ipcp.fsm.state == ST_STARTING) 534 fsm_Close(&ncp->ipcp.fsm); 535 536#ifndef NOINET6 |
537 if (ncp->ipv6cp.fsm.state > ST_CLOSED || 538 ncp->ipv6cp.fsm.state == ST_STARTING) 539 fsm_Close(&ncp->ipv6cp.fsm); |
540#endif 541} 542 543void 544ncp2initial(struct ncp *ncp) 545{ 546 fsm2initial(&ncp->ipcp.fsm); 547#ifndef NOINET6 |
548 fsm2initial(&ncp->ipv6cp.fsm); |
549#endif 550} |