From: chas w. <ch...@us...> - 2005-10-06 17:28:01
|
Update of /cvsroot/linux-atm/linux-atm/src/led In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23079 Modified Files: Tag: V2_5_0 join.c join.h kernel.c kernel.h main.c Log Message: ATM_LECSADDR support Index: join.c =================================================================== RCS file: /cvsroot/linux-atm/linux-atm/src/led/join.c,v retrieving revision 1.2.2.1 retrieving revision 1.2.2.2 diff -C2 -d -r1.2.2.1 -r1.2.2.2 *** join.c 19 Jul 2003 22:42:01 -0000 1.2.2.1 --- join.c 6 Oct 2005 17:27:50 -0000 1.2.2.2 *************** *** 132,136 **** init_conn_params(&sap, &qos, CONTROL_CONN); ! if (lecs_method == LECS_MANUAL) { diag(COMPONENT, DIAG_DEBUG, "trying manual LECS address"); conn = setup_svc(manual_atm_addr, listen_addr, &sap, &qos); --- 132,136 ---- init_conn_params(&sap, &qos, CONTROL_CONN); ! if ((lecs_method == LECS_MANUAL) || (lecs_method == LECS_FROM_ILMI)) { diag(COMPONENT, DIAG_DEBUG, "trying manual LECS address"); conn = setup_svc(manual_atm_addr, listen_addr, &sap, &qos); Index: join.h =================================================================== RCS file: /cvsroot/linux-atm/linux-atm/src/led/join.h,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -C2 -d -r1.2 -r1.2.2.1 *** join.h 9 Oct 2001 22:33:07 -0000 1.2 --- join.h 6 Oct 2005 17:27:50 -0000 1.2.2.1 *************** *** 17,20 **** --- 17,21 ---- #define LECS_WELLKNOWN 1 #define LECS_MANUAL 2 + #define LECS_FROM_ILMI 3 #endif /* JOIN_H */ Index: kernel.c =================================================================== RCS file: /cvsroot/linux-atm/linux-atm/src/led/kernel.c,v retrieving revision 1.2.2.1 retrieving revision 1.2.2.2 diff -C2 -d -r1.2.2.1 -r1.2.2.2 *** kernel.c 19 Jul 2003 22:42:01 -0000 1.2.2.1 --- kernel.c 6 Oct 2005 17:27:50 -0000 1.2.2.2 *************** *** 339,340 **** --- 339,379 ---- } } + + int get_lecsaddr(int itf, struct sockaddr_atmsvc *addr) + { + int fd, howmany; + struct atmif_sioc req; + char txt[80]; + + #ifdef ATM_GETLECSADDR + fd = socket(AF_ATMSVC, SOCK_DGRAM, 0); + if (fd < 0) { + diag(COMPONENT, DIAG_ERROR, "could not create AF_ATMSVC socket"); + return -1; + } + req.number = itf; + req.arg = addr; + req.length = sizeof( struct sockaddr_atmsvc ); + + if (ioctl(fd, ATM_GETLECSADDR, &req) < 0) { + diag(COMPONENT, DIAG_DEBUG, "ioctl ATM_GETLECSADDR failed" ); + close(fd); + return -1; + } + close(fd); + howmany = req.length; + if (howmany == 0) { + diag(COMPONENT, DIAG_ERROR, "No LECS address registered"); + return -1; + } + if (addr->sas_addr.pub[0] != 0){ + diag( COMPONENT, DIAG_ERROR, "Public address???" ); + addr->sas_addr.pub[0] = 0; + } + atm2text(txt, 80, (struct sockaddr *)addr, 0); + diag(COMPONENT, DIAG_DEBUG, "discovered LECS address %s", txt); + return howmany; + #else + return -1; + #endif + } Index: kernel.h =================================================================== RCS file: /cvsroot/linux-atm/linux-atm/src/led/kernel.h,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -C2 -d -r1.2 -r1.2.2.1 *** kernel.h 9 Oct 2001 22:33:07 -0000 1.2 --- kernel.h 6 Oct 2005 17:27:50 -0000 1.2.2.1 *************** *** 33,36 **** --- 33,37 ---- int msg_from_kernel(void); int read_from_kernel (char *buff, int size); + int get_lecsaddr(int itf, struct sockaddr_atmsvc *addr); #endif /* KERNEL_H */ Index: main.c =================================================================== RCS file: /cvsroot/linux-atm/linux-atm/src/led/main.c,v retrieving revision 1.2.2.6 retrieving revision 1.2.2.7 diff -C2 -d -r1.2.2.6 -r1.2.2.7 *** main.c 11 Dec 2004 01:57:11 -0000 1.2.2.6 --- main.c 6 Oct 2005 17:27:50 -0000 1.2.2.7 *************** *** 205,208 **** --- 205,209 ---- char pidbuf[PATH_MAX + 1]; int fd; + int retval; memset(elan_name, '\0', sizeof(elan_name)); *************** *** 435,438 **** --- 436,455 ---- itf, foreId, max_frame_size, proxy_flag, lane_version); + if (lecs_method != LECS_MANUAL && lecs_method != LECS_NONE) { + diag(COMPONENT, DIAG_DEBUG, "trying to get LECS address from ILMI"); + /* Not sure why this memset is necessary */ + memset(&manual_atm_addr, 0, sizeof(struct sockaddr_atmsvc)); + retval = get_lecsaddr(phys_itf, &manual_atm_addr); + if (retval <= 0) { + diag(COMPONENT, DIAG_DEBUG, + "get_lecsaddr failed; not enough " + "memory allocated for all addresses " + "or no LECS address registered"); + } else { + diag(COMPONENT, DIAG_DEBUG, "obtained LECS address from ILMI"); + lecs_method = LECS_FROM_ILMI; + } + } + diag(COMPONENT, DIAG_DEBUG, "About to connect LECS"); if (lec_configure(lecs_method, &manual_atm_addr, &listen_addr) < 0) { |