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
65 cbcp->required = 0; in cbcp_Init()
66 cbcp->fsm.state = CBCP_CLOSED; in cbcp_Init()
67 cbcp->fsm.id = 0; in cbcp_Init()
68 cbcp->fsm.delay = 0; in cbcp_Init()
69 *cbcp->fsm.phone = '\0'; in cbcp_Init()
70 memset(&cbcp->fsm.timer, '\0', sizeof cbcp->fsm.timer); in cbcp_Init()
71 cbcp->p = p; in cbcp_Init()
83 timer_Stop(&cbcp->fsm.timer); in cbcp_Timeout()
84 if (cbcp->fsm.restart) { in cbcp_Timeout()
85 switch (cbcp->fsm.state) { in cbcp_Timeout()
88 log_Printf(LogCBCP, "%s: Urk - unexpected CBCP timeout !\n", in cbcp_Timeout()
89 cbcp->p->dl->name); in cbcp_Timeout()
105 switch (cbcp->fsm.state) { in cbcp_Timeout()
119 log_Printf(LogCBCP, "%s: Urk - unexpected CBCP timeout !\n", in cbcp_Timeout()
120 cbcp->p->dl->name); in cbcp_Timeout()
126 cbcp->p->dl->name, missed); in cbcp_Timeout()
127 datalink_CBCPFailed(cbcp->p->dl); in cbcp_Timeout()
134 timer_Stop(&cbcp->fsm.timer); in cbcp_StartTimer()
135 cbcp->fsm.timer.func = cbcp_Timeout; in cbcp_StartTimer()
136 cbcp->fsm.timer.name = "cbcp"; in cbcp_StartTimer()
137 cbcp->fsm.timer.load = timeout * SECTICKS; in cbcp_StartTimer()
138 cbcp->fsm.timer.arg = cbcp; in cbcp_StartTimer()
139 timer_Start(&cbcp->fsm.timer); in cbcp_StartTimer()
149 "closed", "stopped", "req-sent", "resp-sent", "ack-sent"
163 if (cbcp->fsm.state != new) { in cbcp_NewPhase()
164 log_Printf(LogCBCP, "%s: State change %s --> %s\n", cbcp->p->dl->name, in cbcp_NewPhase()
165 cbcpstate(cbcp->fsm.state), cbcpstate(new)); in cbcp_NewPhase()
166 cbcp->fsm.state = new; in cbcp_NewPhase()
201 bp = m_get(sizeof *head + data->length, MB_CBCPOUT); in cbcp_Output()
203 head->code = code; in cbcp_Output()
204 head->id = cbcp->fsm.id; in cbcp_Output()
205 head->length = htons(sizeof *head + data->length); in cbcp_Output()
206 memcpy(MBUF_CTOP(bp) + sizeof *head, data, data->length); in cbcp_Output()
208 link_PushPacket(&cbcp->p->link, bp, cbcp->p->dl->bundle, in cbcp_Output()
209 LINK_QUEUES(&cbcp->p->link) - 1, PROTO_CBCP); in cbcp_Output()
216 "No callback", "User-spec", "Server-spec", "list" in cbcp_data_Type()
221 return types[type-1]; in cbcp_data_Type()
226 char addr[sizeof ((struct cbcp_data *)0)->addr_start - 1]; /* ASCIIZ */
238 addr = (struct cbcp_addr *)data->addr_start; in cbcp_data_Show()
239 end = (char *)data + data->length; in cbcp_data_Show()
242 log_Printf(LogCBCP, " TYPE %s\n", cbcp_data_Type(data->type)); in cbcp_data_Show()
243 if ((char *)&data->delay < end) { in cbcp_data_Show()
244 log_Printf(LogCBCP, " DELAY %d\n", data->delay); in cbcp_data_Show()
245 while (addr->addr < end) { in cbcp_data_Show()
246 if (addr->type == CBCP_ADDR_PSTN) in cbcp_data_Show()
247 log_Printf(LogCBCP, " ADDR %s\n", addr->addr); in cbcp_data_Show()
249 log_Printf(LogCBCP, " ADDR type %d ??\n", (int)addr->type); in cbcp_data_Show()
250 addr = (struct cbcp_addr *)(addr->addr + strlen(addr->addr) + 1); in cbcp_data_Show()
260 char list[sizeof cbcp->fsm.phone], *next; in cbcp_SendReq()
265 log_Printf(LogCBCP, "%s: SendReq(%d) state = %s\n", cbcp->p->dl->name, in cbcp_SendReq()
266 cbcp->fsm.id, cbcpstate(cbcp->fsm.state)); in cbcp_SendReq()
267 data.type = cbcp->fsm.type; in cbcp_SendReq()
269 strncpy(list, cbcp->fsm.phone, sizeof list - 1); in cbcp_SendReq()
270 list[sizeof list - 1] = '\0'; in cbcp_SendReq()
275 addr->type = CBCP_ADDR_PSTN; in cbcp_SendReq()
276 *addr->addr = '\0'; in cbcp_SendReq()
277 data.length = addr->addr - (char *)&data; in cbcp_SendReq()
284 max = data.addr_start + sizeof data.addr_start - addr->addr - 1; in cbcp_SendReq()
286 addr->type = CBCP_ADDR_PSTN; in cbcp_SendReq()
287 strncpy(addr->addr, next, sizeof addr->addr - 1); in cbcp_SendReq()
288 addr->addr[sizeof addr->addr - 1] = '\0'; in cbcp_SendReq()
291 log_Printf(LogWARN, "CBCP ADDR \"%s\" skipped - packet too large\n", in cbcp_SendReq()
294 data.length = (char *)addr - (char *)&data; in cbcp_SendReq()
298 data.length = data.addr_start - (char *)&data; in cbcp_SendReq()
302 data.length = (char *)&data.delay - (char *)&data; in cbcp_SendReq()
308 cbcp->fsm.restart--; in cbcp_SendReq()
309 cbcp_StartTimer(cbcp, cbcp->fsm.delay); in cbcp_SendReq()
316 struct lcp *lcp = &cbcp->p->link.lcp; in cbcp_Up()
318 cbcp->fsm.delay = cbcp->p->dl->cfg.cbcp.delay; in cbcp_Up()
319 if (*cbcp->p->dl->peer.authname == '\0' || in cbcp_Up()
320 !auth_SetPhoneList(cbcp->p->dl->peer.authname, cbcp->fsm.phone, in cbcp_Up()
321 sizeof cbcp->fsm.phone)) { in cbcp_Up()
322 strncpy(cbcp->fsm.phone, cbcp->p->dl->cfg.cbcp.phone, in cbcp_Up()
323 sizeof cbcp->fsm.phone - 1); in cbcp_Up()
324 cbcp->fsm.phone[sizeof cbcp->fsm.phone - 1] = '\0'; in cbcp_Up()
327 if (lcp->want_callback.opmask) { in cbcp_Up()
328 if (*cbcp->fsm.phone == '\0') in cbcp_Up()
329 cbcp->fsm.type = CBCP_NONUM; in cbcp_Up()
330 else if (!strcmp(cbcp->fsm.phone, "*")) { in cbcp_Up()
331 cbcp->fsm.type = CBCP_SERVERNUM; in cbcp_Up()
332 *cbcp->fsm.phone = '\0'; in cbcp_Up()
334 cbcp->fsm.type = CBCP_CLIENTNUM; in cbcp_Up()
336 cbcp_StartTimer(cbcp, cbcp->fsm.delay * DEF_FSMTRIES); in cbcp_Up()
338 if (*cbcp->fsm.phone == '\0') in cbcp_Up()
339 cbcp->fsm.type = CBCP_NONUM; in cbcp_Up()
340 else if (!strcmp(cbcp->fsm.phone, "*")) { in cbcp_Up()
341 cbcp->fsm.type = CBCP_CLIENTNUM; in cbcp_Up()
342 *cbcp->fsm.phone = '\0'; in cbcp_Up()
343 } else if (strchr(cbcp->fsm.phone, ',')) in cbcp_Up()
344 cbcp->fsm.type = CBCP_LISTNUM; in cbcp_Up()
346 cbcp->fsm.type = CBCP_SERVERNUM; in cbcp_Up()
347 cbcp->fsm.restart = DEF_FSMTRIES; in cbcp_Up()
356 * We've received a REQ (data). Adjust our response (cbcp->fsm.*) in cbcp_AdjustResponse()
361 switch (data->type) { in cbcp_AdjustResponse()
363 if (cbcp->p->dl->cfg.callback.opmask & CALLBACK_BIT(CALLBACK_NONE)) in cbcp_AdjustResponse()
369 cbcp->fsm.type = CBCP_NONUM; in cbcp_AdjustResponse()
373 * what Win95 does - although I can't find this behaviour documented in cbcp_AdjustResponse()
380 if (cbcp->fsm.type == CBCP_CLIENTNUM) { in cbcp_AdjustResponse()
383 if (data->length > data->addr_start - (char *)data) { in cbcp_AdjustResponse()
385 * The peer has given us an address type spec - make sure we in cbcp_AdjustResponse()
388 addr = (struct cbcp_addr *)data->addr_start; in cbcp_AdjustResponse()
389 if (addr->type != CBCP_ADDR_PSTN) { in cbcp_AdjustResponse()
391 (int)addr->type); in cbcp_AdjustResponse()
395 /* we accept the REQ even if the peer didn't specify an addr->type */ in cbcp_AdjustResponse()
396 ptr = strchr(cbcp->fsm.phone, ','); in cbcp_AdjustResponse()
405 if (cbcp->fsm.type == CBCP_SERVERNUM) { in cbcp_AdjustResponse()
406 *cbcp->fsm.phone = '\0'; in cbcp_AdjustResponse()
409 if (data->length > data->addr_start - (char *)data) { in cbcp_AdjustResponse()
416 addr = (struct cbcp_addr *)data->addr_start; in cbcp_AdjustResponse()
417 if (addr->type != CBCP_ADDR_PSTN) { in cbcp_AdjustResponse()
419 (int)addr->type); in cbcp_AdjustResponse()
421 } else if (cbcp->fsm.type == CBCP_CLIENTNUM) { in cbcp_AdjustResponse()
425 * think it's in control :-) in cbcp_AdjustResponse()
427 char list[sizeof cbcp->fsm.phone], *next; in cbcp_AdjustResponse()
429 strncpy(list, cbcp->fsm.phone, sizeof list - 1); in cbcp_AdjustResponse()
430 list[sizeof list - 1] = '\0'; in cbcp_AdjustResponse()
432 if (!strcmp(next, addr->addr)) { in cbcp_AdjustResponse()
433 cbcp->fsm.type = CBCP_SERVERNUM; in cbcp_AdjustResponse()
434 strcpy(cbcp->fsm.phone, next); in cbcp_AdjustResponse()
443 if (cbcp->fsm.type == CBCP_CLIENTNUM || cbcp->fsm.type == CBCP_LISTNUM) { in cbcp_AdjustResponse()
445 * Search through ``data''s addresses and see if cbcp->fsm.phone in cbcp_AdjustResponse()
448 char list[sizeof cbcp->fsm.phone], *next, *end; in cbcp_AdjustResponse()
450 addr = (struct cbcp_addr *)data->addr_start; in cbcp_AdjustResponse()
451 end = (char *)data + data->length; in cbcp_AdjustResponse()
453 while (addr->addr < end) { in cbcp_AdjustResponse()
454 if (addr->type == CBCP_ADDR_PSTN) { in cbcp_AdjustResponse()
455 strncpy(list, cbcp->fsm.phone, sizeof list - 1); in cbcp_AdjustResponse()
456 list[sizeof list - 1] = '\0'; in cbcp_AdjustResponse()
458 if (!strcmp(next, addr->addr)) { in cbcp_AdjustResponse()
459 cbcp->fsm.type = CBCP_LISTNUM; in cbcp_AdjustResponse()
460 strcpy(cbcp->fsm.phone, next); in cbcp_AdjustResponse()
465 (int)addr->type); in cbcp_AdjustResponse()
466 addr = (struct cbcp_addr *)(addr->addr + strlen(addr->addr) + 1); in cbcp_AdjustResponse()
473 log_Printf(LogCBCP, "Unrecognised REQ type %d !\n", (int)data->type); in cbcp_AdjustResponse()
485 log_Printf(LogCBCP, "%s: SendResponse(%d) state = %s\n", cbcp->p->dl->name, in cbcp_SendResponse()
486 cbcp->fsm.id, cbcpstate(cbcp->fsm.state)); in cbcp_SendResponse()
488 data.type = cbcp->fsm.type; in cbcp_SendResponse()
489 data.delay = cbcp->fsm.delay; in cbcp_SendResponse()
492 data.length = (char *)&data.delay - (char *)&data; in cbcp_SendResponse()
493 else if (*cbcp->fsm.phone) { in cbcp_SendResponse()
494 addr->type = CBCP_ADDR_PSTN; in cbcp_SendResponse()
495 strncpy(addr->addr, cbcp->fsm.phone, sizeof addr->addr - 1); in cbcp_SendResponse()
496 addr->addr[sizeof addr->addr - 1] = '\0'; in cbcp_SendResponse()
497 data.length = (addr->addr + strlen(addr->addr) + 1) - (char *)&data; in cbcp_SendResponse()
499 data.length = data.addr_start - (char *)&data; in cbcp_SendResponse()
503 cbcp->fsm.restart--; in cbcp_SendResponse()
504 cbcp_StartTimer(cbcp, cbcp->fsm.delay); in cbcp_SendResponse()
518 * our REQ (cbcp->fsm) in cbcp_CheckResponse()
522 addr = (struct cbcp_addr *)data->addr_start; in cbcp_CheckResponse()
524 if (data->type == cbcp->fsm.type) { in cbcp_CheckResponse()
525 switch (cbcp->fsm.type) { in cbcp_CheckResponse()
530 if ((char *)data + data->length <= addr->addr) in cbcp_CheckResponse()
532 else if (addr->type != CBCP_ADDR_PSTN) in cbcp_CheckResponse()
534 addr->type); in cbcp_CheckResponse()
536 strncpy(cbcp->fsm.phone, addr->addr, sizeof cbcp->fsm.phone - 1); in cbcp_CheckResponse()
537 cbcp->fsm.phone[sizeof cbcp->fsm.phone - 1] = '\0'; in cbcp_CheckResponse()
538 cbcp->fsm.delay = data->delay; in cbcp_CheckResponse()
544 cbcp->fsm.delay = data->delay; in cbcp_CheckResponse()
548 if ((char *)data + data->length <= addr->addr) in cbcp_CheckResponse()
550 else if (addr->type != CBCP_ADDR_PSTN) in cbcp_CheckResponse()
552 addr->type); in cbcp_CheckResponse()
554 char list[sizeof cbcp->fsm.phone], *next; in cbcp_CheckResponse()
556 strncpy(list, cbcp->fsm.phone, sizeof list - 1); in cbcp_CheckResponse()
557 list[sizeof list - 1] = '\0'; in cbcp_CheckResponse()
559 if (!strcmp(addr->addr, next)) { in cbcp_CheckResponse()
560 strcpy(cbcp->fsm.phone, next); in cbcp_CheckResponse()
561 cbcp->fsm.delay = data->delay; in cbcp_CheckResponse()
569 log_Printf(LogPHASE, "Internal CBCP error - agreed on %d !\n", in cbcp_CheckResponse()
570 (int)cbcp->fsm.type); in cbcp_CheckResponse()
572 } else if (data->type == CBCP_NONUM && cbcp->fsm.type == CBCP_CLIENTNUM) { in cbcp_CheckResponse()
577 cbcp->fsm.type = CBCP_NONUM; in cbcp_CheckResponse()
592 log_Printf(LogCBCP, "%s: SendAck(%d) state = %s\n", cbcp->p->dl->name, in cbcp_SendAck()
593 cbcp->fsm.id, cbcpstate(cbcp->fsm.state)); in cbcp_SendAck()
595 data.type = cbcp->fsm.type; in cbcp_SendAck()
598 data.length = (char *)&data.delay - (char *)&data; in cbcp_SendAck()
602 addr->type = CBCP_ADDR_PSTN; in cbcp_SendAck()
603 strncpy(addr->addr, cbcp->fsm.phone, sizeof addr->addr - 1); in cbcp_SendAck()
604 addr->addr[sizeof addr->addr - 1] = '\0'; in cbcp_SendAck()
605 data.delay = cbcp->fsm.delay; in cbcp_SendAck()
606 data.length = addr->addr + strlen(addr->addr) + 1 - (char *)&data; in cbcp_SendAck()
609 data.delay = cbcp->fsm.delay; in cbcp_SendAck()
610 data.length = data.addr_start - (char *)&data; in cbcp_SendAck()
616 cbcp->fsm.restart--; in cbcp_SendAck()
617 cbcp_StartTimer(cbcp, cbcp->fsm.delay); in cbcp_SendAck()
627 struct cbcp *cbcp = &p->dl->cbcp; in cbcp_Input()
631 log_Printf(LogERROR, "cbcp_Input: Not a physical link - dropped\n"); in cbcp_Input()
643 if (ntohs(head->length) != len) { in cbcp_Input()
645 " - ignored\n", head->code, ntohs(head->length), len); in cbcp_Input()
653 bp->m_offset += sizeof(struct cbcp_header); in cbcp_Input()
654 bp->m_len -= sizeof(struct cbcp_header); in cbcp_Input()
657 switch (head->code) { in cbcp_Input()
660 p->dl->name, head->id, cbcpstate(cbcp->fsm.state)); in cbcp_Input()
662 if (cbcp->fsm.state == CBCP_STOPPED || cbcp->fsm.state == CBCP_RESPSENT) { in cbcp_Input()
663 timer_Stop(&cbcp->fsm.timer); in cbcp_Input()
665 cbcp->fsm.restart = DEF_FSMTRIES; in cbcp_Input()
666 cbcp->fsm.id = head->id; in cbcp_Input()
669 datalink_CBCPFailed(cbcp->p->dl); in cbcp_Input()
671 log_Printf(LogCBCP, "%s: unexpected REQ dropped\n", p->dl->name); in cbcp_Input()
676 p->dl->name, head->id, cbcpstate(cbcp->fsm.state)); in cbcp_Input()
678 if (cbcp->fsm.id != head->id) { in cbcp_Input()
680 cbcp->fsm.id, head->id); in cbcp_Input()
681 cbcp->fsm.id = head->id; in cbcp_Input()
683 if (cbcp->fsm.state == CBCP_REQSENT || cbcp->fsm.state == CBCP_ACKSENT) { in cbcp_Input()
684 timer_Stop(&cbcp->fsm.timer); in cbcp_Input()
691 cbcp->fsm.restart = DEF_FSMTRIES; in cbcp_Input()
693 if (cbcp->fsm.type == CBCP_NONUM) { in cbcp_Input()
698 timer_Stop(&cbcp->fsm.timer); in cbcp_Input()
699 datalink_NCPUp(cbcp->p->dl); in cbcp_Input()
704 datalink_CBCPFailed(cbcp->p->dl); in cbcp_Input()
708 log_Printf(LogCBCP, "%s: unexpected RESPONSE dropped\n", p->dl->name); in cbcp_Input()
713 p->dl->name, head->id, cbcpstate(cbcp->fsm.state)); in cbcp_Input()
715 if (cbcp->fsm.id != head->id) { in cbcp_Input()
717 cbcp->fsm.id, head->id); in cbcp_Input()
718 cbcp->fsm.id = head->id; in cbcp_Input()
720 if (cbcp->fsm.type == CBCP_NONUM) { in cbcp_Input()
725 timer_Stop(&cbcp->fsm.timer); in cbcp_Input()
726 datalink_NCPUp(cbcp->p->dl); in cbcp_Input()
727 } else if (cbcp->fsm.state == CBCP_RESPSENT) { in cbcp_Input()
728 timer_Stop(&cbcp->fsm.timer); in cbcp_Input()
729 datalink_CBCPComplete(cbcp->p->dl); in cbcp_Input()
730 log_Printf(LogPHASE, "%s: CBCP: Peer will dial back\n", p->dl->name); in cbcp_Input()
732 log_Printf(LogCBCP, "%s: unexpected ACK dropped\n", p->dl->name); in cbcp_Input()
737 head->code, len); in cbcp_Input()
748 timer_Stop(&cbcp->fsm.timer); in cbcp_Down()
750 cbcp->required = 0; in cbcp_Down()
756 if (p->dl->cbcp.fsm.state == CBCP_ACKSENT) { in cbcp_ReceiveTerminateReq()
758 p->dl->cbcp.required = 1; in cbcp_ReceiveTerminateReq()
759 log_Printf(LogPHASE, "%s: CBCP: Will dial back on %s\n", p->dl->name, in cbcp_ReceiveTerminateReq()
760 p->dl->cbcp.fsm.phone); in cbcp_ReceiveTerminateReq()
762 cbcp_NewPhase(&p->dl->cbcp, CBCP_CLOSED); in cbcp_ReceiveTerminateReq()