Deleted Added
sdiff udiff text old ( 81888 ) new ( 81897 )
full compact
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 81888 2001-08-18 13:04:52Z 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#include "probe.h"
94
95
96static u_short default_urgent_tcp_ports[] = {
97 21, /* ftp */
98 22, /* ssh */
99 23, /* telnet */
100 513, /* login */
101 514, /* shell */

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

129
130
131 mp_Init(&ncp->mp, bundle);
132
133 /* Send over the first physical link by default */
134 ipcp_Init(&ncp->ipcp, bundle, &bundle->links->physical->link,
135 &bundle->fsm);
136#ifndef NOINET6
137 if (probe.ipv6_available)
138 ipv6cp_Init(&ncp->ipv6cp, bundle, &bundle->links->physical->link,
139 &bundle->fsm);
140#endif
141}
142
143void
144ncp_Destroy(struct ncp *ncp)
145{
146 ipcp_Destroy(&ncp->ipcp);
147#ifndef NOINET6
148 if (probe.ipv6_available)
149 ipv6cp_Destroy(&ncp->ipv6cp);
150#endif
151
152 if (ncp->cfg.urgent.tcp.maxports) {
153 ncp->cfg.urgent.tcp.nports = ncp->cfg.urgent.tcp.maxports = 0;
154 free(ncp->cfg.urgent.tcp.port);
155 ncp->cfg.urgent.tcp.port = NULL;
156 }
157 if (ncp->cfg.urgent.udp.maxports) {

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

170 if (Enabled(bundle, OPT_IPCP)) {
171#endif
172 fsm_Up(&ncp->ipcp.fsm);
173 fsm_Open(&ncp->ipcp.fsm);
174 res++;
175#ifndef NOINET6
176 }
177
178 if (probe.ipv6_available && Enabled(bundle, OPT_IPV6CP)) {
179 fsm_Up(&ncp->ipv6cp.fsm);
180 fsm_Open(&ncp->ipv6cp.fsm);
181 res++;
182 }
183#endif
184
185 return res;
186}

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

207 ipcp_IfaceAddrDeleted(&ncp->ipcp, addr);
208}
209
210void
211ncp_SetLink(struct ncp *ncp, struct link *l)
212{
213 ipcp_SetLink(&ncp->ipcp, l);
214#ifndef NOINET6
215 if (probe.ipv6_available)
216 ipv6cp_SetLink(&ncp->ipv6cp, l);
217#endif
218}
219
220/*
221 * Enqueue a packet of the given address family. Nothing will make it
222 * down to the physical link level 'till ncp_FillPhysicalQueues() is used.
223 */
224void

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

276 */
277size_t
278ncp_QueueLen(struct ncp *ncp)
279{
280 size_t result;
281
282 result = ipcp_QueueLen(&ncp->ipcp);
283#ifndef NOINET6
284 if (probe.ipv6_available)
285 result += ipv6cp_QueueLen(&ncp->ipv6cp);
286#endif
287 result += mp_QueueLen(&ncp->mp); /* Usually empty */
288
289 return result;
290}
291
292/*
293 * Ditch all queued packets. This is usually done after our choked timer

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

304 struct mp *mp = &ncp->mp;
305 struct mqueue *q;
306
307 for (q = ipcp->Queue; q < ipcp->Queue + IPCP_QUEUES(ipcp); q++)
308 while (q->top)
309 m_freem(m_dequeue(q));
310
311#ifndef NOINET6
312 if (probe.ipv6_available)
313 for (q = ipv6cp->Queue; q < ipv6cp->Queue + IPV6CP_QUEUES(ipv6cp); q++)
314 while (q->top)
315 m_freem(m_dequeue(q));
316#endif
317
318 link_DeleteQueue(&mp->link); /* Usually empty anyway */
319}
320
321/*
322 * Arrange that each of our links has at least one packet. We keep the
323 * number of packets queued at the link level to a minimum so that the

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

353 */
354int
355ncp_PushPacket(struct ncp *ncp, int *af, struct link *l)
356{
357 struct bundle *bundle = l->lcp.fsm.bundle;
358 int res;
359
360#ifndef NOINET6
361 if (!probe.ipv6_available)
362 res = ipcp_PushPacket(&bundle->ncp.ipcp, l);
363 else if (*af == AF_INET) {
364 if ((res = ipcp_PushPacket(&bundle->ncp.ipcp, l)))
365 *af = AF_INET6;
366 else
367 res = ipv6cp_PushPacket(&bundle->ncp.ipv6cp, l);
368 } else {
369 if ((res = ipv6cp_PushPacket(&bundle->ncp.ipv6cp, l)))
370 *af = AF_INET;
371 else

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

451
452int
453ncp_Show(struct cmdargs const *arg)
454{
455 struct ncp *ncp = &arg->bundle->ncp;
456 int p;
457
458#ifndef NOINET6
459 if (probe.ipv6_available)
460 prompt_Printf(arg->prompt, "Next queued AF: %s\n",
461 ncp->afq == AF_INET6 ? "inet6" : "inet");
462#endif
463
464 if (ncp->route) {
465 prompt_Printf(arg->prompt, "\n");
466 route_ShowSticky(arg->prompt, ncp->route, "Sticky routes", 1);
467 }
468
469 prompt_Printf(arg->prompt, "\nDefaults:\n");

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

506
507int
508ncp_LayersOpen(struct ncp *ncp)
509{
510 int n;
511
512 n = !!(ncp->ipcp.fsm.state == ST_OPENED);
513#ifndef NOINET6
514 if (probe.ipv6_available)
515 n += !!(ncp->ipv6cp.fsm.state == ST_OPENED);
516#endif
517
518 return n;
519}
520
521int
522ncp_LayersUnfinished(struct ncp *ncp)
523{
524 int n = 0;
525
526 if (ncp->ipcp.fsm.state > ST_CLOSED ||
527 ncp->ipcp.fsm.state == ST_STARTING)
528 n++;
529
530#ifndef NOINET6
531 if (probe.ipv6_available)
532 if (ncp->ipv6cp.fsm.state > ST_CLOSED ||
533 ncp->ipv6cp.fsm.state == ST_STARTING)
534 n++;
535#endif
536
537 return n;
538}
539
540void
541ncp_Close(struct ncp *ncp)
542{
543 if (ncp->ipcp.fsm.state > ST_CLOSED ||
544 ncp->ipcp.fsm.state == ST_STARTING)
545 fsm_Close(&ncp->ipcp.fsm);
546
547#ifndef NOINET6
548 if (probe.ipv6_available)
549 if (ncp->ipv6cp.fsm.state > ST_CLOSED ||
550 ncp->ipv6cp.fsm.state == ST_STARTING)
551 fsm_Close(&ncp->ipv6cp.fsm);
552#endif
553}
554
555void
556ncp2initial(struct ncp *ncp)
557{
558 fsm2initial(&ncp->ipcp.fsm);
559#ifndef NOINET6
560 if (probe.ipv6_available)
561 fsm2initial(&ncp->ipv6cp.fsm);
562#endif
563}