From: chas w. - C. <ch...@cm...> - 2014-07-07 12:59:15
|
On Mon, 07 Jul 2014 10:01:38 +0200 Ico <at...@ze...> wrote: > Not sure if this list is still alive, there does not seem to be very much going > on in the linux-atm world these days, is there? Only in the embedded world is my guess. > The PPPoA plugin has one additional ioctl call which I omitted in my test program: > > r = ioctl(fd, ATM_SETBACKEND, &be); > > I understand this is ment to set the line discipline of the socket to PPP, so > the kernel will know it will has to do PPP over the link. But since I don't > want the kernel to handle the ppp for me, I omitted the call. I believe this > might be part of the problem. You are right. This hooks the ppp protocol onto the ATM socket. You shouldn't need this if you just want to send and recv AAL5 frames. > Any insight much appreciated. Is what I'm trying to do even possible? Yes, it should be possible. You could try the debug programs aread and awrite (from the linux-atm distribution) to see if you can see the frames, for instance: aread 0.0.35 and watch for output. If you need to send some data, you can use awrite 0.0.35 'message' (since aread only opens the pvc for reading). Also, run atmdiag and see if you are reporting errors or drops. Run dmesg after running your program to see if your hardware had any issues with opening an atm socket. > #define MAX_SDU 20000 > #define MAX_OFFSET 8 > > void usage(char *name) > { > fprintf(stderr, "usage: %s [vpi] [vci]\n", name); > exit(1); > } > > int main(int argc, char *argv[]) > { > struct sockaddr_atmpvc addr; > struct atm_qos qos; > int fd; > static unsigned char buffer[30]; > int r; > > > fd = socket(PF_ATMPVC, SOCK_DGRAM, ATM_AAL5); Usually, we say 0 instead of ATM_AAL5 here. I believe the kernel code ignores this value so it doesn't have any effect. > if(fd < 0) { > perror("socket error"); > return 1; > } > > memset(&qos, 0, sizeof(qos)); > qos.aal = ATM_AAL5; > qos.txtp.traffic_class = ATM_UBR; > qos.txtp.max_sdu = 500; > qos.txtp.pcr = ATM_MAX_PCR; I don't think you need to set .pcr if you say UBR. I don't think it will hurt though. > qos.rxtp = qos.txtp; > > r = setsockopt(fd, SOL_ATM, SO_ATMQOS, &qos, sizeof(qos)); > if(r < 0) { > perror("setsockopt SO_ATMQOS"); > return 1; > } > > int bufsize[1524]; > r = setsockopt(fd, SOL_SOCKET,SO_SNDBUF, &bufsize ,sizeof(bufsize)); > if(r < 0) { > perror("setbufsize SO_ATMQOS"); > return 1; > } > > memset(&addr, 0, sizeof(addr)); > addr.sap_family = AF_ATMPVC; > addr.sap_addr.itf = 0; > addr.sap_addr.vpi = 0; This might need to be 8. I have seen both 0 and 8 for the vpi for PPPoATM. > addr.sap_addr.vci = 35; > > r = connect(fd, (struct sockaddr *) &addr, sizeof(addr)); > if(r < 0) { > perror("connect"); > return 1; > } > > while (1) { > > memset(buffer,0, sizeof(buffer)); > > r = read(fd, buffer, sizeof(buffer)); > > if (r < 0) > perror("read()"); > > if (r > 0) > { > printf("received bytes %d\n", r); > } > } > > return 0; > } > |