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 --- linux-atm-2.4.1/src/br2684/br2684ctl.c 1970-01-01 01:00:00.000000000 +0100
180 +++ linux-atm-2.4.1.new/src/br2684/br2684ctl.c 2006-02-07 14:05:14.000000000 +0100
186 +#include <sys/ioctl.h>
190 +#include <linux/atmdev.h>
191 +#include <linux/atmbr2684.h>
193 +/* Written by Marcell GAL <cell@sch.bme.hu> to make use of the */
194 +/* ioctls defined in the br2684... kernel patch */
195 +/* Compile with cc -o br2684ctl br2684ctl.c -latm */
198 + Modified feb 2001 by Stephen Aaskov (saa@lasat.com)
199 + - Added daemonization code
202 + TODO: Delete interfaces after exit?
206 +#define LOG_NAME "RFC1483/2684 bridge"
207 +#define LOG_OPTION LOG_PERROR
208 +#define LOG_FACILITY LOG_LOCAL0
211 +int lastsock, lastitf;
213 +void fatal(char *str, int i)
215 + syslog(LOG_ERR, "Fatal: %s", str);
222 + syslog(LOG_PID, "Daemon terminated\n");
226 +int create_pidfile(char *nstr)
228 + FILE *pidfile = NULL;
238 + snprintf(name, 20, "/var/run/nas%d.pid", num);
239 + pidfile = fopen(name, "w");
240 + if (pidfile == NULL)
242 + fprintf(pidfile, "%d", getpid());
248 +int create_br(char *nstr, int payload)
252 + if (lastsock < 0) {
253 + lastsock = socket(PF_ATMPVC, SOCK_DGRAM, ATM_AAL5);
255 + if (lastsock < 0) {
256 + syslog(LOG_ERR, "socket creation failed: %s",
259 + /* create the device with ioctl: */
261 + if (num >= 0 && num < 1234567890) {
262 + struct atm_newif_br2684 ni;
263 + ni.backend_num = ATM_BACKEND_BR2684;
264 + ni.media = BR2684_MEDIA_ETHERNET;
266 + ni.payload = payload; /* bridged or routed */
267 + sprintf(ni.ifname, "nas%d", num);
268 + err = ioctl(lastsock, ATM_NEWBACKENDIF, &ni);
272 + "Interface \"%s\" (mtu=%d, payload=%s) created sucessfully\n",
273 + ni.ifname, ni.mtu,ni.payload ? "bridged" : "routed");
276 + "Interface \"%s\" could not be created, reason: %s\n",
277 + ni.ifname, strerror(errno));
278 + lastitf = num; /* even if we didn't create, because existed, assign_vcc wil want to know it! */
280 + syslog(LOG_ERR, "err: strange interface number %d",
288 +int assign_vcc(char *astr, int encap, int payload, int bufsize)
291 + struct atm_qos qos;
292 + struct sockaddr_atmpvc addr;
294 + struct atm_backend_br2684 be;
296 + memset(&addr, 0, sizeof(addr));
298 + text2atm(astr, (struct sockaddr *) (&addr), sizeof(addr),
302 + "Could not parse ATM parameters (error=%d)\n", err);
305 + addr.sap_family = AF_ATMPVC;
306 + addr.sap_addr.itf = itf;
307 + addr.sap_addr.vpi = 0;
308 + addr.sap_addr.vci = vci;
311 + "Communicating over ATM %d.%d.%d, encapsulation: %s\n",
312 + addr.sap_addr.itf, addr.sap_addr.vpi, addr.sap_addr.vci,
313 + encap ? "VC mux" : "LLC");
315 + if ((fd = socket(PF_ATMPVC, SOCK_DGRAM, ATM_AAL5)) < 0)
316 + syslog(LOG_ERR, "failed to create socket %d, reason: %s",
317 + errno, strerror(errno));
320 + memset(&qos, 0, sizeof(qos));
321 + qos.aal = ATM_AAL5;
322 + qos.txtp.traffic_class = ATM_UBR;
323 + qos.txtp.max_sdu = 1524;
324 + qos.txtp.pcr = ATM_MAX_PCR;
325 + qos.rxtp = qos.txtp;
328 + setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &bufsize,
330 + syslog(LOG_ERR, "setsockopt SO_SNDBUF: (%d) %s\n", err,
333 + if (setsockopt(fd, SOL_ATM, SO_ATMQOS, &qos, sizeof(qos)) < 0)
334 + syslog(LOG_ERR, "setsockopt SO_ATMQOS %d", errno);
337 + connect(fd, (struct sockaddr *) &addr,
338 + sizeof(struct sockaddr_atmpvc));
341 + fatal("failed to connect on socket", err);
343 + /* attach the vcc to device: */
345 + be.backend_num = ATM_BACKEND_BR2684;
346 + be.ifspec.method = BR2684_FIND_BYIFNAME;
347 + sprintf(be.ifspec.spec.ifname, "nas%d", lastitf);
348 + be.fcs_in = BR2684_FCSIN_NO;
349 + be.fcs_out = BR2684_FCSOUT_NO;
351 + be.encaps = encap ? BR2684_ENCAPS_VC : BR2684_ENCAPS_LLC;
352 + be.payload = payload;
354 + be.send_padding = 0;
356 + err = ioctl(fd, ATM_SETBACKEND, &be);
358 + syslog(LOG_INFO, "Interface configured");
360 + syslog(LOG_ERR, "Could not configure interface:%s",
371 + printf("usage: %s [-b] [[-c number] [-e 0|1] [-p 0|1] [-s num] [-a [itf.]vpi.vci]*]*\n"
372 + " -b = run in background (daemonize)\n"
373 + " -c <num> = use interface nas<num>\n"
374 + " -e 0|1 = encapsulation (0=LLC, 1=VC Mux)\n"
375 + " -p 0|1 = payload type (0=routed,1=bridged)\n"
376 + " -s <num> = set sndbuf (send buffer) size (default 8192)\n"
377 + " -a [itf.]vpi.vci = ATM interface no, VPI, VCI\n",
384 +int main(int argc, char **argv)
386 + int c, background = 0, encap = 0, sndbuf = 8192, payload = 1;
387 + char *itfnum = NULL;
392 + openlog(LOG_NAME, LOG_OPTION, LOG_FACILITY);
394 + while ((c = getopt(argc, argv, "a:bc:e:s:p:t:?h")) != EOF)
397 + assign_vcc(optarg, encap, payload, sndbuf);
403 + create_br(optarg, payload);
404 + itfnum = strdup(optarg);
407 + encap = (atoi(optarg));
410 + "invalid encapsulation: %s:\n",
416 + sndbuf = (atoi(optarg));
419 + "Invalid sndbuf: %s, using size of 8192 instead\n",
424 + case 'p': /* payload type: routed (0) or bridged (1) */
425 + payload = atoi(optarg);
434 + if (argc != optind)
445 + fprintf(stderr, "Error detaching\n");
448 + exit(0); // This is the parent
450 + // Become a process group and session group leader
451 + if (setsid() < 0) {
452 + fprintf(stderr, "Could not set process group\n");
455 + // Fork again to let process group leader exit
459 + "Error detaching during second fork\n");
462 + exit(0); // This is the parent
464 + // Now we're ready for buisness
465 + chdir("/"); // Don't keep directories in use
468 + close(2); // Close stdin, -out and -error
470 + Note that this implementation does not keep an open
472 + If we need them they can be opened now
477 + if (itfnum != NULL) {
478 + create_pidfile(itfnum);
482 + syslog(LOG_INFO, "RFC 1483/2684 bridge daemon started\n");
486 + sleep(30); /* to keep the sockets... */