Lines Matching +full:software +full:- +full:dl

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
94 peer->enddisc.class = 0; in peerid_Init()
95 *peer->enddisc.address = '\0'; in peerid_Init()
96 peer->enddisc.len = 0; in peerid_Init()
97 *peer->authname = '\0'; in peerid_Init()
103 return !strcmp(p1->authname, p2->authname) && in peerid_Equal()
104 p1->enddisc.class == p2->enddisc.class && in peerid_Equal()
105 p1->enddisc.len == p2->enddisc.len && in peerid_Equal()
106 !memcmp(p1->enddisc.address, p2->enddisc.address, p1->enddisc.len); in peerid_Equal()
124 u_int32_t max = (is12bit ? 0xfff : 0xffffff) - 0x200; in isbefore()
138 if (mp->local_is12bit) { in mp_ReadHeader()
143 log_Printf(LogWARN, "Oops - MP header without required zero bits\n"); in mp_ReadHeader()
146 header->begin = val & 0x8000 ? 1 : 0; in mp_ReadHeader()
147 header->end = val & 0x4000 ? 1 : 0; in mp_ReadHeader()
148 header->seq = val & 0x0fff; in mp_ReadHeader()
151 ua_ntohl(MBUF_CTOP(m), &header->seq); in mp_ReadHeader()
152 if (header->seq & 0x3f000000) { in mp_ReadHeader()
153 log_Printf(LogWARN, "Oops - MP header without required zero bits\n"); in mp_ReadHeader()
156 header->begin = header->seq & 0x80000000 ? 1 : 0; in mp_ReadHeader()
157 header->end = header->seq & 0x40000000 ? 1 : 0; in mp_ReadHeader()
158 header->seq &= 0x00ffffff; in mp_ReadHeader()
174 bundle_CalculateBandwidth(fp->bundle); /* Against ccp_MTUOverhead */ in mp_LayerUp()
187 if (fp->state == ST_CLOSED && fp->open_mode == OPEN_PASSIVE) in mp_LayerFinish()
197 percent = MAX(mp->link.stats.total.in.OctetsPerSecond, in mp_UpDown()
198 mp->link.stats.total.out.OctetsPerSecond) * 800 / in mp_UpDown()
199 mp->bundle->bandwidth; in mp_UpDown()
200 if (percent >= mp->cfg.autoload.max) { in mp_UpDown()
201 log_Printf(LogDEBUG, "%d%% saturation - bring a link up ?\n", percent); in mp_UpDown()
202 bundle_AutoAdjust(mp->bundle, percent, AUTO_UP); in mp_UpDown()
203 } else if (percent <= mp->cfg.autoload.min) { in mp_UpDown()
204 log_Printf(LogDEBUG, "%d%% saturation - bring a link down ?\n", percent); in mp_UpDown()
205 bundle_AutoAdjust(mp->bundle, percent, AUTO_DOWN); in mp_UpDown()
212 throughput_stop(&mp->link.stats.total); in mp_StopAutoloadTimer()
218 if (mp->link.stats.total.SamplePeriod != mp->cfg.autoload.period) { in mp_CheckAutoloadTimer()
219 throughput_destroy(&mp->link.stats.total); in mp_CheckAutoloadTimer()
220 throughput_init(&mp->link.stats.total, mp->cfg.autoload.period); in mp_CheckAutoloadTimer()
221 throughput_callback(&mp->link.stats.total, mp_UpDown, mp); in mp_CheckAutoloadTimer()
224 if (bundle_WantAutoloadTimer(mp->bundle)) in mp_CheckAutoloadTimer()
225 throughput_start(&mp->link.stats.total, "MP throughput", 1); in mp_CheckAutoloadTimer()
233 if (mp->link.stats.total.SamplePeriod != mp->cfg.autoload.period) in mp_RestartAutoloadTimer()
236 throughput_clear(&mp->link.stats.total, THROUGHPUT_OVERALL, NULL); in mp_RestartAutoloadTimer()
242 mp->peer_is12bit = mp->local_is12bit = 0; in mp_Init()
243 mp->peer_mrru = mp->local_mrru = 0; in mp_Init()
245 peerid_Init(&mp->peer); in mp_Init()
247 mp->out.seq = 0; in mp_Init()
248 mp->out.link = 0; in mp_Init()
249 mp->out.af = AF_INET; in mp_Init()
250 mp->seq.min_in = 0; in mp_Init()
251 mp->seq.next_in = 0; in mp_Init()
252 mp->inbufs = NULL; in mp_Init()
253 mp->bundle = bundle; in mp_Init()
255 mp->link.type = LOGICAL_LINK; in mp_Init()
256 mp->link.name = "mp"; in mp_Init()
257 mp->link.len = sizeof *mp; in mp_Init()
259 mp->cfg.autoload.period = SAMPLE_PERIOD; in mp_Init()
260 mp->cfg.autoload.min = mp->cfg.autoload.max = 0; in mp_Init()
261 throughput_init(&mp->link.stats.total, mp->cfg.autoload.period); in mp_Init()
262 throughput_callback(&mp->link.stats.total, mp_UpDown, mp); in mp_Init()
263 mp->link.stats.parent = NULL; in mp_Init()
264 mp->link.stats.gather = 0; /* Let the physical links gather stats */ in mp_Init()
265 memset(mp->link.Queue, '\0', sizeof mp->link.Queue); in mp_Init()
266 memset(mp->link.proto_in, '\0', sizeof mp->link.proto_in); in mp_Init()
267 memset(mp->link.proto_out, '\0', sizeof mp->link.proto_out); in mp_Init()
269 mp->fsmp.LayerStart = mp_LayerStart; in mp_Init()
270 mp->fsmp.LayerUp = mp_LayerUp; in mp_Init()
271 mp->fsmp.LayerDown = mp_LayerDown; in mp_Init()
272 mp->fsmp.LayerFinish = mp_LayerFinish; in mp_Init()
273 mp->fsmp.object = mp; in mp_Init()
275 mpserver_Init(&mp->server); in mp_Init()
277 mp->cfg.mrru = 0; in mp_Init()
278 mp->cfg.shortseq = NEG_ENABLED|NEG_ACCEPTED; in mp_Init()
279 mp->cfg.negenddisc = NEG_ENABLED|NEG_ACCEPTED; in mp_Init()
280 mp->cfg.enddisc.class = 0; in mp_Init()
281 *mp->cfg.enddisc.address = '\0'; in mp_Init()
282 mp->cfg.enddisc.len = 0; in mp_Init()
284 lcp_Init(&mp->link.lcp, mp->bundle, &mp->link, NULL); in mp_Init()
285 ccp_Init(&mp->link.ccp, mp->bundle, &mp->link, &mp->fsmp); in mp_Init()
287 link_EmptyStack(&mp->link); in mp_Init()
288 link_Stack(&mp->link, &protolayer); in mp_Init()
289 link_Stack(&mp->link, &ccplayer); in mp_Init()
290 link_Stack(&mp->link, &vjlayer); in mp_Init()
292 link_Stack(&mp->link, &natlayer); in mp_Init()
297 mp_Up(struct mp *mp, struct datalink *dl) in mp_Up() argument
299 struct lcp *lcp = &dl->physical->link.lcp; in mp_Up()
301 if (mp->active) { in mp_Up()
302 /* We're adding a link - do a last validation on our parameters */ in mp_Up()
303 if (!peerid_Equal(&dl->peer, &mp->peer)) { in mp_Up()
304 log_Printf(LogPHASE, "%s: Inappropriate peer !\n", dl->name); in mp_Up()
305 log_Printf(LogPHASE, " Attached to peer %s/%s\n", mp->peer.authname, in mp_Up()
306 mp_Enddisc(mp->peer.enddisc.class, mp->peer.enddisc.address, in mp_Up()
307 mp->peer.enddisc.len)); in mp_Up()
308 log_Printf(LogPHASE, " New link is peer %s/%s\n", dl->peer.authname, in mp_Up()
309 mp_Enddisc(dl->peer.enddisc.class, dl->peer.enddisc.address, in mp_Up()
310 dl->peer.enddisc.len)); in mp_Up()
313 if (mp->local_mrru != lcp->want_mrru || in mp_Up()
314 mp->peer_mrru != lcp->his_mrru || in mp_Up()
315 mp->local_is12bit != lcp->want_shortseq || in mp_Up()
316 mp->peer_is12bit != lcp->his_shortseq) { in mp_Up()
318 dl->name); in mp_Up()
325 mp->local_mrru = lcp->want_mrru; in mp_Up()
326 mp->peer_mrru = lcp->his_mrru; in mp_Up()
327 mp->local_is12bit = lcp->want_shortseq; in mp_Up()
328 mp->peer_is12bit = lcp->his_shortseq; in mp_Up()
329 mp->peer = dl->peer; in mp_Up()
331 throughput_destroy(&mp->link.stats.total); in mp_Up()
332 throughput_init(&mp->link.stats.total, mp->cfg.autoload.period); in mp_Up()
333 throughput_callback(&mp->link.stats.total, mp_UpDown, mp); in mp_Up()
334 memset(mp->link.Queue, '\0', sizeof mp->link.Queue); in mp_Up()
335 memset(mp->link.proto_in, '\0', sizeof mp->link.proto_in); in mp_Up()
336 memset(mp->link.proto_out, '\0', sizeof mp->link.proto_out); in mp_Up()
339 dl->physical->link.stats.parent = &mp->link.stats.total; in mp_Up()
341 mp->out.seq = 0; in mp_Up()
342 mp->out.link = 0; in mp_Up()
343 mp->out.af = AF_INET; in mp_Up()
344 mp->seq.min_in = 0; in mp_Up()
345 mp->seq.next_in = 0; in mp_Up()
351 switch (mpserver_Open(&mp->server, &mp->peer)) { in mp_Up()
354 mp->server.socket.sun_path); in mp_Up()
355 mp->server.send.dl = dl; /* Defer 'till it's safe to send */ in mp_Up()
360 log_Printf(LogPHASE, "mp: Listening on %s\n", mp->server.socket.sun_path); in mp_Up()
361 log_Printf(LogPHASE, " First link: %s\n", dl->name); in mp_Up()
363 /* Re-point our NCP layers at our MP link */ in mp_Up()
364 ncp_SetLink(&mp->bundle->ncp, &mp->link); in mp_Up()
367 if (ccp_SetOpenMode(&mp->link.ccp)) { in mp_Up()
368 fsm_Up(&mp->link.ccp.fsm); in mp_Up()
369 fsm_Open(&mp->link.ccp.fsm); in mp_Up()
372 mp->active = 1; in mp_Up()
383 if (mp->active) { in mp_Down()
390 mpserver_Close(&mp->server); in mp_Down()
393 fsm2initial(&mp->link.ccp.fsm); in mp_Down()
395 /* Received fragments go in the bit-bucket */ in mp_Down()
396 while (mp->inbufs) { in mp_Down()
397 next = mp->inbufs->m_nextpkt; in mp_Down()
398 m_freem(mp->inbufs); in mp_Down()
399 mp->inbufs = next; in mp_Down()
402 peerid_Init(&mp->peer); in mp_Down()
403 mp->active = 0; in mp_Down()
410 mplink->seq = 0; in mp_linkInit()
411 mplink->bandwidth = 0; in mp_linkInit()
433 seq = p->dl->mp.seq; in mp_Assemble()
434 p->dl->mp.seq = mh.seq; in mp_Assemble()
436 seq = mp->seq.min_in; in mp_Assemble()
438 if (mp->seq.min_in == seq) { in mp_Assemble()
443 struct datalink *dl; in mp_Assemble() local
445 mp->seq.min_in = (u_int32_t)-1; in mp_Assemble()
446 for (dl = mp->bundle->links; dl; dl = dl->next) in mp_Assemble()
447 if (dl->state == DATALINK_OPEN && in mp_Assemble()
448 (mp->seq.min_in == (u_int32_t)-1 || in mp_Assemble()
449 isbefore(mp->local_is12bit, dl->mp.seq, mp->seq.min_in))) in mp_Assemble()
450 mp->seq.min_in = dl->mp.seq; in mp_Assemble()
460 seq = mp->seq.next_in; in mp_Assemble()
461 q = mp->inbufs; in mp_Assemble()
465 last->m_nextpkt = m; in mp_Assemble()
467 mp->inbufs = m; in mp_Assemble()
474 if (m && isbefore(mp->local_is12bit, mh.seq, h.seq)) { in mp_Assemble()
477 last->m_nextpkt = m; in mp_Assemble()
479 mp->inbufs = m; in mp_Assemble()
480 m->m_nextpkt = q; in mp_Assemble()
488 /* we're missing something :-( */ in mp_Assemble()
489 if (isbefore(mp->local_is12bit, seq, mp->seq.min_in)) { in mp_Assemble()
494 while (mp->inbufs != q) { in mp_Assemble()
496 next = mp->inbufs->m_nextpkt; in mp_Assemble()
497 m_freem(mp->inbufs); in mp_Assemble()
498 mp->inbufs = next; in mp_Assemble()
503 * the next `begin' fragment OR 'till seq.min_in - whichever in mp_Assemble()
507 mp_ReadHeader(mp, mp->inbufs, &h); in mp_Assemble()
510 h.seq--; /* We're gonna look for fragment with h.seq+1 */ in mp_Assemble()
513 next = mp->inbufs->m_nextpkt; in mp_Assemble()
515 m_freem(mp->inbufs); in mp_Assemble()
516 mp->inbufs = next; in mp_Assemble()
517 } while (mp->inbufs && (isbefore(mp->local_is12bit, mp->seq.min_in, in mp_Assemble()
528 mp->seq.next_in = seq = inc_seq(mp->local_is12bit, h.seq); in mp_Assemble()
530 q = mp->inbufs; in mp_Assemble()
538 long long first = -1; in mp_Assemble()
541 *frag = mp->inbufs; in mp_Assemble()
542 mp->inbufs = mp->inbufs->m_nextpkt; in mp_Assemble()
544 if (first == -1) in mp_Assemble()
547 log_Printf(LogWARN, "Oops - MP frag %lu should have a begin flag\n", in mp_Assemble()
552 log_Printf(LogWARN, "Oops - MP frag %lu should have an end flag\n", in mp_Assemble()
553 (u_long)h.seq - 1); in mp_Assemble()
556 * our half-assembled packet. in mp_Assemble()
558 (*frag)->m_nextpkt = mp->inbufs; in mp_Assemble()
559 mp->inbufs = *frag; in mp_Assemble()
566 (*frag)->m_offset += len; in mp_Assemble()
567 (*frag)->m_len -= len; in mp_Assemble()
568 (*frag)->m_nextpkt = NULL; in mp_Assemble()
570 frag = &(*frag)->m_next; in mp_Assemble()
577 log_Printf(LogDEBUG, "MP: Reassembled frags %lu-%lu, length %zd\n", in mp_Assemble()
579 link_PullPacket(&mp->link, MBUF_CTOP(q), q->m_len, mp->bundle); in mp_Assemble()
583 mp->seq.next_in = seq = inc_seq(mp->local_is12bit, h.seq); in mp_Assemble()
585 q = mp->inbufs; in mp_Assemble()
588 seq = inc_seq(mp->local_is12bit, seq); in mp_Assemble()
590 q = q->m_nextpkt; in mp_Assemble()
597 for (q = mp->inbufs; q; last = q, q = q->m_nextpkt) { in mp_Assemble()
599 if (isbefore(mp->local_is12bit, mh.seq, h.seq)) in mp_Assemble()
604 last->m_nextpkt = m; in mp_Assemble()
606 mp->inbufs = m; in mp_Assemble()
607 m->m_nextpkt = q; in mp_Assemble()
616 if (!bundle->ncp.mp.active) in mp_Input()
625 mp_Assemble(&bundle->ncp.mp, bp, p); in mp_Input()
639 if (mp->peer_is12bit) { in mp_Output()
642 val = (begin << 15) | (end << 14) | (u_int16_t)mp->out.seq; in mp_Output()
648 val = (begin << 31) | (end << 30) | (u_int32_t)mp->out.seq; in mp_Output()
654 mp->out.seq, m_length(m), l->name); in mp_Output()
655 mp->out.seq = inc_seq(mp->peer_is12bit, mp->out.seq); in mp_Output()
657 if (l->ccp.fsm.state != ST_OPENED && ccp_Required(&l->ccp)) { in mp_Output()
658 log_Printf(LogPHASE, "%s: Not transmitting... waiting for CCP\n", l->name); in mp_Output()
662 link_PushPacket(l, m, bundle, LINK_QUEUES(l) - 1, PROTO_MP); in mp_Output()
668 struct mp *mp = &bundle->ncp.mp; in mp_FillPhysicalQueues()
669 struct datalink *dl, *fdl; in mp_FillPhysicalQueues() local
677 for (fdl = NULL, dl = bundle->links; dl; dl = dl->next) { in mp_FillPhysicalQueues()
678 /* Include non-open links here as mp->out.link will stay more correct */ in mp_FillPhysicalQueues()
680 if (thislink == mp->out.link) in mp_FillPhysicalQueues()
681 fdl = dl; in mp_FillPhysicalQueues()
686 if (dl->state == DATALINK_OPEN) in mp_FillPhysicalQueues()
691 fdl = bundle->links; in mp_FillPhysicalQueues()
698 for (dl = fdl; nlinks > 0; dl = dl->next, nlinks--, thislink++) { in mp_FillPhysicalQueues()
699 if (!dl) { in mp_FillPhysicalQueues()
700 dl = bundle->links; in mp_FillPhysicalQueues()
704 if (dl->state != DATALINK_OPEN) in mp_FillPhysicalQueues()
707 if (dl->physical->out) in mp_FillPhysicalQueues()
711 add = link_QueueLen(&dl->physical->link); in mp_FillPhysicalQueues()
732 if (dl->physical->link.lcp.his_mru < mp->peer_mrru) { in mp_FillPhysicalQueues()
744 bestlink = sendasip ? &dl->physical->link : &mp->link; in mp_FillPhysicalQueues()
745 if (!ncp_PushPacket(&bundle->ncp, &mp->out.af, bestlink)) in mp_FillPhysicalQueues()
754 add = link_QueueLen(&dl->physical->link); in mp_FillPhysicalQueues()
763 m = link_Dequeue(&mp->link); in mp_FillPhysicalQueues()
770 if (dl->state == DATALINK_OPEN) { in mp_FillPhysicalQueues()
772 if (len <= dl->physical->link.lcp.his_mru) { in mp_FillPhysicalQueues()
778 mo = m_get(dl->physical->link.lcp.his_mru, MB_MPOUT); in mp_FillPhysicalQueues()
779 len -= mo->m_len; in mp_FillPhysicalQueues()
780 m = mbuf_Read(m, MBUF_CTOP(mo), mo->m_len); in mp_FillPhysicalQueues()
782 mp_Output(mp, bundle, &dl->physical->link, mo, begin, end); in mp_FillPhysicalQueues()
787 nlinks--; in mp_FillPhysicalQueues()
788 dl = dl->next; in mp_FillPhysicalQueues()
789 if (!dl) { in mp_FillPhysicalQueues()
790 dl = bundle->links; in mp_FillPhysicalQueues()
798 mp->out.link = thislink; /* Start here next time */ in mp_FillPhysicalQueues()
808 if (arg->argc != arg->argn+1) in mp_SetDatalinkBandwidth()
809 return -1; in mp_SetDatalinkBandwidth()
811 val = atoi(arg->argv[arg->argn]); in mp_SetDatalinkBandwidth()
816 arg->cx->mp.bandwidth = val; in mp_SetDatalinkBandwidth()
818 if (arg->cx->state == DATALINK_OPEN) in mp_SetDatalinkBandwidth()
819 bundle_CalculateBandwidth(arg->bundle); in mp_SetDatalinkBandwidth()
827 struct mp *mp = &arg->bundle->ncp.mp; in mp_ShowStatus()
829 prompt_Printf(arg->prompt, "Multilink is %sactive\n", mp->active ? "" : "in"); in mp_ShowStatus()
830 if (mp->active) { in mp_ShowStatus()
835 prompt_Printf(arg->prompt, "Socket: %s\n", in mp_ShowStatus()
836 mp->server.socket.sun_path); in mp_ShowStatus()
837 for (m = mp->inbufs; m; m = m->m_nextpkt) { in mp_ShowStatus()
841 prompt_Printf(arg->prompt, "Pending frags: %d", bufs); in mp_ShowStatus()
846 first = mp_ReadHeader(mp, mp->inbufs, &mh) ? mh.seq : 0; in mp_ShowStatus()
848 prompt_Printf(arg->prompt, " (Have %lu - %lu, want %lu, lowest %lu)\n", in mp_ShowStatus()
849 first, last, (unsigned long)mp->seq.next_in, in mp_ShowStatus()
850 (unsigned long)mp->seq.min_in); in mp_ShowStatus()
851 prompt_Printf(arg->prompt, " First has %sbegin bit and " in mp_ShowStatus()
854 prompt_Printf(arg->prompt, "\n"); in mp_ShowStatus()
857 prompt_Printf(arg->prompt, "\nMy Side:\n"); in mp_ShowStatus()
858 if (mp->active) { in mp_ShowStatus()
859 prompt_Printf(arg->prompt, " Output SEQ: %u\n", mp->out.seq); in mp_ShowStatus()
860 prompt_Printf(arg->prompt, " MRRU: %u\n", mp->local_mrru); in mp_ShowStatus()
861 prompt_Printf(arg->prompt, " Short Seq: %s\n", in mp_ShowStatus()
862 mp->local_is12bit ? "on" : "off"); in mp_ShowStatus()
864 prompt_Printf(arg->prompt, " Discriminator: %s\n", in mp_ShowStatus()
865 mp_Enddisc(mp->cfg.enddisc.class, mp->cfg.enddisc.address, in mp_ShowStatus()
866 mp->cfg.enddisc.len)); in mp_ShowStatus()
868 prompt_Printf(arg->prompt, "\nHis Side:\n"); in mp_ShowStatus()
869 if (mp->active) { in mp_ShowStatus()
870 prompt_Printf(arg->prompt, " Auth Name: %s\n", mp->peer.authname); in mp_ShowStatus()
871 prompt_Printf(arg->prompt, " Input SEQ: %u\n", mp->seq.next_in); in mp_ShowStatus()
872 prompt_Printf(arg->prompt, " MRRU: %u\n", mp->peer_mrru); in mp_ShowStatus()
873 prompt_Printf(arg->prompt, " Short Seq: %s\n", in mp_ShowStatus()
874 mp->peer_is12bit ? "on" : "off"); in mp_ShowStatus()
876 prompt_Printf(arg->prompt, " Discriminator: %s\n", in mp_ShowStatus()
877 mp_Enddisc(mp->peer.enddisc.class, mp->peer.enddisc.address, in mp_ShowStatus()
878 mp->peer.enddisc.len)); in mp_ShowStatus()
880 prompt_Printf(arg->prompt, "\nDefaults:\n"); in mp_ShowStatus()
882 prompt_Printf(arg->prompt, " MRRU: "); in mp_ShowStatus()
883 if (mp->cfg.mrru) in mp_ShowStatus()
884 prompt_Printf(arg->prompt, "%d (multilink enabled)\n", mp->cfg.mrru); in mp_ShowStatus()
886 prompt_Printf(arg->prompt, "disabled\n"); in mp_ShowStatus()
887 prompt_Printf(arg->prompt, " Short Seq: %s\n", in mp_ShowStatus()
888 command_ShowNegval(mp->cfg.shortseq)); in mp_ShowStatus()
889 prompt_Printf(arg->prompt, " Discriminator: %s\n", in mp_ShowStatus()
890 command_ShowNegval(mp->cfg.negenddisc)); in mp_ShowStatus()
891 prompt_Printf(arg->prompt, " AutoLoad: min %d%%, max %d%%," in mp_ShowStatus()
892 " period %d secs\n", mp->cfg.autoload.min, in mp_ShowStatus()
893 mp->cfg.autoload.max, mp->cfg.autoload.period); in mp_ShowStatus()
935 len = sizeof result - header - 1; in mp_Enddisc()
948 len = sizeof result - header - 1; in mp_Enddisc()
959 struct mp *mp = &arg->bundle->ncp.mp; in mp_SetEnddisc()
962 switch (bundle_Phase(arg->bundle)) { in mp_SetEnddisc()
967 if (bundle_HighestState(arg->bundle) >= DATALINK_LCP) { in mp_SetEnddisc()
978 if (arg->argc == arg->argn) { in mp_SetEnddisc()
979 mp->cfg.enddisc.class = 0; in mp_SetEnddisc()
980 *mp->cfg.enddisc.address = '\0'; in mp_SetEnddisc()
981 mp->cfg.enddisc.len = 0; in mp_SetEnddisc()
982 } else if (arg->argc > arg->argn) { in mp_SetEnddisc()
983 if (!strcasecmp(arg->argv[arg->argn], "label")) { in mp_SetEnddisc()
984 mp->cfg.enddisc.class = ENDDISC_LOCAL; in mp_SetEnddisc()
985 strcpy(mp->cfg.enddisc.address, arg->bundle->cfg.label); in mp_SetEnddisc()
986 mp->cfg.enddisc.len = strlen(mp->cfg.enddisc.address); in mp_SetEnddisc()
987 } else if (!strcasecmp(arg->argv[arg->argn], "ip")) { in mp_SetEnddisc()
988 if (arg->bundle->ncp.ipcp.my_ip.s_addr == INADDR_ANY) in mp_SetEnddisc()
989 ncprange_getip4addr(&arg->bundle->ncp.ipcp.cfg.my_range, &addr); in mp_SetEnddisc()
991 addr = arg->bundle->ncp.ipcp.my_ip; in mp_SetEnddisc()
992 memcpy(mp->cfg.enddisc.address, &addr.s_addr, sizeof addr.s_addr); in mp_SetEnddisc()
993 mp->cfg.enddisc.class = ENDDISC_IP; in mp_SetEnddisc()
994 mp->cfg.enddisc.len = sizeof arg->bundle->ncp.ipcp.my_ip.s_addr; in mp_SetEnddisc()
995 } else if (!strcasecmp(arg->argv[arg->argn], "mac")) { in mp_SetEnddisc()
998 if (arg->bundle->ncp.ipcp.my_ip.s_addr == INADDR_ANY) in mp_SetEnddisc()
999 ncprange_getip4addr(&arg->bundle->ncp.ipcp.cfg.my_range, &addr); in mp_SetEnddisc()
1001 addr = arg->bundle->ncp.ipcp.my_ip; in mp_SetEnddisc()
1004 mp->cfg.enddisc.class = ENDDISC_MAC; in mp_SetEnddisc()
1005 memcpy(mp->cfg.enddisc.address, hwaddr.sdl_data + hwaddr.sdl_nlen, in mp_SetEnddisc()
1007 mp->cfg.enddisc.len = hwaddr.sdl_alen; in mp_SetEnddisc()
1013 } else if (!strcasecmp(arg->argv[arg->argn], "magic")) { in mp_SetEnddisc()
1018 *(long *)(mp->cfg.enddisc.address + f) = random(); in mp_SetEnddisc()
1019 mp->cfg.enddisc.class = ENDDISC_MAGIC; in mp_SetEnddisc()
1020 mp->cfg.enddisc.len = 20; in mp_SetEnddisc()
1021 } else if (!strcasecmp(arg->argv[arg->argn], "psn")) { in mp_SetEnddisc()
1022 if (arg->argc > arg->argn+1) { in mp_SetEnddisc()
1023 mp->cfg.enddisc.class = ENDDISC_PSN; in mp_SetEnddisc()
1024 strcpy(mp->cfg.enddisc.address, arg->argv[arg->argn+1]); in mp_SetEnddisc()
1025 mp->cfg.enddisc.len = strlen(mp->cfg.enddisc.address); in mp_SetEnddisc()
1032 arg->argv[arg->argn]); in mp_SetEnddisc()
1048 if (s->send.dl != NULL) { in mpserver_UpdateSet()
1050 if (!link_QueueLen(&s->send.dl->physical->link) && in mpserver_UpdateSet()
1051 !s->send.dl->physical->out) { in mpserver_UpdateSet()
1053 result -= datalink_RemoveFromSet(s->send.dl, r, w, e); in mpserver_UpdateSet()
1054 bundle_SendDatalink(s->send.dl, s->fd, &s->socket); in mpserver_UpdateSet()
1055 s->send.dl = NULL; in mpserver_UpdateSet()
1056 s->fd = -1; in mpserver_UpdateSet()
1059 result -= datalink_RemoveFromSet(s->send.dl, r, NULL, NULL); in mpserver_UpdateSet()
1060 } else if (r && s->fd >= 0) { in mpserver_UpdateSet()
1061 if (*n < s->fd + 1) in mpserver_UpdateSet()
1062 *n = s->fd + 1; in mpserver_UpdateSet()
1063 FD_SET(s->fd, r); in mpserver_UpdateSet()
1064 log_Printf(LogTIMER, "mp: fdset(r) %d\n", s->fd); in mpserver_UpdateSet()
1074 return s->fd >= 0 && FD_ISSET(s->fd, fdset); in mpserver_IsSet()
1083 bundle_ReceiveDatalink(bundle, s->fd); in mpserver_Read()
1098 s->desc.type = MPSERVER_DESCRIPTOR; in mpserver_Init()
1099 s->desc.UpdateSet = mpserver_UpdateSet; in mpserver_Init()
1100 s->desc.IsSet = mpserver_IsSet; in mpserver_Init()
1101 s->desc.Read = mpserver_Read; in mpserver_Init()
1102 s->desc.Write = mpserver_Write; in mpserver_Init()
1103 s->send.dl = NULL; in mpserver_Init()
1104 s->fd = -1; in mpserver_Init()
1105 memset(&s->socket, '\0', sizeof s->socket); in mpserver_Init()
1114 if (s->fd != -1) { in mpserver_Open()
1119 l = snprintf(s->socket.sun_path, sizeof s->socket.sun_path, "%sppp-%s-%02x-", in mpserver_Open()
1120 _PATH_VARRUN, peer->authname, peer->enddisc.class); in mpserver_Open()
1127 f < peer->enddisc.len && (size_t)l < sizeof s->socket.sun_path - 2; in mpserver_Open()
1129 snprintf(s->socket.sun_path + l, sizeof s->socket.sun_path - l, in mpserver_Open()
1130 "%02x", *(u_char *)(peer->enddisc.address+f)); in mpserver_Open()
1134 s->socket.sun_family = AF_LOCAL; in mpserver_Open()
1135 s->socket.sun_len = sizeof s->socket; in mpserver_Open()
1136 s->fd = ID0socket(PF_LOCAL, SOCK_DGRAM, 0); in mpserver_Open()
1137 if (s->fd < 0) { in mpserver_Open()
1142 setsockopt(s->fd, SOL_SOCKET, SO_REUSEADDR, (struct sockaddr *)&s->socket, in mpserver_Open()
1143 sizeof s->socket); in mpserver_Open()
1151 if (ID0bind_un(s->fd, &s->socket) < 0) { in mpserver_Open()
1154 s->socket.sun_path, strerror(errno)); in mpserver_Open()
1156 close(s->fd); in mpserver_Open()
1157 s->fd = -1; in mpserver_Open()
1163 if (ID0connect_un(s->fd, &s->socket) < 0) { in mpserver_Open()
1165 s->socket.sun_path, strerror(errno)); in mpserver_Open()
1168 close(s->fd); in mpserver_Open()
1169 s->fd = -1; in mpserver_Open()
1183 if (s->send.dl != NULL) { in mpserver_Close()
1184 bundle_SendDatalink(s->send.dl, s->fd, &s->socket); in mpserver_Close()
1185 s->send.dl = NULL; in mpserver_Close()
1186 s->fd = -1; in mpserver_Close()
1187 } else if (s->fd >= 0) { in mpserver_Close()
1188 close(s->fd); in mpserver_Close()
1189 if (ID0unlink(s->socket.sun_path) == -1) in mpserver_Close()
1190 log_Printf(LogERROR, "%s: Failed to remove: %s\n", s->socket.sun_path, in mpserver_Close()
1192 memset(&s->socket, '\0', sizeof s->socket); in mpserver_Close()
1193 s->fd = -1; in mpserver_Close()
1198 mp_LinkLost(struct mp *mp, struct datalink *dl) in mp_LinkLost() argument
1200 if (mp->seq.min_in == dl->mp.seq) in mp_LinkLost()
1208 return link_QueueLen(&mp->link); in mp_QueueLen()