From: chas w. <ch...@us...> - 2003-05-02 16:39:40
|
Update of /cvsroot/linux-atm/linux-atm/src/led In directory sc8-pr-cvs1:/tmp/cvs-serv28789 Modified Files: Tag: V2_5_0 conn.c frames.c Log Message: handle_connect() now checks the incoming call's atm address. if its not the default data direct and a call already exists the connection is closed (it no longer assumes that this call is going to be the default data direct) handle_accept() checks the incoming call to see if it should be the default data direct. if not, the connection is attached as a receive only. if this would be the default data direct, the it gets attached as such and the old data direct (which zeppelin probably setup) is closed. since zeppelin may not setup the connection to a client, it needs to watch for the READY_IND on connections and upon recept, send a flush request to switch over to the new path. Index: conn.c =================================================================== RCS file: /cvsroot/linux-atm/linux-atm/src/led/conn.c,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -C2 -d -r1.2 -r1.2.2.1 *** conn.c 9 Oct 2001 22:33:07 -0000 1.2 --- conn.c 2 May 2003 16:39:36 -0000 1.2.2.1 *************** *** 38,41 **** --- 38,42 ---- #include <errno.h> #include <sys/ioctl.h> + #include <time.h> #include <atm.h> *************** *** 224,236 **** - /* - * You need to check this if setup_svc() returns NULL - */ - #if 0 - if (is_data_direct(&sap->blli[0])) { - /* Try to remove possible entry in kernel */ - delete_addr(conn->atm_address); - } - #endif /* Does an active open to dst_addr using pre-filled * parameters in sap and qos. --- 225,228 ---- *************** *** 249,268 **** diag(COMPONENT, DIAG_DEBUG, "Outgoing call setup\n"); - /* The code below is commented out due to the following scenario: - We have made a connection to another LEC and our address was - numerically lower than theirs (LANEv2 8.1.13). - The other end has also connected us, but we must not use that - VCC. - However, if the connection we made gets closed, we can not open - it again since a connection to the destination LEC already exists. - */ - #if 0 - /* We don't create connection to an entity where we already have - a connection. */ - if (conn_already_exists(dst_addr->sas_addr.prv, NULL) && - is_data_direct(&sap->blli[0])) - return NULL; - #endif - dst_addr->sas_family = AF_ATMSVC; listen_addr->sas_family = AF_ATMSVC; --- 241,244 ---- *************** *** 518,522 **** static int handle_accept(Conn_t *conn) { ! Conn_t *new; struct atmlec_ioc ioc; --- 494,498 ---- static int handle_accept(Conn_t *conn) { ! Conn_t *new, *existing = NULL; struct atmlec_ioc ioc; *************** *** 530,538 **** diag(COMPONENT, DIAG_DEBUG, "Data Direct VCC accepted\n"); ioc.receive = 0; ! if (conn_already_exists(new->atm_address, new) && ! memcmp(lec_params.c1n_my_atm_addr, new->atm_address, ATM_ESA_LEN) < 0) { ! diag(COMPONENT, DIAG_DEBUG, "Using it only to receive, spec 8.1.1\n"); ! ioc.receive = 1; ! } } memcpy(ioc.atm_addr, new->atm_address, ATM_ESA_LEN); --- 506,516 ---- diag(COMPONENT, DIAG_DEBUG, "Data Direct VCC accepted\n"); ioc.receive = 0; ! if ((existing = conn_already_exists(new->atm_address, new)) && ! /* is calling address > called address */ ! (memcmp(new->atm_address, lec_params.c1n_my_atm_addr, ATM_ESA_LEN) > 0)) { ! diag(COMPONENT, DIAG_DEBUG, "Using it only to receive, spec 8.1.13\n"); ! ioc.receive = 1; ! existing = NULL; ! } } memcpy(ioc.atm_addr, new->atm_address, ATM_ESA_LEN); *************** *** 544,547 **** --- 522,530 ---- } + if (existing && existing->status == CONNECTED) { + diag(COMPONENT, DIAG_DEBUG, "Closing old data direct, fd %d\n", existing->fd); + close_connection(existing); + } + return 0; } *************** *** 633,646 **** } - send_ready_ind(conn); - memcpy(ioc.atm_addr, conn->atm_address, ATM_ESA_LEN); ioc.dev_num = lec_params.itf_num; ioc.receive = 0; diag(COMPONENT, DIAG_DEBUG, "Attaching a new active VCC, fd %d\n", conn->fd); if (ioctl(conn->fd, ATMLEC_DATA, &ioc) < 0) { diag(COMPONENT, DIAG_ERROR, "VCC attach failed: ioctl: %s\n", strerror(errno)); return -1; } memset(&msg, 0, sizeof(struct atmlec_msg)); --- 616,636 ---- } memcpy(ioc.atm_addr, conn->atm_address, ATM_ESA_LEN); ioc.dev_num = lec_params.itf_num; ioc.receive = 0; diag(COMPONENT, DIAG_DEBUG, "Attaching a new active VCC, fd %d\n", conn->fd); + if (conn_already_exists(conn->atm_address, conn) && + /* is calling address > called address */ + memcmp(lec_params.c1n_my_atm_addr, conn->atm_address, ATM_ESA_LEN) > 0) { + diag(COMPONENT, DIAG_DEBUG, "Receive only, spec 8.1.13 -- Closing"); + close_connection(conn); + return 0; + } if (ioctl(conn->fd, ATMLEC_DATA, &ioc) < 0) { diag(COMPONENT, DIAG_ERROR, "VCC attach failed: ioctl: %s\n", strerror(errno)); return -1; } + + send_ready_ind(conn); memset(&msg, 0, sizeof(struct atmlec_msg)); Index: frames.c =================================================================== RCS file: /cvsroot/linux-atm/linux-atm/src/led/frames.c,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -C2 -d -r1.2 -r1.2.2.1 *** frames.c 9 Oct 2001 22:33:07 -0000 1.2 --- frames.c 2 May 2003 16:39:36 -0000 1.2.2.1 *************** *** 294,297 **** --- 294,312 ---- } + static void handle_ready_ind(Conn_t *conn) + { + struct atmlec_msg msg; + + /* FIXME -- if its a receive only vcc we should not do this */ + + diag(COMPONENT, DIAG_DEBUG, "READY_IND, on fd %d; sending LE_FLUSH_REQ\n", conn->fd); + memset(&msg, 0, sizeof(struct atmlec_msg)); + msg.type = l_flush_tran_id; + memcpy(msg.content.normal.atm_addr, conn->atm_address, ATM_ESA_LEN); + msg.content.normal.flag = send_flush_req(conn); + + msg_to_kernel(&msg, sizeof(struct atmlec_msg)); + } + /* Processes and validates incoming frames. Calls frame * dependant handler functions. *************** *** 312,315 **** --- 327,331 ---- break; case LE_FLUSH_RSP: + diag(COMPONENT, DIAG_DEBUG, "LE_FLUSH_RESPONSE, on fd %d", conn->fd); handle_flush_rsp(frame); break; *************** *** 318,322 **** break; case READY_IND: ! /* We can ignore these */ break; case LE_ARP_REQ: --- 334,338 ---- break; case READY_IND: ! handle_ready_ind(conn); break; case LE_ARP_REQ: |