From: Ico <at...@ze...> - 2014-07-07 08:01:51
|
Hi all, 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? I'm pretty familiar with linux IP networking, but ATM is quite new to me. I might be asking stupid questions; please tell me if I do. I'm trying to access the raw PPP frames of a pppoa link from userspace. The idea is that the ppp frames are to be relayed somewhere else and the PPP itself is not handled by the machine that is running the ATM link. I have a working setup with a board running PPPoA using the pppoa plugin from the stock pppd. I've stolen some code from this said plugin, hoping to be able to recv() and send() raw PPP frames from an ATM socked. My test code, simple as it is, does however not seem to work. No data is ever seen on the ATM socket, and sending PPP handshake data to the socket does not give any replies from the BRAS. 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. Any insight much appreciated. Is what I'm trying to do even possible? Thank you, Ico #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); 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; 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; 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; } -- :wq ^X^Cy^K^X^C^C^C^C |