Deleted Added
full compact
datalink.c (38174) datalink.c (38200)
1/*-
2 * Copyright (c) 1998 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 *
1/*-
2 * Copyright (c) 1998 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 * $Id: datalink.c,v 1.16 1998/07/03 17:24:37 brian Exp $
26 * $Id: datalink.c,v 1.17 1998/08/07 18:42:48 brian Exp $
27 */
28
29#include <sys/types.h>
30#include <netinet/in.h>
31#include <netinet/in_systm.h>
32#include <netinet/ip.h>
33#include <sys/un.h>
34

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

239 break;
240 /* fall through */
241
242 case DATALINK_OPENING:
243 if (dl->dial_timer.state != TIMER_RUNNING) {
244 if (--dl->dial_tries < 0)
245 dl->dial_tries = 0;
246 if (modem_Open(dl->physical, dl->bundle) >= 0) {
27 */
28
29#include <sys/types.h>
30#include <netinet/in.h>
31#include <netinet/in_systm.h>
32#include <netinet/ip.h>
33#include <sys/un.h>
34

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

239 break;
240 /* fall through */
241
242 case DATALINK_OPENING:
243 if (dl->dial_timer.state != TIMER_RUNNING) {
244 if (--dl->dial_tries < 0)
245 dl->dial_tries = 0;
246 if (modem_Open(dl->physical, dl->bundle) >= 0) {
247 log_WritePrompts(dl, "%s: Entering terminal mode on %s\r\n"
248 "Type `~?' for help\r\n", dl->name,
249 dl->physical->name.full);
247 if (dl->script.run) {
248 datalink_NewState(dl, DATALINK_DIAL);
249 chat_Init(&dl->chat, dl->physical, dl->cfg.script.dial, 1,
250 datalink_ChoosePhoneNumber(dl));
251 if (!(dl->physical->type & (PHYS_DDIAL|PHYS_DEDICATED)) &&
252 dl->cfg.dial.max)
253 log_Printf(LogCHAT, "%s: Dial attempt %u of %d\n",
254 dl->name, dl->cfg.dial.max - dl->dial_tries,
255 dl->cfg.dial.max);
256 return datalink_UpdateSet(d, r, w, e, n);
257 } else
258 datalink_LoginDone(dl);
259 } else {
260 if (!(dl->physical->type & (PHYS_DDIAL|PHYS_DEDICATED)) &&
261 dl->cfg.dial.max)
262 log_Printf(LogCHAT, "Failed to open modem (attempt %u of %d)\n",
250 if (dl->script.run) {
251 datalink_NewState(dl, DATALINK_DIAL);
252 chat_Init(&dl->chat, dl->physical, dl->cfg.script.dial, 1,
253 datalink_ChoosePhoneNumber(dl));
254 if (!(dl->physical->type & (PHYS_DDIAL|PHYS_DEDICATED)) &&
255 dl->cfg.dial.max)
256 log_Printf(LogCHAT, "%s: Dial attempt %u of %d\n",
257 dl->name, dl->cfg.dial.max - dl->dial_tries,
258 dl->cfg.dial.max);
259 return datalink_UpdateSet(d, r, w, e, n);
260 } else
261 datalink_LoginDone(dl);
262 } else {
263 if (!(dl->physical->type & (PHYS_DDIAL|PHYS_DEDICATED)) &&
264 dl->cfg.dial.max)
265 log_Printf(LogCHAT, "Failed to open modem (attempt %u of %d)\n",
263 dl->cfg.dial.max - dl->dial_tries, dl->cfg.dial.max);
266 dl->cfg.dial.max - dl->dial_tries, dl->cfg.dial.max);
264 else
265 log_Printf(LogCHAT, "Failed to open modem\n");
266
267 if (dl->bundle->CleaningUp ||
268 (!(dl->physical->type & (PHYS_DDIAL|PHYS_DEDICATED)) &&
269 dl->cfg.dial.max && dl->dial_tries == 0)) {
270 datalink_NewState(dl, DATALINK_CLOSED);
271 dl->reconnect_tries = 0;
272 dl->dial_tries = -1;
267 else
268 log_Printf(LogCHAT, "Failed to open modem\n");
269
270 if (dl->bundle->CleaningUp ||
271 (!(dl->physical->type & (PHYS_DDIAL|PHYS_DEDICATED)) &&
272 dl->cfg.dial.max && dl->dial_tries == 0)) {
273 datalink_NewState(dl, DATALINK_CLOSED);
274 dl->reconnect_tries = 0;
275 dl->dial_tries = -1;
276 log_WritePrompts(dl, "Failed to open %s\n",
277 dl->physical->name.full);
273 bundle_LinkClosed(dl->bundle, dl);
274 }
278 bundle_LinkClosed(dl->bundle, dl);
279 }
275 if (!dl->bundle->CleaningUp)
280 if (!dl->bundle->CleaningUp) {
281 log_WritePrompts(dl, "Failed to open %s, pause %d seconds\n",
282 dl->physical->name.full, dl->cfg.dial.timeout);
276 datalink_StartDialTimer(dl, dl->cfg.dial.timeout);
283 datalink_StartDialTimer(dl, dl->cfg.dial.timeout);
284 }
277 }
278 }
279 break;
280
281 case DATALINK_HANGUP:
282 case DATALINK_DIAL:
283 case DATALINK_LOGIN:
284 result = descriptor_UpdateSet(&dl->chat.desc, r, w, e, n);

--- 978 unchanged lines hidden ---
285 }
286 }
287 break;
288
289 case DATALINK_HANGUP:
290 case DATALINK_DIAL:
291 case DATALINK_LOGIN:
292 result = descriptor_UpdateSet(&dl->chat.desc, r, w, e, n);

--- 978 unchanged lines hidden ---