head 1.21; access; symbols new_system:1.13 old_system:1.12; locks alexis:1.21; strict; comment @ * @; 1.21 date 99.04.26.16.18.44; author alexis; state Exp; branches; next 1.20; 1.20 date 99.01.07.13.16.49; author alexis; state Exp; branches; next 1.19; 1.19 date 98.10.17.12.57.02; author alexis; state Exp; branches; next 1.18; 1.18 date 98.10.07.16.43.38; author alexis; state Exp; branches; next 1.17; 1.17 date 98.08.31.12.41.40; author alexis; state Exp; branches; next 1.16; 1.16 date 98.08.30.21.10.29; author alexis; state Exp; branches; next 1.15; 1.15 date 98.08.29.16.44.57; author alexis; state Exp; branches; next 1.14; 1.14 date 98.08.28.13.12.38; author alexis; state Exp; branches; next 1.13; 1.13 date 98.08.08.09.47.47; author alexis; state Exp; branches; next 1.12; 1.12 date 98.08.07.14.49.25; author alexis; state Exp; branches; next 1.11; 1.11 date 98.08.07.11.28.42; author alexis; state Exp; branches; next 1.10; 1.10 date 97.11.11.12.01.38; author alexis; state Exp; branches; next 1.9; 1.9 date 97.10.26.12.12.30; author alexis; state Exp; branches; next 1.8; 1.8 date 97.03.06.13.07.33; author alexis; state Exp; branches; next 1.7; 1.7 date 97.02.25.17.52.25; author alexis; state Exp; branches; next 1.6; 1.6 date 97.02.21.17.07.03; author alexis; state Exp; branches; next 1.5; 1.5 date 97.02.16.14.44.55; author alexis; state Exp; branches; next 1.4; 1.4 date 97.02.16.13.37.39; author alexis; state Exp; branches; next 1.3; 1.3 date 97.02.15.11.15.55; author alexis; state Exp; branches; next 1.2; 1.2 date 97.02.09.16.00.50; author alexis; state Exp; branches; next 1.1; 1.1 date 97.02.01.21.52.17; author alexis; state Exp; branches; next ; desc @MILEPOST - WORKS @ 1.21 log @formalised function return types used larger buffer size for a few string buffers @ text @#include /* for SIG* */ #include /* for strerror() */ #include /* for errno */ #include /* for exit() */ #include "ppplcd.h" /* for c queue defs */ #include "utils.h" /* for DBG_* */ #include "ppplcd_ipc.h" /* for forward refs */ #include "ppplcd_msgids.h" /* for message ids */ #include "patchlevel.h" /* for forward ref */ #include "ppplcd_cfg.h" /* for forward refs */ #include "ppplcd_mhf.h" /* for PPPLCD_MHF_MAXSTRLEN */ #define HUPID_UNSET -1 #define HUPID_QUALITY 1 #define HUPID_IDLE 2 #define HUPID_HANGUP 3 #define ANNID_UP 0 #define ANNID_DOWN_QUALITY_REDIAL 1 #define ANNID_DOWN_QUALITY_NOREDIAL 2 #define ANNID_DOWN_REMOTE_REDIAL 3 #define ANNID_DOWN_REMOTE_NOREDIAL 4 #define ANNID_DOWN_IDLE_NOREDIAL 5 #define ANNID_DOWN_HANGUP_NOREDIAL 6 #define INFID_RESERVED -1000 int reason_down = HUPID_UNSET; static char *rcs_id = "$Header: /diskb/home/alexis/dev/supported/ppplc/bin/RCS/ppplcd_mhf.c,v 1.20 1999/01/07 13:16:49 alexis Exp alexis $"; static int ipup_part1(void); static int ipup_part2(void); static int ipup_part3(void); static int ipup_part4(void); /* * Global data - idle check info, no real need to initialise here, they * get initialised as the first idle check is queued, but it looks nice * in reports. */ int idle_oldusecnt = -1; unsigned long idle_oldusetim = 0; static int ppp_interface_no = -1; /****************************************************************************** * * MESSAGE HANDLING FUNCTIONS * ******************************************************************************/ int mhf_load_config( int *notusedp) { debug(DBG_FUNCS, "mhf_load_config: sof"); load_config("master.cfg", 0); } int mhf_gen_config( int *notusedp) { debug(DBG_FUNCS, "mhf_gen_config: sof"); gen_config(); } int mhf_set_autoreconnect( int *notusedp) { autoreconnect_flag = 1; } int mhf_unset_autoreconnect( int *notusedp) { autoreconnect_flag = 0; } int mhf_info_request( int *parp) { int info_requester = *parp; int parcnt; int *mp; int rc; debug(DBG_FUNCS, "mhf_info_request: sof"); parcnt = (svrmsginfo_data+lookup_msginfo(svrmsginfo_data, MSGID_INFO_DATA))->argc; if (parcnt == 0) { internal("mhf_info_request: lookup says MSGID_INFO_DATA has no pars"); } else if ((mp=(int *) calloc(sizeof(int), parcnt)) == NULL) error("calloc: %s", strerror(errno)); /* * Read/Write parameters */ *(mp+0) = state_want; *(mp+1) = state_quit; *(mp+2) = do_xfer_news_flag; *(mp+3) = autoreconnect_flag; *(mp+4) = debug_level; *(mp+5) = idle_timeout; *(mp+6) = quality_minlevel; *(mp+7) = quality_interval; *(mp+8) = INFID_RESERVED; *(mp+9) = INFID_RESERVED; *(mp+10) = INFID_RESERVED; *(mp+11) = INFID_RESERVED; *(mp+12) = INFID_RESERVED; *(mp+13) = INFID_RESERVED; *(mp+14) = INFID_RESERVED; *(mp+15) = INFID_RESERVED; *(mp+16) = INFID_RESERVED; *(mp+17) = INFID_RESERVED; *(mp+18) = INFID_RESERVED; *(mp+19) = INFID_RESERVED; /* * Read-only parameters */ *(mp+20) = state_curr; *(mp+21) = state_cfgok; *(mp+22) = state_donemx; *(mp+23) = state_donenx; *(mp+24) = state_inipup; *(mp+25) = ipc_mode; *(mp+26) = ipc_owner; *(mp+27) = ipc_group; *(mp+28) = INFID_RESERVED; *(mp+29) = INFID_RESERVED; *(mp+30) = INFID_RESERVED; *(mp+31) = INFID_RESERVED; *(mp+32) = INFID_RESERVED; *(mp+33) = INFID_RESERVED; *(mp+34) = INFID_RESERVED; *(mp+35) = INFID_RESERVED; *(mp+36) = INFID_RESERVED; *(mp+37) = INFID_RESERVED; *(mp+38) = INFID_RESERVED; *(mp+39) = INFID_RESERVED; if (rc=ipc_queue_submit(svrmsginfo_data, info_requester, time(NULL), MSGID_INFO_DATA, mp)) error("IPC queue submit failed"); free(mp); } int mhf_del_msgid( int *parp) { c_queue_del_msgid(*parp); } int mhf_sub_msgids( int *parp) { c_queue_sub_msgid(*parp, *(parp+1)); } int mhf_exec_pppd( int *notusedp) { char cmdbuf[512]; debug(DBG_FUNCS, "mhf_exec_pppd: sof"); /* * what about regenning the chat file? should that do here? no - another * step is needed - so that ppp-on results in MSGID_EXEC_PREPPPD getting * queued, and then this checks doregen_flag, if it's set - which the * server does at startup - then the file get's regenerated by a fork * and send sort of thing - perhaps not forking - and the flag gets * cleared, either way, the next step should be to queueu MSGID_EXEC_PPPD * - either in mhf_exec_prepppd - which would be the non-forking function * mentioned above - or should it fork? could be slow? - note that it * would be queued from there only if the regen was *not* necessary, * otherwise it would be queed from mhf_ok_prepppd(). */ if (state_curr) { warning("already connected or attempt in progress!"); return; } if (!state_cfgok) { warning("config has not yet been successfully loaded"); return; } state_want = 1; sprintf(cmdbuf, "%s %s %d connect \"%s -v -f %s\" crtscts defaultroute lock netmask %s noipdefault asyncmap 0x00000000 mru %d mtu %d lcp-echo-interval 180 -detach lcp-echo-interval 0 kdebug %d%s", pppd_cmd, port, speed, chat_cmd, chatfile, netmask, mru, mtu, pppd_kdebug, pppd_debug ? " debug" : ""); reason_down = HUPID_UNSET; fork_and_submit_rc_ipc_msg(cmdbuf, MSGID_OK_PPPD, MSGID_NOK_PPPD); } int mhf_exec_named( int *statusp) { static int last_request = -1; char cmdbuf[512]; if (*statusp != last_request) { sprintf(cmdbuf, "%s %d", named_modifier_cmd, *statusp); fork_and_submit_rc_ipc_msg(cmdbuf, MSGID_OK_NAMED, MSGID_NOK_NAMED); last_request = *statusp; } } int mhf_ok_named( int *notusedp) { if (state_inipup) ipup_part2(); } int mhf_nok_named( int *notusedp) { mhf_ok_named(notusedp); } int mhf_exec_announce( int *annidp) { char cmdbuf[512]; sprintf(cmdbuf, "%s %d", announce_cmd, *annidp); fork_and_submit_rc_ipc_msg(cmdbuf, MSGID_NOACTION, MSGID_NOACTION); } int mhf_ok_pppd( int *notusedp) { int announce_id; int *mp; int *intp; debug(DBG_FUNCS, "mhf_ok_pppd: sof"); /* * This first paragraph is a list of things that have to be done * very very urgently, they match 1 to 1 with stuff done in * mhf_exec_ipup() before link tests. */ ppp_interface_no = -1; state_inipup = 0; if (*named_modifier_cmd != '\0') { if ((intp = (int *) calloc(sizeof(int), 1)) == NULL) error("calloc: %s", strerror(errno)); *intp = 0; c_queue_submit(time(NULL), MSGID_EXEC_NAMED, intp); } /* * Normal stuff follows. */ if (state_curr) { state_curr = 0; switch (reason_down) { /* * If the remote end hangs up either because of idle or bad line * or whatever then we take the decision to redial or not on * what the user has specified for this situation. */ case HUPID_UNSET: state_want = autoreconnect_flag; announce_id = (state_want) ? ANNID_DOWN_REMOTE_REDIAL : ANNID_DOWN_REMOTE_NOREDIAL; break; case HUPID_QUALITY: state_want = autoreconnect_flag; announce_id = (state_want) ? ANNID_DOWN_QUALITY_REDIAL : ANNID_DOWN_QUALITY_NOREDIAL; break; case HUPID_HANGUP: state_want = 0; announce_id = ANNID_DOWN_HANGUP_NOREDIAL; break; case HUPID_IDLE: state_want = 0; announce_id = ANNID_DOWN_IDLE_NOREDIAL; break; default: internal("(%s,%d) unexpected down reason: %d", __FILE__, __LINE__, reason_down); break; } if ((mp=(int *) calloc(sizeof(int), 1)) == NULL) error("calloc: %s", strerror(errno)); *mp = announce_id; c_queue_submit(time(NULL), MSGID_EXEC_ANNOUNCE, mp); c_queue_del_msgid(MSGID_EXEC_USECNT); c_queue_del_msgid(MSGID_EXEC_QTEST); } if (state_want) c_queue_submit(time(NULL), MSGID_EXEC_PPPD, NULL); } int mhf_nok_pppd( int *notusedp) { debug(DBG_FUNCS, "mhf_nok_pppd: sof"); mhf_ok_pppd(notusedp); } int mhf_exec_ipup( int *ifnop) { debug(DBG_FUNCS, "mhf_exec_ipup: sof"); ppp_interface_no = *ifnop; /* note interface number */ state_inipup = 1; ipup_part1(); } int mhf_exec_qtest( int *notusedp) { char cmdbuf[PPPLCD_MHF_MAXSTRLEN]; debug(DBG_FUNCS, "mhf_exec_qtest: sof"); fork_and_submit_rc_ipc_msg(qtest_cmd, MSGID_OK_QTEST, MSGID_NOK_QTEST); } int mhf_ok_qtest( int *notusedp) { debug(DBG_FUNCS, "mhf_ok_qtest: sof"); /* * qualitycheck_flag is likely to be on, hey!, or why would we be here in * the first place? but it could have been turned off while the test was * running, so we check again. */ if (quality_interval && quality_minlevel && state_curr && state_want) { debug(DBG_QUALIDLE, "mhf_ok_qtest: requeuing qtest check for %d secs", quality_interval); c_queue_submit(time(NULL)+quality_interval, MSGID_EXEC_QTEST, NULL); } else debug(DBG_QUALIDLE, "mhf_ok_qtest: NOT requeuing qtest"); } int mhf_nok_qtest( int *notusedp) { debug(DBG_FUNCS, "mhf_nok_qtest: sof"); mhf_ok_qtest(notusedp); } int mhf_qtest_response( int *qualityp) { /* * goodqual !goodqual * ----------------------------------- * ininup | do main ipup kill without announce * !inipup | do nothing kill with announce */ if (*qualityp < quality_minlevel) if (!state_curr && state_inipup) /* up but unannounced pending tests */ kill_pppd(ppp_interface_no); else { reason_down = HUPID_QUALITY; kill_pppd(ppp_interface_no); } else if (!state_curr && state_inipup) ipup_part3(); else ; } int mhf_exec_mail( int *notusedp) { debug(DBG_FUNCS|DBG_SPECIAL1, "mhf_exec_mail: sof"); fork_and_submit_rc_ipc_msg(mail_cmd, MSGID_OK_MAIL, MSGID_NOK_MAIL); } int mhf_nok_mail( int *notusedp) { debug(DBG_FUNCS, "mhf_nok_mail: sof"); mhf_ok_mail(notusedp); } int mhf_ok_mail( int *notusedp) { debug(DBG_FUNCS, "mhf_ok_mail: sof"); if (!state_inipup) return; state_donemx = 1; ipup_part4(); } int mhf_exec_misc( int *notusedp) { debug(DBG_FUNCS, "mhf_exec_misc: sof"); fork_and_submit_rc_ipc_msg(misc_cmd, MSGID_NOACTION, MSGID_NOACTION); } int mhf_exec_news( int *notusedp) { debug(DBG_FUNCS, "mhf_exec_news: sof"); fork_and_submit_rc_ipc_msg(news_cmd, MSGID_OK_NEWS, MSGID_NOK_NEWS); } int mhf_nok_news( int *notusedp) { debug(DBG_FUNCS, "mhf_nok_news: sof"); mhf_ok_news(notusedp); } int mhf_ok_news( int *notusedp) { debug(DBG_FUNCS, "mhf_ok_news: sof"); if (!state_inipup) return; state_donenx = 1; ipup_part4(); } int mhf_exec_usecnt( int *parp) { char cmdbuf[512]; debug(DBG_FUNCS, "mhf_exec_usecnt: sof"); sprintf(cmdbuf, "%s ppp%d", usecnt_cmd, *parp); fork_and_submit_rc_ipc_msg(cmdbuf, MSGID_OK_USECNT, MSGID_NOK_USECNT); } int mhf_ok_usecnt( int *notusedp) { int *ifnop; debug(DBG_FUNCS, "mhf_ok_usecnt: sof"); if (idle_timeout && state_curr && state_want) { debug(DBG_QUALIDLE, "mhf_ok_usecnt: requeuing idle check for %d secs", idle_timeout/4); if ((ifnop=(int *) calloc(sizeof(int), 1)) == NULL) error("calloc: %s", strerror(errno)); *ifnop = ppp_interface_no; c_queue_submit(time(NULL)+idle_timeout/4, MSGID_EXEC_USECNT, ifnop); } else debug(DBG_QUALIDLE, "mhf_ok_usecnt: NOT requeuing idle check"); } int mhf_nok_usecnt( int *notusedp) { debug(DBG_FUNCS, "mhf_nok_usecnt: sof"); mhf_ok_usecnt(notusedp); } int mhf_usecnt_response( int *usecountp) { /* * countrisen !countrisen * ----------------------------------- * expired | update last count kill with announce * !expired | update last count do nothing */ if (*usecountp == idle_oldusecnt && time(NULL) > idle_oldusetim + idle_timeout) { debug(DBG_QUALIDLE, "mhf_exec_usecnt: idle and limit expired"); reason_down = HUPID_IDLE; kill_pppd(ppp_interface_no); } else if (*usecountp == idle_oldusecnt) { debug(DBG_QUALIDLE, "mhf_exec_usecnt: idle but limit not expired yet"); } else { debug(DBG_QUALIDLE, "mhf_exec_usecnt: not idle"); idle_oldusetim = time(NULL); idle_oldusecnt = *usecountp; } } int mhf_set_debug( int *debug_levelp) { debug(DBG_FUNCS, "mhf_set_debug: sof"); /* * Note that the mhf functions currently take integers as parameters * and that debug_level is a long. Really the parameter should be the * address of a union of int, unsigned long and char *. And the * mhf functions should extract the bit they want. But we'll leave * that for the time being. */ debug_level = (unsigned long) *debug_levelp; } int mhf_set_quality( int *new_qualityp) { debug(DBG_FUNCS, "mhf_set_quality: sof"); c_queue_del_msgid(MSGID_EXEC_QTEST); quality_minlevel = *new_qualityp; quality_interval = *(new_qualityp+1); if (quality_minlevel > 0 && quality_interval > 0 && state_curr && state_want) c_queue_submit(time(NULL), MSGID_EXEC_QTEST, NULL); } int mhf_set_idlepars( int *idle_timeoutp) { int i; int *ifnop; debug(DBG_FUNCS, "mhf_set_idlepars: sof"); c_queue_del_msgid(MSGID_EXEC_USECNT); if (*idle_timeoutp > 0 && idle_timeout == 0) { idle_oldusecnt = -1; idle_oldusetim = 0; } idle_timeout = *idle_timeoutp; if (idle_timeout > 0 && state_curr && state_want) { if ((ifnop=(int *) calloc(sizeof(int), 1)) == NULL) error("calloc: %s", strerror(errno)); *ifnop = ppp_interface_no; c_queue_submit(time(NULL), MSGID_EXEC_USECNT, ifnop); } } int mhf_set_quit( int *notusedp) { debug(DBG_FUNCS, "mhf_set_quit: sof"); state_quit = !state_quit; } int mhf_set_donews( int *notusedp) { debug(DBG_FUNCS, "mhf_set_donews: sof"); do_xfer_news_flag = 1; } int mhf_unset_donews( int *notusedp) { debug(DBG_FUNCS, "mhf_unset_donews: sof"); do_xfer_news_flag = 0; } int mhf_hangup( int *notusedp) { debug(DBG_FUNCS, "mhf_hangup: sof"); state_want = 0; if (state_curr) { reason_down = HUPID_HANGUP; kill_pppd(ppp_interface_no); } } int mhf_exec_ipdown( int *notusedp) { debug(DBG_FUNCS, "mhf_exec_ipdown: sof"); /* * note ppp_interface_no is cleared when pppd exits - it's more certain * to be done there than here (e.g. kill -9 on running pppd will not * result in this function getting called. */ } int mhf_noaction( int *notusedp) { debug(DBG_FUNCS, "mhf_noaction: sof"); } /****************************************************************************** * * 'QUICK' FUNCTIONS * *******************************************************************************/ static int ipup_part1() { int *intp; debug(DBG_FUNCS, "ipup_part1 (nsswitcher): sof"); if (!state_want) return(kill_pppd(ppp_interface_no)); if (*named_modifier_cmd != '\0') { if ((intp = (int *) calloc(sizeof(int), 1)) == NULL) error("calloc: %s", strerror(errno)); *intp = 1; c_queue_submit(time(NULL), MSGID_EXEC_NAMED, intp); } else ipup_part2(); } static int ipup_part2() { debug(DBG_FUNCS, "ipup_part2 (quality tester): sof"); if (!state_want) return(kill_pppd(ppp_interface_no)); if (quality_interval && quality_minlevel) c_queue_submit(time(NULL), MSGID_EXEC_QTEST, NULL); else ipup_part3(); } ipup_part3() { char cmdbuf[PPPLCD_MHF_MAXSTRLEN]; int *mp; int *ifnop; debug(DBG_FUNCS, "ipup_part3 (announce, news, mail, misc): sof"); if (!state_want) return(kill_pppd(ppp_interface_no)); if ((mp=(int *) calloc(sizeof(int), 1)) == NULL) error("calloc: %s", strerror(errno)); *mp = ANNID_UP; c_queue_submit(time(NULL), MSGID_EXEC_ANNOUNCE, mp); state_curr = 1; /* * Do mail, news, misc and idle checks concurrently */ if (*misc_cmd != '\0') c_queue_submit(time(NULL), MSGID_EXEC_MISC, NULL); if (idle_timeout) { idle_oldusecnt = -1; idle_oldusetim = 0; if ((ifnop=(int *) calloc(sizeof(int), 1)) == NULL) error("calloc: %s", strerror(errno)); *ifnop = ppp_interface_no; c_queue_submit(time(NULL), MSGID_EXEC_USECNT, ifnop); } state_donenx = state_donemx = 0; if (*mail_cmd == '\0' && (*news_cmd == '\0' || !do_xfer_news_flag)) ipup_part4(); else { if (*news_cmd != '\0' && do_xfer_news_flag) c_queue_submit(time(NULL), MSGID_EXEC_NEWS, NULL); if (*mail_cmd != '\0') c_queue_submit(time(NULL), MSGID_EXEC_MAIL, NULL); } } ipup_part4() { debug(DBG_FUNCS|DBG_SPECIAL1, "ipup_part4 (placeholder): sof"); if ((*mail_cmd != '\0' && !state_donemx) || (*news_cmd != '\0' && do_xfer_news_flag && !state_donenx)) return; debug(DBG_FUNCS|DBG_SPECIAL1, "ipup_part4 (placeholder): post-exclusions"); state_inipup = 0; } @ 1.20 log @cleanup code removed (tmpfile removal done elsewhere) RCS Id is now Header @ text @d12 1 d31 1 a31 1 static char *rcs_id = "$Header: ppplcd_mhf.c,v 1.19 1998/10/17 12:57:02 alexis Exp alexis $"; d54 2 a55 1 mhf_load_config() d61 2 a62 1 mhf_gen_config() d68 2 a69 1 mhf_set_autoreconnect() d74 2 a75 1 mhf_unset_autoreconnect() d80 1 a80 1 mhf_info_request( d151 1 a151 1 mhf_del_msgid( d157 1 a157 1 mhf_sub_msgids( d163 2 a164 1 mhf_exec_pppd() d200 1 a200 1 mhf_exec_named( d213 2 a214 1 mhf_ok_named() d219 2 a220 1 mhf_nok_named() d222 1 a222 1 mhf_ok_named(); d225 1 a225 1 mhf_exec_announce( d234 2 a235 1 mhf_ok_pppd() d305 2 a306 1 mhf_nok_pppd() d309 1 a309 1 mhf_ok_pppd(); d312 1 a312 1 mhf_exec_ipup( d321 2 a322 1 mhf_exec_qtest() d324 1 a324 1 char cmdbuf[128]; d330 2 a331 1 mhf_ok_qtest() d348 2 a349 1 mhf_nok_qtest() d352 1 a352 1 mhf_ok_qtest(); d355 1 a355 1 mhf_qtest_response( d380 2 a381 1 mhf_exec_mail() d387 2 a388 1 mhf_nok_mail() d391 1 a391 1 mhf_ok_mail(); d394 2 a395 1 mhf_ok_mail() d404 2 a405 1 mhf_exec_misc() d411 2 a412 1 mhf_exec_news() d418 2 a419 1 mhf_nok_news() d422 1 a422 1 mhf_ok_news(); d425 2 a426 1 mhf_ok_news() d435 1 a435 1 mhf_exec_usecnt( d445 2 a446 1 mhf_ok_usecnt() d462 2 a463 1 mhf_nok_usecnt() d466 1 a466 1 mhf_ok_usecnt(); d469 1 a469 1 mhf_usecnt_response( d492 1 a492 1 mhf_set_debug( d508 1 a508 1 mhf_set_quality( d522 1 a522 1 mhf_set_idlepars( d547 2 a548 1 mhf_set_quit() d555 2 a556 1 mhf_set_donews() d563 2 a564 1 mhf_unset_donews() d571 2 a572 1 mhf_hangup() d582 2 a583 1 mhf_exec_ipdown() d595 2 a596 1 mhf_noaction() d636 1 a636 1 char cmdbuf[128]; @ 1.19 log @removed info messages added support for optional config commands in ip-up 1-4 @ text @d30 1 a30 1 static char *rcs_id = "$Id: ppplcd_mhf.c,v 1.18 1998/10/07 16:43:38 alexis Exp alexis $"; d141 1 a141 2 if (rc=ipc_queue_submit(svrmsginfo_data, info_requester, time(NULL), MSGID_INFO_DATA, mp)) { cleanup(); a142 1 } @ 1.18 log @shorted many private preprocessor names chopped ip-up functionality into four parts which are linked by queued messages and their responses - specifically: part1 ends calling nsswitcher, part2 is called when nsswitcher completes part2 ends calling qtest, part3 is called when qtest response recieved part3 ends calling news&mail, part4 is called when news and mail complete absrtacted ppp interface number - we hold it in a static delinted switched to simpified error() calls temporary use of cleanup() instead of ppplcdexit() - we need delonexit() functionality added nsswitcher support remove all queued up use counts on ip-down or pppd exit kill_pppd() now takes parameter - abstraction semi-complete @ text @d14 3 a16 3 #define HUPID_QUALITY 1 #define HUPID_IDLE 2 #define HUPID_HANGUP 3 d20 1 a20 1 #define ANNID_DOWN_QUALITY_NOREDIAL 2 d22 1 a22 1 #define ANNID_DOWN_REMOTE_NOREDIAL 4 d26 1 a26 1 #define INFID_RESERVED -1000 d30 1 a30 1 static char *rcs_id = "$Id: ppplcd_mhf.c,v 1.17 1998/08/31 12:41:40 alexis Exp alexis $"; a55 2 info("loading config"); a61 2 info("generating chat script"); a164 1 info("dialling"); d244 1 a244 1 if (named_modifier_cmd != NULL) { a285 1 info("announcing that pppd has finished"); a307 2 info("calling ip-up"); a317 2 info("testing link quality"); d371 1 a371 3 debug(DBG_FUNCS, "mhf_exec_mail: sof"); info("transferring mail"); a398 2 info("transferring news"); a423 1 info("checking idle"); a550 2 info("hanging up"); a567 1 info("running ip-down"); d585 1 a585 1 debug(DBG_SPECIAL1, "ipup_part1 (nsswitcher): running"); d588 1 a588 1 if (named_modifier_cmd != NULL) { d599 1 a599 1 debug(DBG_SPECIAL1, "ipup_part2 (quality tester): running"); d614 1 a614 1 debug(DBG_SPECIAL1, "ipup_part3 (announce, news, mail, misc): running"); d627 3 a629 5 state_donenx = state_donemx = 0; c_queue_submit(time(NULL), MSGID_EXEC_MAIL, NULL); c_queue_submit(time(NULL), MSGID_EXEC_MISC, NULL); if (do_xfer_news_flag) c_queue_submit(time(NULL), MSGID_EXEC_NEWS, NULL); a632 1 d639 9 a647 4 /* * We get to part4 when mail *or* news complete. But note that * part4 really only gets going when it knows *both* are complete. */ d652 2 a653 1 if (!state_donemx || (!state_donenx && do_xfer_news_flag)) d656 1 a656 1 debug(DBG_SPECIAL1, "ipup_part4 (placeholder): running"); @ 1.17 log @added function to handle requests to delete mesaages qtest and idle cancellations use delete-msgid instead of sub-msgid @ text @d13 23 a35 18 #define PPPLCD_HANGUP_ID_UNSET -1 #define PPPLCD_HANGUP_ID_QUALITY 1 #define PPPLCD_HANGUP_ID_IDLE 2 #define PPPLCD_HANGUP_ID_HANGUP 3 #define PPPLCD_ANNOUNCE_ID_UP 0 #define PPPLCD_ANNOUNCE_ID_DOWN_QUALITY_REDIAL 1 #define PPPLCD_ANNOUNCE_ID_DOWN_QUALITY_NOREDIAL 2 #define PPPLCD_ANNOUNCE_ID_DOWN_REMOTE_REDIAL 3 #define PPPLCD_ANNOUNCE_ID_DOWN_REMOTE_NOREDIAL 4 #define PPPLCD_ANNOUNCE_ID_DOWN_IDLE_NOREDIAL 5 #define PPPLCD_ANNOUNCE_ID_DOWN_HANGUP_NOREDIAL 6 #define RESERVED -1000 int reason_down = PPPLCD_HANGUP_ID_UNSET; static char *rcs_id = "$Id: ppplcd_mhf.c,v 1.16 1998/08/30 21:10:29 alexis Exp alexis $"; d45 7 d92 2 a93 4 } else if ((mp=(int *) calloc(sizeof(int), parcnt)) == NULL) { error(exit, 1, "calloc: %s", strerror[errno]); exit(1); } d107 12 a118 12 *(mp+8) = RESERVED; *(mp+9) = RESERVED; *(mp+10) = RESERVED; *(mp+11) = RESERVED; *(mp+12) = RESERVED; *(mp+13) = RESERVED; *(mp+14) = RESERVED; *(mp+15) = RESERVED; *(mp+16) = RESERVED; *(mp+17) = RESERVED; *(mp+18) = RESERVED; *(mp+19) = RESERVED; d132 17 a148 15 *(mp+28) = RESERVED; *(mp+29) = RESERVED; *(mp+30) = RESERVED; *(mp+31) = RESERVED; *(mp+32) = RESERVED; *(mp+33) = RESERVED; *(mp+34) = RESERVED; *(mp+35) = RESERVED; *(mp+36) = RESERVED; *(mp+37) = RESERVED; *(mp+38) = RESERVED; *(mp+39) = RESERVED; if (rc=ipc_queue_submit(svrmsginfo_data, info_requester, time(NULL), MSGID_INFO_DATA, mp)) error(ppplcdexit, 1, "IPC queue submit failed"); d197 1 a197 1 reason_down = PPPLCD_HANGUP_ID_UNSET; d201 23 d237 1 d241 19 d270 1 a270 1 case PPPLCD_HANGUP_ID_UNSET: d272 1 a272 1 announce_id = (state_want) ? PPPLCD_ANNOUNCE_ID_DOWN_REMOTE_REDIAL : PPPLCD_ANNOUNCE_ID_DOWN_REMOTE_NOREDIAL; d274 1 a274 1 case PPPLCD_HANGUP_ID_QUALITY: d276 1 a276 1 announce_id = (state_want) ? PPPLCD_ANNOUNCE_ID_DOWN_QUALITY_REDIAL : PPPLCD_ANNOUNCE_ID_DOWN_QUALITY_NOREDIAL; d278 1 a278 1 case PPPLCD_HANGUP_ID_HANGUP: d280 1 a280 1 announce_id = PPPLCD_ANNOUNCE_ID_DOWN_HANGUP_NOREDIAL; d282 1 a282 1 case PPPLCD_HANGUP_ID_IDLE: d284 1 a284 1 announce_id = PPPLCD_ANNOUNCE_ID_DOWN_IDLE_NOREDIAL; d292 2 a293 4 if ((mp=(int *) calloc(sizeof(int), 1)) == NULL) { error(exit, 1, "calloc: %s", strerror[errno]); exit(1); } d296 2 d310 2 a311 5 /* * IPUP Functions */ mhf_exec_ipup() d316 3 a318 23 if (state_want) { state_inipup = 1; if (quality_interval && quality_minlevel) { debug(DBG_QUALIDLE, "mhf_exec_ipup: queuing immediate qtest execution"); c_queue_submit(time(NULL), MSGID_EXEC_QTEST, NULL); } else { debug(DBG_QUALIDLE, "mhf_exec_ipup: NOT queuing immediate qtest execution"); just_got_good_conn(); } } else { /* * pppd was on its way up and the kill got issued, but there is * no lock file while it's going up so the kill won't have * worked - cos the lock file is interface specific - it only * appears when the connection is up - so we don't know what * process to kill, and if we do go through the ps listing then * i think it ignored signals at that time anyway. All that * can be done is we wait until we get here and kill it now. */ kill_pppd(); } a356 45 debug(DBG_FUNCS, "mhf_qtest_response: sof"); info("processing link quality information"); /* * If the quality reported by the quality checking program is insufficient * then kill the connection. We leave it to 'ip-down' to report this * if necessary. */ if (*qualityp < quality_minlevel) { debug(DBG_QUALIDLE, "mhf_qtest_response: bad quality"); /* * The reason should only be read if we have already announced we * are up. Doesn't really matter if it isn't since the ipdown function * also interrogates state_curr before producing a message. */ reason_down = PPPLCD_HANGUP_ID_QUALITY; kill_pppd(); } else if (!state_curr && state_inipup) { debug(DBG_QUALIDLE, "mhf_qtest_response: good quality"); just_got_good_conn(); } else debug(DBG_QUALIDLE, "mhf_qtest_response: good quality"); } just_got_good_conn() { char cmdbuf[128]; int *mp; debug(DBG_FUNCS, "just_got_good_conn: sof"); /* * Don't pursue the normal routine if the user has changed their mind * while the quality test was running. There are no further actions * required (hopefully); the instruction to kill the pppd process should * have been issued elsewhere. */ if (!state_want) return; d358 4 a361 1 * Announce it! d364 13 a376 23 info("announcing connection is up"); if ((mp=(int *) calloc(sizeof(int), 1)) == NULL) { error(exit, 1, "calloc: %s", strerror[errno]); exit(1); } *mp = PPPLCD_ANNOUNCE_ID_UP; c_queue_submit(time(NULL), MSGID_EXEC_ANNOUNCE, mp); state_curr = 1; /* * Do mail, news, misc and idle checks concurrently */ state_donenx = state_donemx = 0; c_queue_submit(time(NULL), MSGID_EXEC_MAIL, NULL); c_queue_submit(time(NULL), MSGID_EXEC_MISC, NULL); if (do_xfer_news_flag) c_queue_submit(time(NULL), MSGID_EXEC_NEWS, NULL); if (idle_timeout) { idle_oldusecnt = -1; idle_oldusetim = 0; c_queue_submit(time(NULL), MSGID_EXEC_USECNT, NULL); } a378 4 /* * MAIL functions */ d396 4 a399 5 if (state_inipup) { state_donemx = 1; if (state_donenx || !do_xfer_news_flag) state_inipup = 0; } a401 4 /* * MISC functions */ a406 3 /* * NEWS functions */ d425 4 a428 5 if (state_inipup) { state_donenx = 1; if (state_donemx) state_inipup = 0; } d431 2 a432 1 mhf_exec_usecnt() d434 2 a435 5 FILE *fp; char buf[128]; char iface[8]; int recd, sent, junk, use; d437 1 d439 1 a439 2 fork_and_submit_rc_ipc_msg(usecnt_cmd, MSGID_OK_USECNT, MSGID_NOK_USECNT); d444 2 d450 4 a453 1 c_queue_submit(time(NULL)+idle_timeout/4, MSGID_EXEC_USECNT, NULL); d467 6 a472 2 debug(DBG_FUNCS, "mhf_usecnt_response: sof"); info("processing link usage count information"); d476 2 a477 2 reason_down = PPPLCD_HANGUP_ID_IDLE; kill_pppd(); d521 1 d534 6 a539 2 if (idle_timeout > 0 && state_curr && state_want) c_queue_submit(time(NULL), MSGID_EXEC_USECNT, NULL); d568 5 a572 3 reason_down = PPPLCD_HANGUP_ID_HANGUP; if (kill_pppd() != 0) state_want = 0; d578 7 d591 82 @ 1.16 log @simplified idle timeout change command and quality interval change command code. @ text @d30 1 a30 1 static char *rcs_id = "$Id: ppplcd_mhf.c,v 1.15 1998/08/29 16:44:57 alexis Exp alexis $"; d140 6 d534 1 a534 1 c_queue_sub_msgid(MSGID_EXEC_QTEST, MSGID_NOACTION); d550 1 a550 1 c_queue_sub_msgid(MSGID_EXEC_USECNT, MSGID_NOACTION); @ 1.15 log @corrected missing variable in dump data list @ text @d30 1 a30 1 static char *rcs_id = "$Id: ppplcd_mhf.c,v 1.14 1998/08/28 13:12:38 alexis Exp alexis $"; d526 1 a526 3 int old_quality_interval = quality_interval; int old_quality_minlevel = quality_minlevel; int i; d528 1 a528 1 debug(DBG_FUNCS, "mhf_set_quality: sof"); a531 15 /* * if we want quality checks, but didn't before, and we're connected * and we want to be connected then initiate quality checking. (If we're * merely changing the settings slightly then just let the other functions * take care of it. */ if (quality_interval && quality_minlevel && !(old_quality_interval && old_quality_minlevel) && state_curr && state_want) c_queue_submit(time(NULL), MSGID_EXEC_QTEST, NULL); /* * If we're no longer doing quality checks (regardless of whether before * *that* we were or not) then dequeue all pending quality checks. */ d533 2 a534 2 else if (!quality_interval || !quality_minlevel) c_queue_sub_msgid(MSGID_EXEC_QTEST, MSGID_NOACTION); d544 7 a550 8 if (*idle_timeoutp > 0) { if (!idle_timeout) { idle_oldusecnt = -1; idle_oldusetim = 0; c_queue_submit(time(NULL), MSGID_EXEC_USECNT, NULL); } } else c_queue_sub_msgid(MSGID_EXEC_USECNT, MSGID_NOACTION); d552 3 @ 1.14 log @milepost @ text @d30 1 a30 1 static char *rcs_id = "$Id: ppplcd_mhf.c,v 1.13 1998/08/08 09:47:47 alexis Exp alexis $"; d90 8 a97 7 *(mp+2) = state_quit; *(mp+3) = do_xfer_news_flag; *(mp+4) = autoreconnect_flag; *(mp+5) = debug_level; *(mp+6) = idle_timeout; *(mp+7) = quality_minlevel; *(mp+8) = quality_interval; @ 1.13 log @new system - heavily modified to use alarms @ text @a0 4 #define NEW_SYSTEM 1 #define OLD_SYSTEM (!(NEW_SYSTEM)) #include "ppplcd.h" /* for delayq defs */ d4 3 d26 2 d30 1 a30 1 static char *rcs_id = "$Id: ppplcd_mhf.c,v 1.12 1998/08/07 14:49:25 alexis Exp $"; d67 2 a68 2 mhf_info( int *info_requestp) d70 14 a83 1 int i; d85 3 a87 1 debug(DBG_FUNCS, "mhf_info: sof"); d89 19 a107 4 if (!(debug_level & DBG_INFO)) { debug_level |= DBG_INFO; debug(DBG_INFO, "turning info messages on"); } d109 3 a111 41 if (*info_requestp == 1) { info("FLAGS AND STATES"); info("state_cfgok: %d\tstate_curr: %d", state_cfgok, state_curr); info("state_want: %d\tstate_done: %d", state_want, state_done); info("state_donenx: %d\tstate_donemx: %d", state_donenx, state_donemx); info("state_inipup: %d\tstate_quit: %d", state_inipup, state_quit); info("ipc_owner: %d\tipc_group %d", ipc_owner, ipc_group); info("ipc_perms: %o", ipc_perms); info("do_xfer_news_flag: %d\tautoreconnect: %d", do_xfer_news_flag, autoreconnect_flag); info("pppd_debug: %d\tpppd_kdebug: %d", pppd_debug, pppd_kdebug); info("debug_level: %ld", debug_level); delayqueue_show(); info("IDLE AND QUALITY CHECKING"); info("idle_oldusecnt: %d\tidle_oldusetim: %ld", idle_oldusecnt, idle_oldusetim); info("idle_timeout: %d", idle_timeout); info("quality_minlevel: %d\tquality_interval: %d", quality_minlevel, quality_interval); } else if (*info_requestp == 3) { info("COMMANDS"); info("sndmail: %s", sndmail_cmd); info("getmail: %s", getmail_cmd); info("sndnews: %s", sndnews_cmd); info("getnews: %s", getnews_cmd); info("mail: %s", mail_cmd); info("news: %s", news_cmd); info("qtest: %s", qtest_cmd); info("usecnt: %s", usecnt_cmd); info("announce: %s", announce_cmd); } else if (*info_requestp == 0) info("version %s", patchlevel); else if (*info_requestp == 2) { info("VALID MESSAGES"); for (i=0; svrmsginfdat[i].id != MSGID_LAST_MARKER; i+=2) if (svrmsginfdat[i+1].id != MSGID_LAST_MARKER) info("%2d (%d): %-15s\t\t%2d (%d): %-15s", svrmsginfdat[i].id, svrmsginfdat[i].argc, svrmsginfdat[i].cmt, svrmsginfdat[i+1].id, svrmsginfdat[i+1].argc, svrmsginfdat[i+1].cmt); else { info("%2d (%d): %-15s", svrmsginfdat[i].id, svrmsginfdat[i].argc, svrmsginfdat[i].cmt); break; } } else warning("invalid information request type: %d", *info_requestp); d113 30 a142 2 /* ppplcd_ipc_send_msg(MSGTO_INFO, buf); ppplcd_ipc_send_msg(MSGTO_INFO, "."); */ a169 3 /* if (!state_cfgok) - don't bother trying to load it if it failed gen_config(); */ a175 1 state_done = 0; d179 10 a188 1 forkandsend(cmdbuf, MSGID_OK_PPPD, MSGID_NOK_PPPD); a192 1 char cmdbuf[512]; d194 1 a197 5 #if OLD_SYSTEM delayq_top = 0; this should generate an error signal(SIGALRM, SIG_IGN); #endif d228 1 d230 6 a235 2 sprintf(cmdbuf, "%s %d", announce_cmd, announce_id); forkandsend(cmdbuf, MSGID_NOACTION, MSGID_NOACTION); d239 1 a239 5 #if OLD_SYSTEM ppplcd_ipc_send_msg(svrmsginfdat, MSGTO_SVR, MSGID_EXEC_PPPD, NULL); #else delayqueue_send(time(NULL), MSGID_EXEC_PPPD, NULL); #endif d261 1 a261 5 #if OLD_SYSTEM ppplcd_ipc_send_msg(svrmsginfdat, MSGTO_SVR, MSGID_EXEC_QTEST, NULL); #else delayqueue_send(time(NULL), MSGID_EXEC_QTEST, NULL); #endif d289 1 a289 1 forkandsend(qtest_cmd, MSGID_OK_QTEST, MSGID_NOK_QTEST); d304 1 a304 1 delayqueue_send(time(NULL)+quality_interval, MSGID_EXEC_QTEST, NULL); d316 1 a316 1 int *info_requestp) d327 1 a327 1 if (*info_requestp < quality_minlevel) { d349 1 d368 6 a373 4 sprintf(cmdbuf, "%s %d", announce_cmd, PPPLCD_ANNOUNCE_ID_UP); debug(DBG_SPECIAL1, "just_got_good_conn: calling: %s", cmdbuf); forkandsend(cmdbuf, MSGID_NOACTION, MSGID_NOACTION); state_done = 1; d377 1 a377 1 * Do mail, news and idle checks concurrently d381 2 a382 5 #if OLD_SYSTEM ppplcd_ipc_send_msg(svrmsginfdat, MSGTO_SVR, MSGID_EXEC_MAIL, NULL); #else delayqueue_send(time(NULL), MSGID_EXEC_MAIL, NULL); #endif d384 1 a384 5 #if OLD_SYSTEM ppplcd_ipc_send_msg(svrmsginfdat, MSGTO_SVR, MSGID_EXEC_NEWS, NULL); #else delayqueue_send(time(NULL), MSGID_EXEC_NEWS, NULL); #endif d388 1 a388 5 #if OLD_SYSTEM ppplcd_ipc_send_msg(svrmsginfdat, MSGTO_SVR, MSGID_EXEC_USECNT, NULL); #else delayqueue_send(time(NULL), MSGID_EXEC_USECNT, NULL); #endif d401 1 a401 1 forkandsend(mail_cmd, MSGID_OK_MAIL, MSGID_NOK_MAIL); d421 9 d438 1 a438 1 forkandsend(news_cmd, MSGID_OK_NEWS, MSGID_NOK_NEWS); a456 118 #if OLD_SYSTEM /* * SNDMAIL Functions */ mhf_exec_sndmail() { debug(DBG_FUNCS, "mhf_exec_sndmail: sof"); info("sending mail"); forkandsend(sndmail_cmd, MSGID_OK_SNDMAIL, MSGID_NOK_SNDMAIL); } mhf_ok_sndmail() { debug(DBG_FUNCS, "mhf_ok_sndmail: sof"); if (state_inipup) ppplcd_ipc_send_msg(svrmsginfdat, MSGTO_SVR, MSGID_EXEC_GETMAIL, NULL); } mhf_nok_sndmail() { debug(DBG_FUNCS, "mhf_nok_sndmail: sof"); mhf_ok_sndmail(); } /* * GETMAIL Functions */ mhf_exec_getmail() { debug(DBG_FUNCS, "mhf_exec_getmail: sof"); info("getting mail"); forkandsend(getmail_cmd, MSGID_OK_GETMAIL, MSGID_NOK_GETMAIL); } mhf_ok_getmail() { debug(DBG_FUNCS, "mhf_ok_getmail: sof"); if (state_inipup) { state_donemx = 1; if (state_donemx && (state_donenx || !do_xfer_news_flag)) state_inipup = 0; } } mhf_nok_getmail() { debug(DBG_FUNCS, "mhf_nok_getmail: sof"); mhf_ok_getmail(); } /* * SNDNEWS Functions */ mhf_exec_sndnews() { debug(DBG_FUNCS, "mhf_exec_sndnews: sof"); info("sending news"); forkandsend(sndnews_cmd, MSGID_OK_SNDNEWS, MSGID_NOK_SNDNEWS); } mhf_ok_sndnews() { debug(DBG_FUNCS, "mhf_ok_sndnews: sof"); if (state_inipup) ppplcd_ipc_send_msg(svrmsginfdat, MSGTO_SVR, MSGID_EXEC_GETNEWS, NULL); } mhf_nok_sndnews() { debug(DBG_FUNCS, "mhf_nok_sndnews: sof"); mhf_ok_sndnews(); } /* * GETNEWS Functions */ mhf_exec_getnews() { debug(DBG_FUNCS, "mhf_exec_getnews: sof"); info("getting news"); forkandsend(getnews_cmd, MSGID_OK_GETNEWS, MSGID_NOK_GETNEWS); } mhf_ok_getnews() { debug(DBG_FUNCS, "mhf_ok_getnews: sof"); if (state_inipup) { state_donenx = 1; if (state_donemx && state_donenx) state_inipup = 0; } } mhf_nok_getnews() { debug(DBG_FUNCS, "mhf_nok_getnews: sof"); mhf_ok_getnews(); } #endif d467 1 a467 1 forkandsend(usecnt_cmd, MSGID_OK_USECNT, MSGID_NOK_USECNT); d476 1 a476 1 delayqueue_send(time(NULL)+idle_timeout/4, MSGID_EXEC_USECNT, NULL); d488 1 a488 1 int *info_requestp) d493 1 a493 1 if (*info_requestp == idle_oldusecnt && time(NULL) > idle_oldusetim + idle_timeout) { d497 1 a497 1 } else if (*info_requestp == idle_oldusecnt) { d502 1 a502 1 idle_oldusecnt = *info_requestp; d542 1 a542 5 #if OLD_SYSTEM ppplcd_ipc_send_msg(svrmsginfdat, MSGTO_SVR, MSGID_EXEC_QTEST, NULL); #else delayqueue_send(time(NULL), MSGID_EXEC_QTEST, NULL); #endif d550 1 a550 7 #if OLD_SYSTEM for (i=0; i idlecheck_oldusetim + idlecheck_timeout) { debug(DBG_IDLE, "mhf_exec_idle: idle and time limit expired!"); state_idle = 1; } else if (use == idlecheck_oldusecnt) { debug(DBG_IDLE, "mhf_exec_idle: idle"); } else { debug(DBG_IDLE, "mhf_exec_idle: not idle, saving current usage levels"); idlecheck_oldusetim = time(NULL); idlecheck_oldusecnt = use; } /* * Send a message to be acted on according to whether we have been idle * long enough or not. The code called could be incorporated here since * *this* function is so quick, but why bother? */ ppplcd_ipc_send_msg(svrmsginfdat, MSGTO_SVR, state_idle ? MSGID_NOK_IDLECHECK : MSGID_OK_IDLECHECK, NULL); d544 1 a544 1 mhf_ok_idle() d546 1 a546 1 debug(DBG_FUNCS, "mhf_ok_idle: sof"); d548 3 a550 3 if (idlecheck_timeout && state_curr) { debug(DBG_IDLE, "mhf_ok_idle: requeuing idle check for %d secs", idlecheck_interval); delaysendmsg(time(NULL)+idlecheck_interval, MSGID_EXEC_IDLECHECK, NULL); d552 1 a552 1 debug(DBG_IDLE, "mhf_ok_idle: NOT requeuing idle check"); d555 1 a555 1 mhf_nok_idle() d557 2 a558 4 debug(DBG_FUNCS, "mhf_nok_idle: sof"); reason_down = REAID_IDLE; kill_pppd(); d561 2 a562 1 mhf_unset_qualitycheck_interval() d564 2 a565 1 int q = 0; d567 11 a577 2 debug(DBG_FUNCS, "mhf_unset_qualitycheck_interval: sof"); mhf_set_qualitycheck_interval(&q); d596 2 a597 2 mhf_set_qualitycheck_interval( int *new_qualitycheck_intervalp) d599 2 a600 1 int old_qualitycheck_interval = qualitycheck_interval; d603 1 a603 1 debug(DBG_FUNCS, "mhf_set_qualitycheck_interval: sof"); d605 2 a606 1 qualitycheck_interval = *new_qualitycheck_intervalp; d609 4 a612 3 * if we require a positive quality and we have a positive interval but * didn't have one already! ... and of course we're connected and * want to be ... d615 1 a615 2 if (qualitycheck_interval && !old_qualitycheck_interval) { if (state_curr && state_want) d618 3 a620 3 /* * if it is the toggling of the quality interval that should deactivate * the delayed queued quality checks then cancel them now d623 1 a623 2 } else /* dequeuing could go here, instead od being in a separate function */ d626 1 a626 9 delayq[i].en = 0; } mhf_unset_idlecheck() { int i = 0; debug(DBG_FUNCS, "mhf_unset_idlecheck: sof"); mhf_set_idlecheck(&i); d629 2 a630 2 mhf_set_idlecheck( int *idlecheck_timeoutp) d634 1 a634 1 debug(DBG_FUNCS, "mhf_set_idlecheck: sof"); d636 5 a640 5 if (*idlecheck_timeoutp > 0) { if (!idlecheck_timeout) { idlecheck_oldusecnt = -1; idlecheck_oldusetim = 0; ppplcd_ipc_send_msg(svrmsginfdat, MSGTO_SVR, MSGID_EXEC_IDLECHECK, NULL); d644 3 a646 4 if (delayq[i].id == MSGID_EXEC_IDLECHECK) delayq[i].en = 0; idlecheck_timeout = *idlecheck_timeoutp; idlecheck_interval = idlecheck_timeout / 4; d673 1 d675 2 a676 3 reason_down = REAID_HANGUP; if (kill_pppd() != 0) { debug(DBG_SPECIAL1, "mhf_hangup: no lock file, noting we wish to disconnect"); a677 1 } d683 1 a689 1 @ 1.9 log @stamped for release 1.0.6 @ text @d5 1 a5 1 #include "ppplcd_utils.h" /* for DBG_* */ a9 1 #include "ppplcd.h" /* for ppplcdexit() */ d26 1 a26 1 static char *rcs_id = "$Id: ppplcd_mhf.c,v 1.8 1997/03/06 13:07:33 alexis Exp alexis $"; a86 1 info("qualitycheck_interval: %d\tqualitycheck_minquality: %d", qualitycheck_interval, qualitycheck_minquality); d95 4 d123 13 a135 9 /* what about regenning the chat file? should that do here? no - another step is needed - so that ppp-on results in MSGID_EXEC_PREPPPD getting queued, and then this checks doregen_flag, if it's set - which the server does at startup - then the file get's regenerated by a fork and send sort of thing - perhaps not forking - and the flag gets cleared, either way, the next step should be to queueu MSGID_EXEC_PPPD - either in mhf_exec_prepppd - which would be the non-forking function mentioned above - or should it fork? could be slow? - note that it would be queued from there only if the regen was *not* necessary, otherwise it would be queed from mhf_ok_prepppd(). */ d151 2 a152 2 sprintf(cmdbuf, "%s %s %d connect \"%s -v -f %s\" crtscts defaultroute lock netmask %s danae.demon.co.uk: asyncmap 0x00000000 mru 576 mtu 576 lcp-echo-interval 180 -detach lcp-echo-interval 0 kdebug %d%s", pppd_cmd, port, speed, chat_cmd, chatfile, netmask, pppd_kdebug, pppd_debug ? " debug" : ""); d229 1 a229 1 if (qualitycheck_interval && qualitycheck_minquality) { d258 1 a258 2 sprintf(cmdbuf, "%s %d %s", qtest_cmd, qualitycheck_minquality, qualitycheck_remhost); forkandsend(cmdbuf, MSGID_OK_QTEST, MSGID_NOK_QTEST); d272 1 a272 1 if (qualitycheck_minquality && qualitycheck_interval && state_curr && state_want) { d561 1 a561 1 if (qualitycheck_interval && !old_qualitycheck_interval && qualitycheck_minquality) { d570 1 a570 1 } else if (qualitycheck_minquality) @ 1.8 log @fixed format of message in mhf_info @ text @d27 1 a27 1 static char *rcs_id = "$Id: ppplcd_mhf.c,v 1.7 1997/02/25 17:52:25 alexis Exp alexis $"; @ 1.7 log @fsstnd conformancy abstracted xfer commands and added to config @ text @d27 1 a27 1 static char *rcs_id = "$Id: ppplcd_mhf.c,v 1.6 1997/02/21 17:07:03 alexis Exp alexis $"; d89 2 a90 2 info("ipc_owner: %d\nipc_group %d", ipc_owner, ipc_group); info("ipc_perms: %o\nipc_perms", ipc_perms); @ 1.6 log @info function now also reports ipc permissions @ text @a24 6 #define QTEST_CMD "/home/alexis/dev/ppp/qtest" #define SNDMAIL_CMD "/home/alexis/dev/ppp/sndmail" #define GETMAIL_CMD "/home/alexis/dev/ppp/getmail" #define SNDNEWS_CMD "/home/alexis/dev/ppp/sndnews" #define GETNEWS_CMD "/home/alexis/dev/ppp/getnews" d27 1 a27 1 static char *rcs_id = "$Id: ppplcd_mhf.c,v 1.5 1997/02/16 14:44:55 alexis Exp alexis $"; d252 1 a252 1 sprintf(cmdbuf, "%s %d %s", QTEST_CMD, qualitycheck_minquality, qualitycheck_remhost); d338 1 a338 1 forkandsend(SNDMAIL_CMD, MSGID_OK_SNDMAIL, MSGID_NOK_SNDMAIL); d364 1 a364 1 forkandsend(GETMAIL_CMD, MSGID_OK_GETMAIL, MSGID_NOK_GETMAIL); d393 1 a393 1 forkandsend(SNDNEWS_CMD, MSGID_OK_SNDNEWS, MSGID_NOK_SNDNEWS); d419 1 a419 1 forkandsend(GETNEWS_CMD, MSGID_OK_GETNEWS, MSGID_NOK_GETNEWS); @ 1.5 log @relocated ownership of state_curr and stat_want to ppplcd.c @ text @d33 1 a33 1 static char *rcs_id = "$Id: ppplcd_mhf.c,v 1.4 1997/02/16 13:37:39 alexis Exp alexis $"; d95 2 @ 1.4 log @News retrieval now only follows news transmission when in ip-up same goes for mail. @ text @a30 2 int state_curr = 0; int state_want = 0; d33 1 a33 1 static char *rcs_id = "$Id: ppplcd_mhf.c,v 1.3 1997/02/15 11:15:55 alexis Exp alexis $"; @ 1.3 log @Improved version information Reset last counts for idle info - this was resulting in immediate hangup when connecting a second time after an interval greater than the idle timeout interval @ text @d35 1 a35 1 static char *rcs_id = "$Id: ppplcd_mhf.c,v 1.2 1997/02/09 16:00:50 alexis Exp $"; d351 2 a352 1 ppplcd_ipc_send_msg(svrmsginfdat, MSGTO_SVR, MSGID_EXEC_GETMAIL, NULL); d406 2 a407 1 ppplcd_ipc_send_msg(svrmsginfdat, MSGTO_SVR, MSGID_EXEC_GETNEWS, NULL); @ 1.2 log @More changes ... now works. @ text @d35 1 a35 1 static char *rcs_id = "$Id: ppplcd_mhf.c,v 1.1 1997/02/01 21:52:17 alexis Exp alexis $"; d38 3 a40 1 * Global data - idle check info d103 3 a105 4 } else if (*info_requestp == 0) { info("PROGRAM: %s", progname); info("VERSION: %s", patchlevel); } else if (*info_requestp == 2) { d314 3 a316 1 if (idlecheck_timeout) d318 1 d351 1 a351 3 if (state_inipup) { ppplcd_ipc_send_msg(svrmsginfdat, MSGTO_SVR, MSGID_EXEC_GETMAIL, NULL); } d592 3 a594 1 if (!idlecheck_timeout) d596 1 @ 1.1 log @Initial revision @ text @d3 2 d10 1 d35 1 a35 1 static char *rcs_id = "$Id: ppplcd_mhf.c,v 1.1 1997/01/31 14:43:34 alexis Exp alexis $"; d90 2 a91 1 info("delayq (%d) in %ld secs, id %d, en %d", i, delayq[i].time-t, delayq[i].id, delayq[i].en); d233 1 a233 1 mhf_got_good_conn(); d265 2 a266 2 if (state_inipup) mhf_got_good_conn(); d280 1 a280 1 mhf_got_good_conn() d284 1 a284 1 debug(DBG_FUNCS, "mhf_got_good_conn: sof"); d456 2 a457 4 if ((fp=fopen("/proc/net/dev", "r")) == NULL) { perror("fopen"); exit(1); } @