home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / N / TCPIP / NETKIT-A.06 / NETKIT-A / NetKit-A-0.06 / dip337d-uri / slip.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-05  |  2.0 KB  |  92 lines

  1. /*
  2.  * dip        A program for handling dialup IP connecions.
  3.  *        This module handles the SLIP protocol.
  4.  *
  5.  * Version:    @(#)slip.c    3.3.3    08/16/93
  6.  *
  7.  * Author:      Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
  8.  *        Copyright 1988-1993 MicroWalt Corporation
  9.  *
  10.  *        This program is free software; you can redistribute it
  11.  *        and/or  modify it under  the terms of  the GNU General
  12.  *        Public  License as  published  by  the  Free  Software
  13.  *        Foundation;  either  version 2 of the License, or  (at
  14.  *        your option) any later version.
  15.  */
  16. #include "dip.h"
  17.  
  18.  
  19. /* SLIP protocol constants. */
  20. #define    END        0xC0        /* end-of-datagram marker    */
  21. #define    ESC        0xDB        /* Binary Escape marker        */
  22. #define    ESC_END        0xDC        /* Escaped END character    */
  23. #define    ESC_ESC        0xDD        /* Escaped ESCAPE character    */
  24.  
  25.  
  26. void
  27. do_slip(struct dip *dip)
  28. {
  29.   char ifname[32];
  30.  
  31.   (void) strcpy((char *) dip->protocol, "SLIP");
  32.  
  33.   /* Put line in SLIP discipline. */
  34.   if (tty_set_disc(N_SLIP) < 0) {
  35.     syslog(LOG_ERR, "SETD(N_SLIP): %m");
  36.     return;
  37.   }
  38.  
  39.   /* Disable VJ Header Compression. */
  40.   if (tty_set_encap(0x0000) < 0) {
  41.     syslog(LOG_ERR, "SET_ENCAP(VJ_COMP=0): %m");
  42.     return;
  43.   }
  44.  
  45.   /* Ask the kernel for the name of our interface. */
  46.   if (tty_get_name(ifname) < 0) {
  47.     syslog(LOG_ERR, "GIFNAME: %m");
  48.     (void) tty_set_disc(-1);
  49.     return;
  50.   }
  51.   
  52. #if 0
  53.   if (opt_v == 1) {
  54.       printf("DIP: Interface %s\n",ifname);
  55.   }
  56. #endif
  57.  
  58.   /* Add the route to that host. */
  59.   (void) attach(ifname, dip);
  60. }
  61.  
  62.  
  63. void
  64. do_cslip(struct dip *dip)
  65. {
  66.   char ifname[32];
  67.  
  68.   (void) strcpy((char *) dip->protocol, "CSLIP");
  69.  
  70.   /* Put line in SLIP discipline. */
  71.   if (tty_set_disc(N_SLIP) < 0) {
  72.     syslog(LOG_ERR, "SETD(N_SLIP): %m");
  73.     return;
  74.   }
  75.  
  76.   /* Enable VJ Header Compression. */
  77.   if (tty_set_encap(0x0001) < 0) {
  78.     syslog(LOG_ERR, "SET_ENCAP(VJ_COMP=1): %m");
  79.     return;
  80.   }
  81.  
  82.   /* Ask the kernel for the name of our interface. */
  83.   if (tty_get_name(ifname) < 0) {
  84.     syslog(LOG_ERR, "GIFNAME: %m");
  85.     (void) tty_set_disc(-1);
  86.     return;
  87.   }
  88.   
  89.   /* Add the route to that host. */
  90.   (void) attach(ifname, dip);
  91. }
  92.