1 --- linux-atm-2.4.1.orig/src/br2684/br2684ctl.c
2 +++ linux-atm-2.4.1/src/br2684/br2684ctl.c
8 +#include <sys/ioctl.h>
12 +#include <linux/atmdev.h>
13 +#include <linux/atmbr2684.h>
15 +/* Written by Marcell GAL <cell@sch.bme.hu> to make use of the */
16 +/* ioctls defined in the br2684... kernel patch */
17 +/* Compile with cc -o br2684ctl br2684ctl.c -latm */
20 + Modified feb 2001 by Stephen Aaskov (saa@lasat.com)
21 + - Added daemonization code
24 + TODO: Delete interfaces after exit?
28 +#define LOG_NAME "RFC1483/2684 bridge"
29 +#define LOG_OPTION LOG_PERROR
30 +#define LOG_FACILITY LOG_LOCAL0
33 +int lastsock, lastitf;
36 +void fatal(const char *str, int i)
38 + syslog (LOG_ERR,"Fatal: %s",str);
45 + syslog (LOG_PID,"Daemon terminated\n");
49 +int create_br(char *nstr)
54 + lastsock = socket(PF_ATMPVC, SOCK_DGRAM, ATM_AAL5);
57 + syslog(LOG_ERR, "socket creation failed: %s",strerror(errno));
59 + /* create the device with ioctl: */
61 + if( num>=0 && num<1234567890){
62 + struct atm_newif_br2684 ni;
63 + ni.backend_num = ATM_BACKEND_BR2684;
64 + ni.media = BR2684_MEDIA_ETHERNET;
66 + sprintf(ni.ifname, "nas%d", num);
67 + err=ioctl (lastsock, ATM_NEWBACKENDIF, &ni);
70 + syslog(LOG_INFO, "Interface \"%s\" created sucessfully\n",ni.ifname);
72 + syslog(LOG_INFO, "Interface \"%s\" could not be created, reason: %s\n",
75 + lastitf=num; /* even if we didn't create, because existed, assign_vcc wil want to know it! */
77 + syslog(LOG_ERR,"err: strange interface number %d", num );
84 +int assign_vcc(char *astr, int encap, int bufsize, struct atm_qos qos)
87 + struct sockaddr_atmpvc addr;
89 + struct atm_backend_br2684 be;
91 + memset(&addr, 0, sizeof(addr));
92 + err=text2atm(astr,(struct sockaddr *)(&addr), sizeof(addr), T2A_PVC);
94 + syslog(LOG_ERR,"Could not parse ATM parameters (error=%d)\n",err);
97 + addr.sap_family = AF_ATMPVC;
98 + addr.sap_addr.itf = itf;
99 + addr.sap_addr.vpi = 0;
100 + addr.sap_addr.vci = vci;
102 + syslog(LOG_INFO,"Communicating over ATM %d.%d.%d, encapsulation: %s\n", addr.sap_addr.itf,
105 + encap?"VC mux":"LLC");
107 + if ((fd = socket(PF_ATMPVC, SOCK_DGRAM, ATM_AAL5)) < 0)
108 + syslog(LOG_ERR,"failed to create socket %d, reason: %s", errno,strerror(errno));
110 + if (qos.aal == 0) {
111 + qos.aal = ATM_AAL5;
112 + qos.txtp.traffic_class = ATM_UBR;
113 + qos.txtp.max_sdu = 1524;
114 + qos.txtp.pcr = ATM_MAX_PCR;
115 + qos.rxtp = qos.txtp;
118 + if ( (err=setsockopt(fd,SOL_SOCKET,SO_SNDBUF, &bufsize ,sizeof(bufsize))) )
119 + syslog(LOG_ERR,"setsockopt SO_SNDBUF: (%d) %s\n",err, strerror(err));
121 + if (setsockopt(fd, SOL_ATM, SO_ATMQOS, &qos, sizeof(qos)) < 0)
122 + syslog(LOG_ERR,"setsockopt SO_ATMQOS %d", errno);
124 + err = connect(fd, (struct sockaddr*)&addr, sizeof(struct sockaddr_atmpvc));
127 + fatal("failed to connect on socket", err);
129 + /* attach the vcc to device: */
131 + be.backend_num = ATM_BACKEND_BR2684;
132 + be.ifspec.method = BR2684_FIND_BYIFNAME;
133 + sprintf(be.ifspec.spec.ifname, "nas%d", lastitf);
134 + be.fcs_in = BR2684_FCSIN_NO;
135 + be.fcs_out = BR2684_FCSOUT_NO;
137 + be.encaps = encap ? BR2684_ENCAPS_VC : BR2684_ENCAPS_LLC;
139 + be.send_padding = 0;
141 + err=ioctl (fd, ATM_SETBACKEND, &be);
143 + syslog (LOG_INFO,"Interface configured");
145 + syslog (LOG_ERR,"Could not configure interface:%s",strerror(errno));
154 + printf("usage: %s [-b] [[-c number] [-e 0|1] [-s sndbuf] [-q qos] [-a [itf.]vpi.vci]*]*\n", s);
160 +int main (int argc, char **argv)
162 + int c, background=0, encap=0, sndbuf=8192;
163 + struct atm_qos reqqos;
168 + memset(&reqqos, 0, sizeof(reqqos));
170 + openlog (LOG_NAME,LOG_OPTION,LOG_FACILITY);
172 + while ((c = getopt(argc, argv,"q:a:bc:e:s:?h")) !=EOF)
175 + printf ("optarg : %s",optarg);
176 + if (text2qos(optarg,&reqqos,0)) fprintf(stderr,"QOS parameter invalid\n");
179 + assign_vcc(optarg, encap, sndbuf, reqqos);
188 + encap=(atoi(optarg));
190 + syslog (LOG_ERR, "invalid encapsulation: %s:\n",optarg);
195 + sndbuf=(atoi(optarg));
197 + syslog(LOG_ERR, "Invalid sndbuf: %s, using size of 8192 instead\n",optarg);
209 + if (argc != optind) usage(argv[0]);
211 + if(lastsock>=0) close(lastsock);
218 + fprintf(stderr,"Error detaching\n");
221 + exit(0); // This is the parent
223 + // Become a process group and session group leader
225 + fprintf (stderr,"Could not set process group\n");
229 + // Fork again to let process group leader exit
232 + fprintf(stderr,"Error detaching during second fork\n");
235 + exit(0); // This is the parent
237 + // Now we're ready for buisness
238 + chdir("/"); // Don't keep directories in use
239 + close(0); close(1); close(2); // Close stdin, -out and -error
241 + Note that this implementation does not keep an open
243 + If we need them they can be opened now
248 + syslog (LOG_INFO, "RFC 1483/2684 bridge daemon started\n");
251 + while (1) sleep(30); /* to keep the sockets... */
255 diff -ruN linux-atm-2.4.1/configure.in linux-atm-2.4.1.new/configure.in
256 --- linux-atm-2.4.1/configure.in 2003-04-25 04:17:05.000000000 +0200
257 +++ linux-atm-2.4.1.new/configure.in 2005-07-27 15:45:49.532396543 +0200
260 src/include/Makefile \
262 - src/test/Makefile \
263 - src/debug/Makefile \
264 - src/qgen/Makefile \
265 - src/saal/Makefile \
266 - src/sigd/Makefile \
267 - src/maint/Makefile \
268 - src/arpd/Makefile \
269 - src/ilmid/Makefile \
270 - src/ilmid/asn1/Makefile \
273 - src/lane/Makefile \
274 - src/mpoad/Makefile \
275 - src/switch/Makefile \
276 - src/switch/debug/Makefile \
277 - src/switch/tcp/Makefile \
278 - src/config/Makefile \
279 - src/config/init-redhat/Makefile \
280 - src/extra/Makefile \
281 - src/extra/linux-atm.spec \
282 - src/extra/ANS/Makefile
283 + src/br2684/Makefile \
286 diff -ruN linux-atm-2.4.1/src/br2684/Makefile linux-atm-2.4.1.new/src/br2684/Makefile
287 --- linux-atm-2.4.1/src/br2684/Makefile 1970-01-01 02:00:00.000000000 +0200
288 +++ linux-atm-2.4.1.new/src/br2684/Makefile 2002-07-15 23:44:25.000000000 +0200
290 +PREFIX=${TI_FILESYSTEM}
294 +br2684ctl: br2684ctl.c
295 + gcc -latm -o br2684ctl br2684ctl.c
299 + cp br2684ctl $(PREFIX)/usr/sbin/
302 + rm -rf br2684ctl *.o
303 diff -ruN linux-atm-2.4.1/src/Makefile.am linux-atm-2.4.1.new/src/Makefile.am
304 --- linux-atm-2.4.1/src/Makefile.am 2001-10-03 23:14:53.000000000 +0200
305 +++ linux-atm-2.4.1.new/src/Makefile.am 2005-07-27 15:33:52.389309711 +0200
307 -SUBDIRS = include lib test debug qgen saal sigd maint arpd ilmid man led lane \
308 - mpoad switch config extra
309 +SUBDIRS = include lib br2684