X-Git-Url: http://git.ozlabs.org/?p=ppp.git;a=blobdiff_plain;f=pppd%2Fmain.c;h=f136a281291b297e8b81ace181b57397f0764d2a;hp=ffeaca09a91f5f639a1212ae5dec04bef6bf69c4;hb=f9f667ee187be5d34ac94f11bf366dd218191122;hpb=4d9b0517fa2dd0492cefa9eb0d56432fddf723cf;ds=sidebyside diff --git a/pppd/main.c b/pppd/main.c index ffeaca0..f136a28 100644 --- a/pppd/main.c +++ b/pppd/main.c @@ -66,7 +66,7 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#define RCSID "$Id: main.c,v 1.146 2004/11/12 11:21:41 paulus Exp $" +#define RCSID "$Id: main.c,v 1.149 2004/11/14 22:53:42 carlsonj Exp $" #include #include @@ -172,6 +172,7 @@ int devfd = -1; /* fd of underlying device */ int fd_ppp = -1; /* fd for talking PPP */ int phase; /* where the link is at */ int kill_link; +int asked_to_quit; int open_ccp_flag; int listen_time; int got_sigusr2; @@ -481,14 +482,8 @@ main(argc, argv) /* * Open the loopback channel and set it up to be the ppp interface. */ -#ifdef USE_TDB - tdb_writelock(pppdb); -#endif fd_loop = open_ppp_loopback(); set_ifunit(1); -#ifdef USE_TDB - tdb_writeunlock(pppdb); -#endif /* * Configure the interface and mark it up, etc. */ @@ -517,13 +512,13 @@ main(argc, argv) add_fd(fd_loop); for (;;) { handle_events(); - if (kill_link && !persist) + if (asked_to_quit) break; if (get_loop_output()) break; } remove_fd(fd_loop); - if (kill_link && !persist) + if (asked_to_quit) break; /* @@ -542,9 +537,10 @@ main(argc, argv) while (phase != PHASE_DEAD) { handle_events(); get_input(); - if (kill_link) { - bundle_terminating = 1; + if (kill_link) lcp_close(0, "User request"); + if (asked_to_quit) { + bundle_terminating = 1; if (phase == PHASE_MASTER) mp_bundle_terminated(); } @@ -556,7 +552,7 @@ main(argc, argv) } } - if (!persist || (maxfail > 0 && unsuccess >= maxfail)) + if (!persist || asked_to_quit || (maxfail > 0 && unsuccess >= maxfail)) break; if (demand) @@ -630,6 +626,7 @@ handle_events() if (got_sigterm) { info("Terminating on signal %d", got_sigterm); kill_link = 1; + asked_to_quit = 1; persist = 0; status = EXIT_USER_REQUEST; got_sigterm = 0; @@ -892,14 +889,54 @@ struct protocol_list { { 0x4b, "SNA over 802.2" }, { 0x4d, "SNA" }, { 0x4f, "IP6 Header Compression" }, + { 0x51, "KNX Bridging Data" }, + { 0x53, "Encryption" }, + { 0x55, "Individual Link Encryption" }, + { 0x57, "IPv6" }, + { 0x59, "PPP Muxing" }, + { 0x5b, "Vendor-Specific Network Protocol" }, + { 0x61, "RTP IPHC Full Header" }, + { 0x63, "RTP IPHC Compressed TCP" }, + { 0x65, "RTP IPHC Compressed non-TCP" }, + { 0x67, "RTP IPHC Compressed UDP 8" }, + { 0x69, "RTP IPHC Compressed RTP 8" }, { 0x6f, "Stampede Bridging" }, + { 0x73, "MP+" }, + { 0xc1, "NTCITS IPI" }, { 0xfb, "single-link compression" }, - { 0xfd, "1st choice compression" }, + { 0xfd, "Compressed Datagram" }, { 0x0201, "802.1d Hello Packets" }, { 0x0203, "IBM Source Routing BPDU" }, { 0x0205, "DEC LANBridge100 Spanning Tree" }, + { 0x0207, "Cisco Discovery Protocol" }, + { 0x0209, "Netcs Twin Routing" }, + { 0x020b, "STP - Scheduled Transfer Protocol" }, + { 0x020d, "EDP - Extreme Discovery Protocol" }, + { 0x0211, "Optical Supervisory Channel Protocol" }, + { 0x0213, "Optical Supervisory Channel Protocol" }, { 0x0231, "Luxcom" }, { 0x0233, "Sigma Network Systems" }, + { 0x0235, "Apple Client Server Protocol" }, + { 0x0281, "MPLS Unicast" }, + { 0x0283, "MPLS Multicast" }, + { 0x0285, "IEEE p1284.4 standard - data packets" }, + { 0x0287, "ETSI TETRA Network Protocol Type 1" }, + { 0x0289, "Multichannel Flow Treatment Protocol" }, + { 0x2063, "RTP IPHC Compressed TCP No Delta" }, + { 0x2065, "RTP IPHC Context State" }, + { 0x2067, "RTP IPHC Compressed UDP 16" }, + { 0x2069, "RTP IPHC Compressed RTP 16" }, + { 0x4001, "Cray Communications Control Protocol" }, + { 0x4003, "CDPD Mobile Network Registration Protocol" }, + { 0x4005, "Expand accelerator protocol" }, + { 0x4007, "ODSICP NCP" }, + { 0x4009, "DOCSIS DLL" }, + { 0x400B, "Cetacean Network Detection Protocol" }, + { 0x4021, "Stacker LZS" }, + { 0x4023, "RefTek Protocol" }, + { 0x4025, "Fibre Channel" }, + { 0x4027, "EMIT Protocols" }, + { 0x405b, "Vendor-Specific Protocol (VSP)" }, { 0x8021, "Internet Protocol Control Protocol" }, { 0x8023, "OSI Network Layer Control Protocol" }, { 0x8025, "Xerox NS IDP Control Protocol" }, @@ -919,17 +956,43 @@ struct protocol_list { { 0x804b, "SNA over 802.2 Control Protocol" }, { 0x804d, "SNA Control Protocol" }, { 0x804f, "IP6 Header Compression Control Protocol" }, - { 0x006f, "Stampede Bridging Control Protocol" }, + { 0x8051, "KNX Bridging Control Protocol" }, + { 0x8053, "Encryption Control Protocol" }, + { 0x8055, "Individual Link Encryption Control Protocol" }, + { 0x8057, "IPv6 Control Protovol" }, + { 0x8059, "PPP Muxing Control Protocol" }, + { 0x805b, "Vendor-Specific Network Control Protocol (VSNCP)" }, + { 0x806f, "Stampede Bridging Control Protocol" }, + { 0x8073, "MP+ Control Protocol" }, + { 0x80c1, "NTCITS IPI Control Protocol" }, { 0x80fb, "Single Link Compression Control Protocol" }, { 0x80fd, "Compression Control Protocol" }, + { 0x8207, "Cisco Discovery Protocol Control" }, + { 0x8209, "Netcs Twin Routing" }, + { 0x820b, "STP - Control Protocol" }, + { 0x820d, "EDPCP - Extreme Discovery Protocol Ctrl Prtcl" }, + { 0x8235, "Apple Client Server Protocol Control" }, + { 0x8281, "MPLSCP" }, + { 0x8285, "IEEE p1284.4 standard - Protocol Control" }, + { 0x8287, "ETSI TETRA TNP1 Control Protocol" }, + { 0x8289, "Multichannel Flow Treatment Protocol" }, { 0xc021, "Link Control Protocol" }, { 0xc023, "Password Authentication Protocol" }, { 0xc025, "Link Quality Report" }, { 0xc027, "Shiva Password Authentication Protocol" }, { 0xc029, "CallBack Control Protocol (CBCP)" }, + { 0xc02b, "BACP Bandwidth Allocation Control Protocol" }, + { 0xc02d, "BAP" }, + { 0xc05b, "Vendor-Specific Authentication Protocol (VSAP)" }, { 0xc081, "Container Control Protocol" }, { 0xc223, "Challenge Handshake Authentication Protocol" }, + { 0xc225, "RSA Authentication Protocol" }, + { 0xc227, "Extensible Authentication Protocol" }, + { 0xc229, "Mitsubishi Security Info Exch Ptcl (SIEP)" }, + { 0xc26f, "Stampede Bridging Authorization Protocol" }, { 0xc281, "Proprietary Authentication Protocol" }, + { 0xc283, "Proprietary Authentication Protocol" }, + { 0xc481, "Proprietary Node ID Authentication Protocol" }, { 0, NULL }, }; @@ -1923,6 +1986,41 @@ script_unsetenv(var) #endif } +/* + * Any arbitrary string used as a key for locking the database. + * It doesn't matter what it is as long as all pppds use the same string. + */ +#define PPPD_LOCK_KEY "pppd lock" + +/* + * lock_db - get an exclusive lock on the TDB database. + * Used to ensure atomicity of various lookup/modify operations. + */ +void lock_db() +{ +#ifdef USE_TDB + TDB_DATA key; + + key.dptr = PPPD_LOCK_KEY; + key.dsize = strlen(key.dptr); + tdb_chainlock(pppdb, key); +#endif +} + +/* + * unlock_db - remove the exclusive lock obtained by lock_db. + */ +void unlock_db() +{ +#ifdef USE_TDB + TDB_DATA key; + + key.dptr = PPPD_LOCK_KEY; + key.dsize = strlen(key.dptr); + tdb_chainunlock(pppdb, key); +#endif +} + #ifdef USE_TDB /* * update_db_entry - update our entry in the database.