+ printk (KERN_DEBUG "%s\n", line);
+ }
+}
+
+/*************************************************************
+ * Compressor module interface
+ *************************************************************/
+
+struct compressor_link {
+ struct compressor_link *next;
+ struct compressor *comp;
+};
+
+static struct compressor_link *ppp_compressors = (struct compressor_link *) 0;
+
+static struct compressor *find_compressor (int type)
+{
+ struct compressor_link *lnk;
+ __u32 flags;
+
+ save_flags(flags);
+ cli();
+
+ lnk = ppp_compressors;
+ while (lnk != (struct compressor_link *) 0) {
+ if ((int) (__u8) lnk->comp->compress_proto == type) {
+ restore_flags(flags);
+ return lnk->comp;
+ }
+ lnk = lnk->next;
+ }
+
+ restore_flags(flags);
+ return (struct compressor *) 0;
+}
+
+static int ppp_register_compressor (struct compressor *cp)
+{
+ struct compressor_link *new;
+ __u32 flags;
+
+ new = (struct compressor_link *) kmalloc (sizeof (struct compressor_link), GFP_KERNEL);
+
+ if (new == (struct compressor_link *) 0)
+ return 1;
+
+ save_flags(flags);
+ cli();
+
+ if (find_compressor (cp->compress_proto)) {
+ restore_flags(flags);
+ kfree (new);
+ return 0;
+ }
+
+ new->next = ppp_compressors;
+ new->comp = cp;
+ ppp_compressors = new;
+
+ restore_flags(flags);
+ return 0;
+}
+
+static void ppp_unregister_compressor (struct compressor *cp)
+{
+ struct compressor_link *prev = (struct compressor_link *) 0;
+ struct compressor_link *lnk;
+ __u32 flags;
+
+ save_flags(flags);
+ cli();
+
+ lnk = ppp_compressors;
+ while (lnk != (struct compressor_link *) 0) {
+ if (lnk->comp == cp) {
+ if (prev)
+ prev->next = lnk->next;
+ else
+ ppp_compressors = lnk->next;
+ kfree (lnk);
+ break;
+ }
+ prev = lnk;
+ lnk = lnk->next;
+ }
+ restore_flags(flags);
+}
+
+/*************************************************************
+ * Module support routines
+ *************************************************************/
+
+#ifdef MODULE
+int
+init_module(void)
+{
+ int status;
+
+ /* register our line disciplines */
+ status = ppp_first_time();
+ if (status != 0)
+ printk (KERN_INFO
+ "PPP: ppp_init() failure %d\n", status);
+ else
+ (void) register_symtab (&ppp_syms);
+ return (status);
+}
+
+void
+cleanup_module(void)
+{
+ int status;
+ ppp_ctrl_t *ctl, *next_ctl;
+ struct device *dev;
+ struct ppp *ppp;
+ int busy_flag = 0;
+/*
+ * Ensure that the devices are not in operation.
+ */
+ ctl = ppp_list;
+ while (ctl) {
+ ppp = ctl2ppp (ctl);
+ if (ppp->inuse && ppp->tty != NULL) {
+ busy_flag = 1;
+ break;
+ }
+
+ dev = ctl2dev (ctl);
+ if (dev->start || dev->flags & IFF_UP) {
+ busy_flag = 1;
+ break;
+ }
+ ctl = ctl->next;
+ }
+/*
+ * Ensure that there are no compressor modules registered
+ */
+ if (ppp_compressors != NULL)
+ busy_flag = 1;
+
+ if (busy_flag) {
+ printk (KERN_INFO
+ "PPP: device busy, remove delayed\n");
+ return;
+ }
+/*
+ * Release the tty registration of the line discipline so that no new entries
+ * may be created.
+ */
+ status = tty_register_ldisc (N_PPP, NULL);
+ if (status != 0)
+ printk (KERN_INFO
+ "PPP: Unable to unregister ppp line discipline "
+ "(err = %d)\n", status);
+ else
+ printk (KERN_INFO
+ "PPP: ppp line discipline successfully unregistered\n");
+/*
+ * De-register the devices so that there is no problem with them
+ */
+ next_ctl = ppp_list;
+ while (next_ctl) {
+ ctl = next_ctl;
+ next_ctl = ctl->next;
+ ppp = ctl2ppp (ctl);
+ dev = ctl2dev (ctl);
+
+ ppp_release (ppp);
+ unregister_netdev (dev);
+ kfree (ctl);