ATM_CLIENT_NULL(4NDEVICES AND NETWORK INTERFACEATM_CLIENT_NULL(4N) NAME atm_client_null - example client ATM program using a null AAL EXAMPLE /* * Copyright (c) 1992 by Fore Systems, Inc. */ #ifndef lint static char -atm-client-null-c-[] = "@(#)$Id: atm-client-null.c,v 1.3 1994/06/28 20:18:38 jshirron Exp $ FSI"; #endif /* lint */ #include #include #include #include #define SERVER-SAP 4096 #define HOST-CELL-SIZE 56 /* ATM Computer Interface cell size */ maimain(argc, argv) int argc; char *argv[]; { int fd, cells, max-cells, octets, qlen; Atm-info info; Atm-endpoint dst; Atm-qos qos; Atm-qos-sel qos-selected; Atm-sap ssap; Aal-type aal = aal-null; /* specify a null connection */ Atm-dataflow dataflow = simplex; char *device-name; char *tbuf; extern char *malloc(); if (argc < 3) { fprintf(stderr, "Usage: %s device server-hostname [server-sap]\n", argv[0]); exit(1); } device-name = malloc(strlen("/dev/") + strlen(argv[1]) + 1); sprintf(device-name, "/dev/%s", argv[1]); if ((fd = atm-open(device-name, O-RDWR, &info)) < 0) { perror("atm-open"); exit(1); } tbuf = malloc(info.mtu); FSI Release 2.3 Last change: 7 June 1994 1 ATM_CLIENT_NULL(4NDEVICES AND NETWORK INTERFACEATM_CLIENT_NULL(4N) max-cells = info.mtu / HOST-CELL-SIZE; /* Max number of cells */ /* * Let ATM driver assign a source SAP by specifying * sap of zero. Set incoming connect request length to * zero since we're the client. Servers set queue length * to non zero. */ ssap = 0; qlen = 0; if (atm-bind(fd, ssap, &ssap, qlen) < 0) { atm-error("atm-bind"); exit(1); } printf("SAP assigned=%d\n", ssap); /* * Initialize the server's data link address. */ if (atm-gethostbyname(argv[2], &dst.nsap) < 0) { fprintf(stderr, "atm-gethostbyname failed\n"); exit(1); } dst.asap = (argc == 4) ? atoi(argv[3]) : SERVER-SAP; /* * Request some quality of service. */ qos.peak-bandwidth.target = 256; /* kbit/sec */ qos.peak-bandwidth.minimum = 128; /* kbit/sec */ qos.mean-bandwidth.target = 128; /* kbit/sec */ qos.mean-bandwidth.minimum = 64; /* kbit/sec */ qos.mean-burst.target = 2; /* 2 kbit packet length */ qos.mean-burst.minimum = 1; /* 1 kbit packet length */ if (atm-connect(fd, &dst, &qos, &qos-selected, aal, dataflow) < 0) { atm-error("atm-connect"); exit(1); } printf("selected qos peak=%d, mean=%d, burst=%d\n", qos-selected.peak-bandwidth, qos-selected.mean-bandwidth, qos-selected.mean-burst); for (cells = 1; cells <= max-cells; cells++) { octets = cells * HOST-CELL-SIZE; /* * The format of cells in `tbuf' is defined in * the appropriate ATM Computer Interface User's * Manual. The 48 octet cell payload is defined FSI Release 2.3 Last change: 7 June 1994 2 ATM_CLIENT_NULL(4NDEVICES AND NETWORK INTERFACEATM_CLIENT_NULL(4N) * by the application. */ if (atm-send(fd, tbuf, octets) < 0) { atm-error("atm-send"); exit(1); } } return(0); } SEE ALSO atm_intro(4N) FSI Release 2.3 Last change: 7 June 1994 3