/[smeserver]/rpms/ppp/sme9/ppp-2.4.5-eth.patch
ViewVC logotype

Annotation of /rpms/ppp/sme9/ppp-2.4.5-eth.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (hide annotations) (download)
Wed Mar 6 22:45:24 2013 UTC (11 years, 7 months ago) by slords
Branch: MAIN
CVS Tags: ppp-2_4_5-24_fc19, ppp-2_4_5-24_el6_sme, HEAD
Initial import

1 slords 1.1 diff -up ppp-2.4.5/pppd/ether.c.inc.eth ppp-2.4.5/pppd/ether.c.inc
2     --- ppp-2.4.5/pppd/ether.c.inc.eth 2011-06-01 10:28:35.356139063 +0200
3     +++ ppp-2.4.5/pppd/ether.c.inc 2011-06-01 11:20:37.876897352 +0200
4     @@ -0,0 +1,46 @@
5     +#define PREF_ETH "eth"
6     +#define PREF_EM "em"
7     +
8     +static char *dev_file = "/proc/self/net/dev";
9     +
10     +/*
11     + * get_first_ethernet - return the name of the first ethernet-style
12     + * interface on this system.
13     + */
14     +char *
15     +get_first_ethernet()
16     +{
17     + FILE *f;
18     + char buf[255], *dv, *smc;
19     + char pci[16];
20     +
21     + memset(pci, 0, sizeof(pci));
22     + if ((f = fopen(dev_file, "r")) != NULL)
23     + {
24     + // go through network dev file
25     + while (fgets (buf, sizeof(buf), f) != NULL)
26     + {
27     + // the line describes interface
28     + if ((smc = strchr(buf, ':')) != NULL)
29     + {
30     + // trim white characters
31     + for (dv=buf, *smc=0; *dv <= ' '; dv++) ;
32     + // is "eth" (originial ethernet name) or "em" (ethernet on board)
33     + if (!strncmp(dv, PREF_ETH, strlen(PREF_ETH)) ||
34     + !strncmp(dv, PREF_EM, strlen(PREF_EM)))
35     + {
36     + return strdup(dv);
37     + }
38     + // remember the first pci NIC-card
39     + if (strlen(pci) == 0 && dv[0] == 'p' && isdigit(dv[1]))
40     + {
41     + strcpy(pci, dv);
42     + }
43     + }
44     + }
45     + fclose(f);
46     + }
47     + // return pci NIC-card or nil if no if name
48     + return strlen(pci) > 0 ? strdup(pci) : 0L;
49     +}
50     +
51     diff -up ppp-2.4.5/pppd/plugins/rp-pppoe/pppoe-discovery.c.eth ppp-2.4.5/pppd/plugins/rp-pppoe/pppoe-discovery.c
52     --- ppp-2.4.5/pppd/plugins/rp-pppoe/pppoe-discovery.c.eth 2011-06-01 09:39:13.099343548 +0200
53     +++ ppp-2.4.5/pppd/plugins/rp-pppoe/pppoe-discovery.c 2011-06-01 11:41:02.188252304 +0200
54     @@ -47,6 +47,8 @@
55     #include <net/if_arp.h>
56     #endif
57    
58     +#include "../../ether.c.inc"
59     +
60     char *xstrdup(const char *s);
61     void usage(void);
62    
63     @@ -686,7 +688,7 @@ int main(int argc, char *argv[])
64    
65     /* default interface name */
66     if (!conn->ifName)
67     - conn->ifName = strdup("eth0");
68     + conn->ifName = get_first_ethernet();
69    
70     conn->discoverySocket = -1;
71     conn->sessionSocket = -1;
72     diff -up ppp-2.4.5/pppd/sys-linux.c.eth ppp-2.4.5/pppd/sys-linux.c
73     --- ppp-2.4.5/pppd/sys-linux.c.eth 2011-06-01 09:39:13.074343397 +0200
74     +++ ppp-2.4.5/pppd/sys-linux.c 2011-06-01 11:50:13.736565685 +0200
75     @@ -144,6 +144,8 @@
76     #include <sys/locks.h>
77     #endif
78    
79     +#include "ether.c.inc"
80     +
81     #ifdef INET6
82     #ifndef _LINUX_IN6_H
83     /*
84     @@ -1869,16 +1871,6 @@ get_if_hwaddr(u_char *addr, char *name)
85     return ret;
86     }
87    
88     -/*
89     - * get_first_ethernet - return the name of the first ethernet-style
90     - * interface on this system.
91     - */
92     -char *
93     -get_first_ethernet()
94     -{
95     - return "eth0";
96     -}
97     -
98     /********************************************************************
99     *
100     * Return user specified netmask, modified by any mask we might determine
101     @@ -2783,6 +2775,7 @@ ether_to_eui64(eui64_t *p_eui64)
102     struct ifreq ifr;
103     int skfd;
104     const unsigned char *ptr;
105     + char warn_msg[80];
106    
107     skfd = socket_fd(PF_INET6, SOCK_DGRAM, 0);
108     if(skfd == -1)
109     @@ -2791,11 +2784,13 @@ ether_to_eui64(eui64_t *p_eui64)
110     return 0;
111     }
112    
113     - strcpy(ifr.ifr_name, "eth0");
114     + strcpy(ifr.ifr_name, get_first_ethernet());
115     if(ioctl(skfd, SIOCGIFHWADDR, &ifr) < 0)
116     {
117     close(skfd);
118     - warn("could not obtain hardware address for eth0");
119     + snprintf(warn_msg, sizeof(warn_msg),
120     + "could not obtain hardware address for %s", ifr.ifr_name);
121     + warn(warn_msg);
122     return 0;
123     }
124     close(skfd);

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed