1 diff -ruN linux-atm-2.4.1/configure.in linux-atm-2.4.1.new/configure.in
2 --- linux-atm-2.4.1/configure.in 2003-04-25 04:17:05.000000000 +0200
3 +++ linux-atm-2.4.1.new/configure.in 2005-07-27 15:45:49.532396543 +0200
13 - src/maint/Makefile \
15 - src/ilmid/Makefile \
16 - src/ilmid/asn1/Makefile \
20 - src/mpoad/Makefile \
21 - src/switch/Makefile \
22 - src/switch/debug/Makefile \
23 - src/switch/tcp/Makefile \
24 - src/config/Makefile \
25 - src/config/init-redhat/Makefile \
26 - src/extra/Makefile \
27 - src/extra/linux-atm.spec \
28 - src/extra/ANS/Makefile
29 + src/br2684/Makefile \
32 diff -ruN linux-atm-2.4.1/src/br2684/Makefile linux-atm-2.4.1.new/src/br2684/Makefile
33 --- linux-atm-2.4.1/src/br2684/Makefile 1970-01-01 02:00:00.000000000 +0200
34 +++ linux-atm-2.4.1.new/src/br2684/Makefile 2002-07-15 23:44:25.000000000 +0200
36 +PREFIX=${TI_FILESYSTEM}
40 +br2684ctl: br2684ctl.c
41 + gcc -latm -o br2684ctl br2684ctl.c
45 + cp br2684ctl $(PREFIX)/usr/sbin/
48 + rm -rf br2684ctl *.o
49 diff -ruN linux-atm-2.4.1/src/Makefile.am linux-atm-2.4.1.new/src/Makefile.am
50 --- linux-atm-2.4.1/src/Makefile.am 2001-10-03 23:14:53.000000000 +0200
51 +++ linux-atm-2.4.1.new/src/Makefile.am 2005-07-27 15:33:52.389309711 +0200
53 -SUBDIRS = include lib test debug qgen saal sigd maint arpd ilmid man led lane \
54 - mpoad switch config extra
55 +SUBDIRS = include lib br2684
58 diff -Nur linux-atm-2.4.1.orig/src/include/linux/atmbr2684.h linux-atm-2.4.1/src/include/linux/atmbr2684.h
59 --- linux-atm-2.4.1.orig/src/include/linux/atmbr2684.h 1970-01-01 01:00:00.000000000 +0100
60 +++ linux-atm-2.4.1/src/include/linux/atmbr2684.h 2005-11-13 00:06:42.000000000 +0100
62 +#ifndef _LINUX_ATMBR2684_H
63 +#define _LINUX_ATMBR2684_H
65 +#include <linux/atm.h>
66 +#include <linux/if.h> /* For IFNAMSIZ */
67 +#include <linux/if_ether.h> /* ETH_P_* */
70 + * Type of media we're bridging (ethernet, token ring, etc) Currently only
71 + * ethernet is supported
73 +#define BR2684_MEDIA_ETHERNET (0) /* 802.3 */
74 +#define BR2684_MEDIA_802_4 (1) /* 802.4 */
75 +#define BR2684_MEDIA_TR (2) /* 802.5 - token ring */
76 +#define BR2684_MEDIA_FDDI (3)
77 +#define BR2684_MEDIA_802_6 (4) /* 802.6 */
80 + * Is there FCS inbound on this VC? This currently isn't supported.
82 +#define BR2684_FCSIN_NO (0)
83 +#define BR2684_FCSIN_IGNORE (1)
84 +#define BR2684_FCSIN_VERIFY (2)
87 + * Is there FCS outbound on this VC? This currently isn't supported.
89 +#define BR2684_FCSOUT_NO (0)
90 +#define BR2684_FCSOUT_SENDZERO (1)
91 +#define BR2684_FCSOUT_GENERATE (2)
94 + * Does this VC include LLC encapsulation?
96 +#define BR2684_ENCAPS_VC (0) /* VC-mux */
97 +#define BR2684_ENCAPS_LLC (1)
98 +#define BR2684_ENCAPS_AUTODETECT (2) /* Unsuported */
101 + * Is this VC bridged or routed?
104 +#define BR2684_PAYLOAD_ROUTED (0)
105 +#define BR2684_PAYLOAD_BRIDGED (1)
109 + * This is for the ATM_NEWBACKENDIF call - these are like socket families:
110 + * the first element of the structure is the backend number and the rest
111 + * is per-backend specific
113 +struct atm_newif_br2684 {
114 + atm_backend_t backend_num; /* ATM_BACKEND_BR2684 */
115 + int media; /* BR2684_MEDIA_* */
116 + char ifname[IFNAMSIZ];
118 + int payload; /* bridged or routed */
122 + * This structure is used to specify a br2684 interface - either by a
123 + * positive integer (returned by ATM_NEWBACKENDIF) or the interfaces name
125 +#define BR2684_FIND_BYNOTHING (0)
126 +#define BR2684_FIND_BYNUM (1)
127 +#define BR2684_FIND_BYIFNAME (2)
128 +struct br2684_if_spec {
129 + int method; /* BR2684_FIND_* */
131 + char ifname[IFNAMSIZ];
137 + * This is for the ATM_SETBACKEND call - these are like socket families:
138 + * the first element of the structure is the backend number and the rest
139 + * is per-backend specific
141 +struct atm_backend_br2684 {
142 + atm_backend_t backend_num; /* ATM_BACKEND_BR2684 */
143 + struct br2684_if_spec ifspec;
144 + int fcs_in; /* BR2684_FCSIN_* */
145 + int fcs_out; /* BR2684_FCSOUT_* */
146 + int fcs_auto; /* 1: fcs_{in,out} disabled if no FCS rx'ed */
147 + int encaps; /* BR2684_ENCAPS_* */
148 + int payload; /* BR2684_PAYLOAD_* */
149 + int has_vpiid; /* 1: use vpn_id - Unsupported */
151 + int send_padding; /* unsupported */
152 + int min_size; /* we will pad smaller packets than this */
156 + * The BR2684_SETFILT ioctl is an experimental mechanism for folks
157 + * terminating a large number of IP-only vcc's. When netfilter allows
158 + * efficient per-if in/out filters, this support will be removed
160 +struct br2684_filter {
161 + __u32 prefix; /* network byte order */
162 + __u32 netmask; /* 0 = disable filter */
165 +struct br2684_filter_set {
166 + struct br2684_if_spec ifspec;
167 + struct br2684_filter filter;
170 +enum br2684_payload {
171 + p_routed = BR2684_PAYLOAD_ROUTED,
172 + p_bridged = BR2684_PAYLOAD_BRIDGED,
175 +#define BR2684_SETFILT _IOW( 'a', ATMIOC_BACKEND + 0, \
176 + struct br2684_filter_set)
178 +#endif /* _LINUX_ATMBR2684_H */
179 diff Nur linux-atm-2.4.1.orig/src/br2684/br2684ctl.c linux-atm-2.4.1/src/br2684/br2684ctl.c
180 --- linux-atm-2.4.1.orig/src/br2684/br2684ctl.c
181 +++ linux-atm-2.4.1/src/br2684/br2684ctl.c
187 +#include <sys/ioctl.h>
191 +#include <linux/atmdev.h>
192 +#include <linux/atmbr2684.h>
194 +/* Written by Marcell GAL <cell@sch.bme.hu> to make use of the */
195 +/* ioctls defined in the br2684... kernel patch */
196 +/* Compile with cc -o br2684ctl br2684ctl.c -latm */
199 + Modified feb 2001 by Stephen Aaskov (saa@lasat.com)
200 + - Added daemonization code
203 + TODO: Delete interfaces after exit?
207 +#define LOG_NAME "RFC1483/2684 bridge"
208 +#define LOG_OPTION LOG_PERROR
209 +#define LOG_FACILITY LOG_LOCAL0
212 +int lastsock, lastitf;
214 +void fatal(char *str, int i)
216 + syslog(LOG_ERR, "Fatal: %s", str);
223 + syslog(LOG_PID, "Daemon terminated\n");
227 +int create_pidfile(char *nstr)
229 + FILE *pidfile = NULL;
239 + snprintf(name, 20, "/var/run/nas%d.pid", num);
240 + pidfile = fopen(name, "w");
241 + if (pidfile == NULL)
243 + fprintf(pidfile, "%d", getpid());
249 +int create_br(char *nstr, int payload)
253 + if (lastsock < 0) {
254 + lastsock = socket(PF_ATMPVC, SOCK_DGRAM, ATM_AAL5);
256 + if (lastsock < 0) {
257 + syslog(LOG_ERR, "socket creation failed: %s",
260 + /* create the device with ioctl: */
262 + if (num >= 0 && num < 1234567890) {
263 + struct atm_newif_br2684 ni;
264 + ni.backend_num = ATM_BACKEND_BR2684;
265 + ni.media = BR2684_MEDIA_ETHERNET;
267 + ni.payload = payload; /* bridged or routed */
268 + sprintf(ni.ifname, "nas%d", num);
269 + err = ioctl(lastsock, ATM_NEWBACKENDIF, &ni);
273 + "Interface \"%s\" created sucessfully\n",
277 + "Interface \"%s\" could not be created, reason: %s\n",
278 + ni.ifname, strerror(errno));
279 + lastitf = num; /* even if we didn't create, because existed, assign_vcc wil want to know it! */
281 + syslog(LOG_ERR, "err: strange interface number %d",
289 +int assign_vcc(char *astr, int encap, int payload, int bufsize)
292 + struct atm_qos qos;
293 + struct sockaddr_atmpvc addr;
295 + struct atm_backend_br2684 be;
297 + memset(&addr, 0, sizeof(addr));
299 + text2atm(astr, (struct sockaddr *) (&addr), sizeof(addr),
303 + "Could not parse ATM parameters (error=%d)\n", err);
306 + addr.sap_family = AF_ATMPVC;
307 + addr.sap_addr.itf = itf;
308 + addr.sap_addr.vpi = 0;
309 + addr.sap_addr.vci = vci;
312 + "Communicating over ATM %d.%d.%d, encapsulation: %s\n",
313 + addr.sap_addr.itf, addr.sap_addr.vpi, addr.sap_addr.vci,
314 + encap ? "VC mux" : "LLC");
316 + if ((fd = socket(PF_ATMPVC, SOCK_DGRAM, ATM_AAL5)) < 0)
317 + syslog(LOG_ERR, "failed to create socket %d, reason: %s",
318 + errno, strerror(errno));
321 + memset(&qos, 0, sizeof(qos));
322 + qos.aal = ATM_AAL5;
323 + qos.txtp.traffic_class = ATM_UBR;
324 + qos.txtp.max_sdu = 1524;
325 + qos.txtp.pcr = ATM_MAX_PCR;
326 + qos.rxtp = qos.txtp;
329 + setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &bufsize,
331 + syslog(LOG_ERR, "setsockopt SO_SNDBUF: (%d) %s\n", err,
334 + if (setsockopt(fd, SOL_ATM, SO_ATMQOS, &qos, sizeof(qos)) < 0)
335 + syslog(LOG_ERR, "setsockopt SO_ATMQOS %d", errno);
338 + connect(fd, (struct sockaddr *) &addr,
339 + sizeof(struct sockaddr_atmpvc));
342 + fatal("failed to connect on socket", err);
344 + /* attach the vcc to device: */
346 + be.backend_num = ATM_BACKEND_BR2684;
347 + be.ifspec.method = BR2684_FIND_BYIFNAME;
348 + sprintf(be.ifspec.spec.ifname, "nas%d", lastitf);
349 + be.fcs_in = BR2684_FCSIN_NO;
350 + be.fcs_out = BR2684_FCSOUT_NO;
352 + be.encaps = encap ? BR2684_ENCAPS_VC : BR2684_ENCAPS_LLC;
353 + be.payload = payload;
355 + be.send_padding = 0;
357 + err = ioctl(fd, ATM_SETBACKEND, &be);
359 + syslog(LOG_INFO, "Interface configured");
361 + syslog(LOG_ERR, "Could not configure interface:%s",
373 + ("usage: %s [-b] [[-c number] [-e 0|1] [-p 0|1] [-t 4|6] [-a [itf.]vpi.vci]*]*\n",
380 +int main(int argc, char **argv)
382 + int c, background = 0, encap = 0, sndbuf = 8192, payload = 1;
383 + char *itfnum = NULL;
388 + openlog(LOG_NAME, LOG_OPTION, LOG_FACILITY);
390 + while ((c = getopt(argc, argv, "a:bc:e:s:p:t:?h")) != EOF)
393 + assign_vcc(optarg, encap, payload, sndbuf);
399 + create_br(optarg, payload);
400 + itfnum = strdup(optarg);
403 + encap = (atoi(optarg));
406 + "invalid encapsulation: %s:\n",
412 + sndbuf = (atoi(optarg));
415 + "Invalid sndbuf: %s, using size of 8192 instead\n",
420 + case 'p': /* payload type: routed (0) or bridged (1) */
421 + payload = atoi(optarg);
430 + if (argc != optind)
441 + fprintf(stderr, "Error detaching\n");
444 + exit(0); // This is the parent
446 + // Become a process group and session group leader
447 + if (setsid() < 0) {
448 + fprintf(stderr, "Could not set process group\n");
451 + // Fork again to let process group leader exit
455 + "Error detaching during second fork\n");
458 + exit(0); // This is the parent
460 + // Now we're ready for buisness
461 + chdir("/"); // Don't keep directories in use
464 + close(2); // Close stdin, -out and -error
466 + Note that this implementation does not keep an open
468 + If we need them they can be opened now
473 + if (itfnum != NULL) {
474 + create_pidfile(itfnum);
478 + syslog(LOG_INFO, "RFC 1483/2684 bridge daemon started\n");
482 + sleep(30); /* to keep the sockets... */