source: npl/internetserver/poptop_ppp/patches/ppp-2.4.2-ifname.diff @ c5c522c

gcc484ntopperl-5.22
Last change on this file since c5c522c was c5c522c, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

initial commit, transferred from cleaned syn3 svn tree

  • Property mode set to 100644
File size: 4.3 KB
  • ./pppd/main.c

    old new  
    9898static const char rcsid[] = RCSID;
    9999
    100100/* interface vars */
    101 char ifname[32];                /* Interface name */
     101char ifname[MAXIFNAMELEN];      /* Interface name */
    102102int ifunit;                     /* Interface unit number */
    103103
    104104struct channel *the_channel;
     
    261261    NULL
    262262};
    263263
    264 /*
    265  * If PPP_DRV_NAME is not defined, use the default "ppp" as the device name.
    266  */
    267 #if !defined(PPP_DRV_NAME)
    268 #define PPP_DRV_NAME    "ppp"
    269 #endif /* !defined(PPP_DRV_NAME) */
    270 
    271264int
    272265main(argc, argv)
    273266    int argc;
     
    777770set_ifunit(iskey)
    778771    int iskey;
    779772{
    780     info("Using interface %s%d", PPP_DRV_NAME, ifunit);
     773    if (req_ifname[0] != '\0')
     774        slprintf(ifname, sizeof(ifname), req_ifname);
     775    else
    781776    slprintf(ifname, sizeof(ifname), "%s%d", PPP_DRV_NAME, ifunit);
     777    info("Using interface %s", ifname);
    782778    script_setenv("IFNAME", ifname, iskey);
    783779    if (iskey) {
    784780        create_pidfile(getpid());       /* write pid to file */
  • ./pppd/options.c

    old new  
    102102bool    tune_kernel;            /* may alter kernel settings */
    103103int     connect_delay = 1000;   /* wait this many ms after connect script */
    104104int     req_unit = -1;          /* requested interface unit */
     105char    req_ifname[MAXIFNAMELEN];       /* requested interface name */
    105106bool    multilink = 0;          /* Enable multilink operation */
    106107char    *bundle_name = NULL;    /* bundle name for multilink */
    107108bool    dump_options;           /* print out option values */
     
    259260      "PPP interface unit number to use if possible",
    260261      OPT_PRIO | OPT_LLIMIT, 0, 0 },
    261262
     263    { "ifname", o_string, req_ifname,
     264      "Set PPP interface name",
     265      OPT_PRIO | OPT_PRIV | OPT_STATIC, NULL, MAXIFNAMELEN },
     266
    262267    { "dump", o_bool, &dump_options,
    263268      "Print out option values after parsing all options", 1 },
    264269    { "dryrun", o_bool, &dryrun,
  • ./pppd/pppd.8

    old new  
    10201020.TP
    10211021.B unit \fInum
    10221022Sets the ppp unit number (for a ppp0 or ppp1 etc interface name) for outbound
    1023 connections.
     1023connections.  If the unit is already in use a dynamically allocated will be
     1024used.
     1025.TP
     1026.B ifname \fIstring
     1027Set the ppp interface name for outbound connections.  A failure to set the
     1028name will terminate the pppd.
    10241029.TP
    10251030.B updetach
    10261031With this option, pppd will detach from its controlling terminal once
  • ./pppd/pppd.h

    old new  
    8080#define MAXARGS         1       /* max # args to a command */
    8181#define MAXNAMELEN      256     /* max length of hostname or name for auth */
    8282#define MAXSECRETLEN    256     /* max length of password or secret */
     83#define MAXIFNAMELEN    32      /* max length of interface name; or use IFNAMSIZ, can we
     84                                   always include net/if.h? */
     85
     86/*
     87 * If PPP_DRV_NAME is not defined, use the default "ppp" as the device name.
     88 * Where should PPP_DRV_NAME come from? Do we include it here?
     89 */
     90#if !defined(PPP_DRV_NAME)
     91#define PPP_DRV_NAME    "ppp"
     92#endif /* !defined(PPP_DRV_NAME) */
    8393
    8494/*
    8595 * Option descriptor structure.
     
    304314extern int      connect_delay;  /* Time to delay after connect script */
    305315extern int      max_data_rate;  /* max bytes/sec through charshunt */
    306316extern int      req_unit;       /* interface unit number to use */
     317extern char     req_ifname[MAXIFNAMELEN];       /* interface name to use */
    307318extern bool     multilink;      /* enable multilink operation */
    308319extern bool     noendpoint;     /* don't send or accept endpt. discrim. */
    309320extern char     *bundle_name;   /* bundle name for multilink */
  • ./pppd/sys-linux.c

    old new  
    649649        }
    650650        if (x < 0)
    651651                error("Couldn't create new ppp unit: %m");
     652
     653        if (x == 0 && req_ifname[0] != '\0') {
     654                struct ifreq ifr;
     655                char t[MAXIFNAMELEN];
     656                memset(&ifr, 0, sizeof(struct ifreq));
     657                slprintf(t, sizeof(t), "%s%d", PPP_DRV_NAME, ifunit);
     658                strncpy(ifr.ifr_name, t, IF_NAMESIZE);
     659                strncpy(ifr.ifr_newname, req_ifname, IF_NAMESIZE);
     660                x = ioctl(sock_fd, SIOCSIFNAME, &ifr);
     661                if (x < 0)
     662                    error("Couldn't rename interface %s to %s: %m", t, req_ifname);
     663                else
     664                    info("Renamed interface %s to %s", t, req_ifname);
     665        }
     666
    652667        return x;
    653668}
    654669
Note: See TracBrowser for help on using the repository browser.