/* m2TcpLib.c - MIB-II TCP-group API for SNMP agents */ /* * Copyright (c) 1984-2014 Wind River Systems, Inc. * * The right to copy, distribute or otherwise make use of this software * may be licensed only pursuant to the terms of an applicable Wind River * license agreement. No license to Wind River intellectual property rights * is granted herein. All rights not licensed by Wind River are reserved * by Wind River. */ /* modification history -------------------- 02l,15feb14,rjq Fix incorrect merge in tcpConnCmp() 02k,15dec11,h_x Back port to 6.9.2.1 for WIND00297079 02j,29oct10,h_x Fix WIND00238817 02i,14oct10,h_x Fix WIND00236294 02h,04Aug10,lzq Fix WIND00225083 02g,21jun10,h_x Fix WIND00217113 02f,07May10,lzq let m2TcpConnEntryGet function get data from both ConnTable and ListenerTable 02e,28may09,zhr Fixed WIND00168052 list stops at TIME_WAIT 02e,28may09,zhr Fixed WIND00168313 tcpRetransSegs 02d,15jul08,zhr Updated for apigen and compiling waring 02c,10jun08,zhr Fixed WIND00124866 tcpConnState 02b,05jun08,zhr updated for GPP 02a,20mar08,zhr Migrated it to IPNET 01z,24oct05,dlk Fix scaling of tcpRtoMin and tcpRtoMax (SPR#114300). 01y,15jul05,vvv replaced iosFdValue() with iosFdDrvValue() 01y,25feb05,niq fix compiler warnings 01w,12jan05,vvv osdep.h cleanup 01v,02jun04,rp removed extern declaration of fdTable 01u,01mar04,dat rework for iosLib changes 01t,20nov03,niq osdep.h cleanup 01r,06nov03,rlm Ran batch header update for header re-org. 01q,08sep03,vvv merged from ACCORDION_BASE6_MERGE_BASELINE 01p,09feb03,pas include socketvar.h to silence a compiler warning 01o,06feb03,vvv merged from tor2_2-patch.alameda, ver01g (SPR #29667) 01n,01oct02,ann reverted the comparison logic in the Get routines 01m,21may02,ppp porting it for t202 01l,16may02,ant integration into Clarinet 01k,19nov01,rae renamed build macro to support different T2.x versions 01j,26oct01,spm isolated virtual stack data structures (SPR #71092) 01i,28jun01,rae add BUILD_FOR_T2 macro for truestack 01h,29mar01,spm merged changes from version 01f of tor2_0.open_stack branch (wpwr VOB, base 01e) for unified code base 01g,25oct00,ham doc: cleanup for vxWorks AE 1.0 01f,14mar00,mak updated access of fdTable[] in m2TcpConnEntrySet(). 01e,08mar97,vin added changes to accomodate changes in pcb structure. 01d,25jan95,jdi doc cleanup. 01c,11nov94,rhp edit man pages 01b,10nov94,rhp fixed typo in m2TcpInit man page 01a,08dec93,jag written */ /* DESCRIPTION This library provides MIB-II services for the TCP group. It provides routines to initialize the group, access the group global variables, read the table of TCP connections, and change the state of a TCP connection. For a broader description of MIB-II services, see the manual entry for m2Lib. To use this feature, include the following component: INCLUDE_MIB2_TCP USING THIS LIBRARY This library can be initialized and deleted by calling m2TcpInit() and m2TcpDelete() respectively, if only the TCP group's services are needed. If full MIB-II support is used, this group and all other groups can be initialized and deleted by calling m2Init() and m2Delete(). The group global variables are accessed by calling m2TcpGroupInfoGet() as follows: .CS M2_TCP tcpVars; if (m2TcpGroupInfoGet (&tcpVars) == OK) /@ values in tcpVars are valid @/ .CE The TCP table of connections can be accessed in lexicographical order. The first entry in the table can be accessed by setting the table index to zero. Every other entry thereafter can be accessed by passing to m2TcpConnTblEntryGet() the index retrieved in the previous invocation incremented to the next lexicographical value by giving M2_NEXT_VALUE as the search parameter. For example: .CS M2_TCPCONNTBL tcpEntry; /@ Specify a zero index to get the first entry in the table @/ tcpEntry.tcpConnLocalAddress = 0; /@ Local IP address in host byte order @/ tcpEntry.tcpConnLocalPort = 0; /@ Local TCP port @/ tcpEntry.tcpConnRemAddress = 0; /@ remote IP address @/ tcpEntry.tcpConnRemPort = 0; /@ remote TCP port in host byte order @/ /@ get the first entry in the table @/ if ((m2TcpConnTblEntryGet (M2_NEXT_VALUE, &tcpEntry) == OK) /@ values in tcpEntry in the first entry are valid @/ /@ process first entry in the table @/ /@ * For the next call, increment the index returned in the previous call. * 147.11.46.8.2000.147.11.46.158.1001. If an entry in the table * matches the specified index, then that entry is returned. * Otherwise the closest entry following it, in lexicographic order, * is returned. @/ /@ get the second entry in the table @/ if ((m2TcpConnTblEntryGet (M2_NEXT_VALUE, &tcpEntry) == OK) /@ values in tcpEntry in the second entry are valid @/ .CE The TCP table of connections allows only for a connection to be deleted as specified in the MIB-II. For example: .CS M2_TCPCONNTBL tcpEntry; /@ Fill in the index for the connection to be deleted in the table @/ /@ Local IP address in host byte order, and local port number @/ tcpEntry.tcpConnLocalAddress = 0x930b2e08; tcpEntry.tcpConnLocalPort = 3000; /@ Remote IP address in host byte order, and remote port number @/ tcpEntry.tcpConnRemAddress = 0x930b2e9e; tcpEntry.tcpConnRemPort = 3000; tcpEntry.tcpConnState = 12; /@ MIB-II state value for delete @/ /@ set the entry in the table @/ if ((m2TcpConnTblEntrySet (&tcpEntry) == OK) /@ tcpEntry deleted successfuly @/ .CE INCLUDE FILES: m2Lib.h SEE ALSO: m2Lib, m2IfLib, m2IpLib, m2IcmpLib, m2UdpLib, m2SysLib */ /* includes */ #include #include #include #include #include #include #include #include #include #include #include #include #include /* MIB-II TCP state definitions */ #define M2TCP_CLOSED 1 #define M2TCP_LISTEN 2 #define M2TCP_SYNSENT 3 #define M2TCP_SYNRECEIVED 4 #define M2TCP_ESTABLISHED 5 #define M2TCP_FINWAIT1 6 #define M2TCP_FINWAIT2 7 #define M2TCP_CLOSEWAIT 8 #define M2TCP_LASTACK 9 #define M2TCP_CLOSING 10 #define M2TCP_TIMEWAIT 11 #define M2TCP_DELETETCB 12 #define M2TCP_NSTATES 13 /* type for m2Lib migration to IPNET */ typedef struct M2_ipcom_mib2_TcpConnectionEntry_cookie_t { int tcount; OIDC_T * tlist; M2_TCPCONNTBL * reqInstance; Ipcom_mib2_TcpConnectionEntry * dataPtr; boolean_t getnext; /* FALSE = getexact */ } M2_ipcom_mib2_TcpConnectionEntry_cookie_t; /* locals & global */ LOCAL Ipcom_mib2_TcpConnectionEntry *Ipcom_mib2_TcpConnectionEntry_lookup (M2_TCPCONNTBL *, boolean_t); IP_PUBLIC int tcpConnectionEntry_callback (Ipcom_mib2_TcpConnectionEntry *, void *); /* * This table maps the BSD TCP states to the MIB-II TCP specified states. The * table is indexed using the BSD TCP states. */ #if 0 LOCAL long m2TcpStates [11] = { M2TCP_CLOSED, /* TCPS_CLOSED -> M2TCP_CLOSED */ M2TCP_LISTEN, /* TCPS_LISTEN -> M2TCP_LISTEN */ M2TCP_SYNSENT, /* TCPS_SYN_SENT -> M2TCP_SYNSENT */ M2TCP_SYNRECEIVED, /* TCPS_SYN_RECEIVED -> M2TCP_SYNRECEIVED */ M2TCP_ESTABLISHED, /* TCPS_ESTABLISHED -> M2TCP_ESTABLISHED */ M2TCP_CLOSEWAIT, /* TCPS_CLOSE_WAIT -> M2TCP_CLOSEWAIT */ M2TCP_FINWAIT1, /* TCPS_FIN_WAIT_1 -> M2TCP_FINWAIT1 */ M2TCP_CLOSING, /* TCPS_CLOSING -> M2TCP_CLOSING */ M2TCP_LASTACK, /* TCPS_LAST_ACK -> M2TCP_LASTACK */ M2TCP_FINWAIT2, /* TCPS_FIN_WAIT_2 -> M2TCP_FINWAIT2 */ M2TCP_TIMEWAIT, /* TCPS_TIME_WAIT -> M2TCP_TIMEWAIT */ }; #endif /******************************************************************************* * * m2TcpInit - initialize MIB-II TCP-group access * * This routine allocates the resources needed to allow access to the TCP * MIB-II variables. This routine must be called before any TCP variables * can be accessed. * * RETURNS: OK, always. * * SEE ALSO: * m2TcpGroupInfoGet(), m2TcpConnEntryGet(), m2TcpConnEntrySet(), m2TcpDelete() */ STATUS m2TcpInit (void) { return (OK); } /****************************************************************************** * * m2TcpGroupInfoGet - get MIB-II TCP-group scalar variables * * This routine fills in the TCP structure pointed to by with the * values of MIB-II TCP-group scalar variables. * * RETURNS: OK, or ERROR if is not a valid pointer. * * ERRNO: * S_m2Lib_INVALID_PARAMETER * * SEE ALSO: * m2TcpInit(), m2TcpConnEntryGet(), m2TcpConnEntrySet(), m2TcpDelete() */ STATUS m2TcpGroupInfoGet ( M2_TCPINFO * pTcpInfo /* pointer to the TCP group structure */ ) { Ipcom_mib2_tcp_group tcpGroup; /* Validate Pointer to TCP structure */ if (pTcpInfo == NULL) { errnoSet (S_m2Lib_INVALID_PARAMETER); return (ERROR); } if (ipcom_mib2_get_tcp_group (&tcpGroup) == -1) { return (ERROR); } pTcpInfo->tcpRtoAlgorithm = tcpGroup.tcpRtoAlgorithm; pTcpInfo->tcpRtoMin = tcpGroup.tcpRtoMin; pTcpInfo->tcpRtoMax = tcpGroup.tcpRtoMax; pTcpInfo->tcpMaxConn = tcpGroup.tcpMaxConn; pTcpInfo->tcpActiveOpens = tcpGroup.tcpActiveOpens; pTcpInfo->tcpPassiveOpens = tcpGroup.tcpPassiveOpens; pTcpInfo->tcpAttemptFails = tcpGroup.tcpAttemptFails; pTcpInfo->tcpEstabResets = tcpGroup.tcpEstabResets; pTcpInfo->tcpCurrEstab = tcpGroup.tcpCurrEstab; pTcpInfo->tcpInSegs = tcpGroup.tcpInSegs; pTcpInfo->tcpOutSegs = tcpGroup.tcpOutSegs; pTcpInfo->tcpInErrs = tcpGroup.tcpInErrs; pTcpInfo->tcpOutRsts = tcpGroup.tcpOutRsts; pTcpInfo->tcpRetransSegs = tcpGroup.tcpRetransSegs; return (OK); } /****************************************************************************** * * tcpConnCmp - compare two TCP connections in lexicographical order * * This routine compares two TCP connection control blocks. It compares the * value 1 with value 2. It returns equal, value 1 greater than * value 2, or value 1 less than value 2. The comparison is done based on the * lexicographical order specified by MIB-II. * * RETURNS: 0 = equal, 1 > greater than, and -1 < less than. * * SEE ALSO: N/A * * \NOMANUAL */ LOCAL long tcpConnCmp ( M2_TCPCONNTBL * pConnVal1, /* pointer to control block (Compare against) */ M2_TCPCONNTBL * pConnVal2 /* pointer to control block (Second entry) */ ) { Mib2_Integer result; if (pConnVal1->tcpConnLocalAddress > pConnVal2->tcpConnLocalAddress) return 1; /* First Entry is Greater */ if (pConnVal1->tcpConnLocalAddress < pConnVal2->tcpConnLocalAddress) return -1; /* First Entry is Smaller */ /* Subtract two values INTEGER(0 .. 65535), result is signed Mib2_Integer */ result = pConnVal1->tcpConnLocalPort - pConnVal2->tcpConnLocalPort; if (result > 0) return 1; if (result < 0) return -1; /* Comparison of two unsigned values */ if (pConnVal1->tcpConnRemAddress > pConnVal2->tcpConnRemAddress) return 1; /* First Entry is Greater */ if (pConnVal1->tcpConnRemAddress < pConnVal2->tcpConnRemAddress) return -1; /* First Entry is Smaller */ result = pConnVal1->tcpConnRemPort - pConnVal2->tcpConnRemPort; if (result > 0) return 1; if (result < 0) return -1; return 0; } /************************************************************************************ * * tcpConnectionEntry_callback - RFC1213 tcpConnTable callback * * The routine compares a TCP connection entry with an index key given by the "user" * repeatedly in iterations. The compariation is carried out based on the request type. * The request type can be "get" M2_EXACT_VALUE or "getnext" M2_NEXT_VALU which is in a * lexicographicl order specified by MIB-II. * * RETURNS: 1 stop - find a matched entry , 0 - not match and continue iterations. * * SEE ALSO: N/A * * \NOMANUAL */ IP_PUBLIC int tcpConnectionEntry_callback ( Ipcom_mib2_TcpConnectionEntry * entry, void * user ) { /* Dont do v6 - the MIB code doesn't handle it and attempts to interpret it as v4. */ if(entry->tcpConnectionLocalAddressType != 1) return 1; M2_ipcom_mib2_TcpConnectionEntry_cookie_t * cookie = (M2_ipcom_mib2_TcpConnectionEntry_cookie_t *) user; boolean_t stopIterating = FALSE; boolean_t saveData = FALSE; M2_TCPCONNTBL tableEntry; M2_TCPCONNTBL prevEntry; /* Dont do v6 - the MIB code doesn't handle it and attempts to interpret it as v4. */ if(entry->tcpConnectionLocalAddressType != 1) return 1; tableEntry.tcpConnLocalAddress = ntohl(*(Ip_u32 *)entry->tcpConnectionLocalAddress); tableEntry.tcpConnLocalPort = entry->tcpConnectionLocalPort; tableEntry.tcpConnRemAddress = ntohl(*(Ip_u32 *)entry->tcpConnectionRemAddress); tableEntry.tcpConnRemPort = entry->tcpConnectionRemPort; if (cookie->getnext) { if (tcpConnCmp (&tableEntry, cookie->reqInstance) > 0 ) { if (cookie->dataPtr == NULL) /* first entry in the table */ { saveData = TRUE; } else /* Compare it with the entry alreay stored in data. * Keep the smaller one. */ { prevEntry.tcpConnLocalAddress = ntohl(*(Ip_u32 *)cookie->dataPtr->tcpConnectionLocalAddress); prevEntry.tcpConnLocalPort = cookie->dataPtr->tcpConnectionLocalPort; prevEntry.tcpConnRemAddress = ntohl(*(Ip_u32 *)cookie->dataPtr->tcpConnectionRemAddress); prevEntry.tcpConnRemPort = cookie->dataPtr->tcpConnectionRemPort; if (tcpConnCmp (&tableEntry, &prevEntry) < 0 ) saveData = TRUE; } } else if (tcpConnCmp (&tableEntry, cookie->reqInstance) == 0 ) /* Next instance in pReqTcpConnEntry is found */ { saveData = TRUE; stopIterating = TRUE; } } else /* Get exact */ { if (tcpConnCmp(&tableEntry, cookie->reqInstance) == 0) { saveData = TRUE; stopIterating = TRUE; } } if ( saveData) { if (cookie->dataPtr == NULL) cookie->dataPtr = (Ipcom_mib2_TcpConnectionEntry *)SNMP_memory_alloc (sizeof (Ipcom_mib2_TcpConnectionEntry)); if (cookie->dataPtr != NULL) memcpy(cookie->dataPtr, entry, sizeof (Ipcom_mib2_TcpConnectionEntry)); /* Return values defined are part of callback API. */ } return (stopIterating? 1: 0); } /* *=========================================================================== * ipcom_mib2_iterate_tcpConnectionListenerTable *=========================================================================== * Description: * Parameters: * Returns: */ IP_STATIC int ipcom_mib2_iterate_tcpConnectionListenerTable(Ipcom_mib2_tcpConnectionTableCb cb, void *user) { void *suspend_handle; int i, count = 0; Ipcom_mib2_TcpConnectionEntry entry; if (cb == IP_NULL) return -1; ipcom_memset(&entry, 0, sizeof(entry)); suspend_handle = ipnet_suspend_stack(); if (suspend_handle == IP_NULL) return -1; for(i = 0; i < ipnet_conf_max_sockets; i++) { if (ipnet->sockets[i] != IP_NULL && ipnet->sockets[i]->ipcom.type == IP_SOCK_STREAM && ipnet->sockets[i]->proto == IP_IPPROTO_TCP && ipnet->sockets[i]->tcb != IP_NULL && (ipnet->sockets[i]->ipcom.domain == IP_AF_INET || ipnet->sockets[i]->ipcom.domain == IP_AF_INET6)) { #ifdef IPCOM_USE_INET if (ipnet->sockets[i]->ipcom.domain == IP_AF_INET) { entry.tcpConnectionLocalAddressType = 1; /* ipv4(1) */ entry.tcpConnectionRemAddressType = 1; /* ipv4(1) */ *(Ip_u32 *)entry.tcpConnectionLocalAddress = ipnet->sockets[i]->ip4->saddr_n; *(Ip_u32 *)entry.tcpConnectionRemAddress = ipnet->sockets[i]->ip4->daddr_n; } #endif #ifdef IPCOM_USE_INET6 if (ipnet->sockets[i]->ipcom.domain == IP_AF_INET6) { entry.tcpConnectionLocalAddressType = IP_IN6_IS_ADDR_LINK_LOCAL(&ipnet->sockets[i]->ip6->saddr) ? 4 : 2; /* ipv6(2) ipv6z(4) */ entry.tcpConnectionRemAddressType = IP_IN6_IS_ADDR_LINK_LOCAL(&ipnet->sockets[i]->ip6->daddr) ? 4 : 2; /* ipv6(2) ipv6z(4) */ ((Ip_u32 *)entry.tcpConnectionLocalAddress)[0] = ipnet->sockets[i]->ip6->saddr.in6.addr32[0]; ((Ip_u32 *)entry.tcpConnectionLocalAddress)[1] = ipnet->sockets[i]->ip6->saddr.in6.addr32[1]; ((Ip_u32 *)entry.tcpConnectionLocalAddress)[2] = ipnet->sockets[i]->ip6->saddr.in6.addr32[2]; ((Ip_u32 *)entry.tcpConnectionLocalAddress)[3] = ipnet->sockets[i]->ip6->saddr.in6.addr32[3]; ((Ip_u32 *)entry.tcpConnectionLocalAddress)[4] = IP_IN6_IS_ADDR_LINK_LOCAL(&ipnet->sockets[i]->ip6->saddr) ? ipnet->sockets[i]->ip6->iscope_id : 0; ((Ip_u32 *)entry.tcpConnectionRemAddress)[0] = ipnet->sockets[i]->ip6->daddr.in6.addr32[0]; ((Ip_u32 *)entry.tcpConnectionRemAddress)[1] = ipnet->sockets[i]->ip6->daddr.in6.addr32[1]; ((Ip_u32 *)entry.tcpConnectionRemAddress)[2] = ipnet->sockets[i]->ip6->daddr.in6.addr32[2]; ((Ip_u32 *)entry.tcpConnectionRemAddress)[3] = ipnet->sockets[i]->ip6->daddr.in6.addr32[3]; ((Ip_u32 *)entry.tcpConnectionRemAddress)[4] = IP_IN6_IS_ADDR_LINK_LOCAL(&ipnet->sockets[i]->ip6->daddr) ? ipnet->sockets[i]->ip6->iscope_id : 0; } #endif entry.tcpConnectionLocalPort = (Ipcom_mib2_InetPortNumber)ipnet->sockets[i]->sport; entry.tcpConnectionRemPort = (Ipcom_mib2_InetPortNumber)ipnet->sockets[i]->dport; entry.tcpConnectionState = ipnet->sockets[i]->tcb->state; entry.tcpConnectionProcess = (Ip_u32)ipnet->sockets[i]->ipcom.pid; /* Callback function */ count++; if (cb(&entry, user) == 1) goto exit; } } exit: ipnet_resume_stack(suspend_handle); return count; } /************************************************************************** * * Ipcom_mib2_TcpConnectionEntry_lookup - Search a RFC1213 tcpConnTable * * The routine search a tcpConnTable through a API provided by the IPNET, * which is ipcom_mib2_iterate_tcpConnectionTable. It executes a user * defined callback function for each iteration. Note that if the table * is empty the callback will not be called and the routine will return * zero. * * RETURNS: a entry found or NULL * * SEE ALSO: N/A * * \NOMANUAL */ LOCAL Ipcom_mib2_TcpConnectionEntry *Ipcom_mib2_TcpConnectionEntry_lookup ( M2_TCPCONNTBL * reqInstance, boolean_t getnext ) { M2_ipcom_mib2_TcpConnectionEntry_cookie_t cookie; cookie.dataPtr = NULL; cookie.getnext = getnext; cookie.reqInstance = reqInstance; ipcom_mib2_iterate_tcpConnectionListenerTable (tcpConnectionEntry_callback, (void *)&cookie); return (cookie.dataPtr); } /****************************************************************************** * * m2TcpConnEntryGet - get a MIB-II TCP connection table entry * * This routine traverses the TCP table of users and does an * M2_EXACT_VALUE or a M2_NEXT_VALUE search based on the * parameter (see m2Lib). The calling routine is responsible * for supplying a valid MIB-II entry index in the input structure * . The index is made up of the local IP address, * the local port number, the remote IP address, and the remote port. * The first entry in the table is retrieved by doing a M2_NEXT_VALUE * search with the index fields set to zero. * * RETURNS: * OK, or ERROR if the input parameter is not specified or a * match is not found. * * ERRNO: * S_m2Lib_INVALID_PARAMETER * S_m2Lib_ENTRY_NOT_FOUND * * SEE ALSO: * m2Lib, m2TcpInit(), m2TcpGroupInfoGet(), m2TcpConnEntrySet(), m2TcpDelete() */ STATUS m2TcpConnEntryGet ( int search, /* M2_EXACT_VALUE or M2_NEXT_VALUE */ M2_TCPCONNTBL * pReqTcpConnEntry /* input = Index, Output = Entry */ ) { Ipcom_mib2_TcpConnectionEntry * data; /* Validate Pointer to TCP Table Entry structure */ if (pReqTcpConnEntry == NULL) { errnoSet (S_m2Lib_INVALID_PARAMETER); return (ERROR); } /* * traverse the tcp connections table from the stack of ipnet * until findng a one, which matches the instance. */ if (search == M2_EXACT_VALUE) { if ((data = (Ipcom_mib2_TcpConnectionEntry *) Ipcom_mib2_TcpConnectionEntry_lookup (pReqTcpConnEntry, FALSE)) == NULL) { return (ERROR); } } else /* getNext */ { if ((data = (Ipcom_mib2_TcpConnectionEntry *) Ipcom_mib2_TcpConnectionEntry_lookup (pReqTcpConnEntry, TRUE)) == NULL) { return (ERROR); } } if (data->tcpConnectionState == M2TCP_NSTATES) { errnoSet (S_m2Lib_ENTRY_NOT_FOUND); free(data); return (ERROR); /* Requested Entry Not Found */ } pReqTcpConnEntry->tcpConnState = data->tcpConnectionState; pReqTcpConnEntry->tcpConnLocalAddress = ntohl(*(Ip_u32 *)data->tcpConnectionLocalAddress); pReqTcpConnEntry->tcpConnLocalPort = data->tcpConnectionLocalPort; pReqTcpConnEntry->tcpConnRemAddress = ntohl(*(Ip_u32 *) data->tcpConnectionRemAddress); pReqTcpConnEntry->tcpConnRemPort = data->tcpConnectionRemPort; free(data); return (OK); } /****************************************************************************** * * m2TcpConnEntrySet - set a TCP connection to the closed state * * This routine traverses the TCP connection table and searches for the * connection specified by the input parameter . The * calling routine is responsible for providing a valid index as the * input parameter . The index is made up of the * local IP address, the local port number, the remote IP address, and * the remote port. This call can only succeed if the connection is in * the MIB-II state "deleteTCB" (12). If a match is found, the socket * associated with the TCP connection is closed. * * RETURNS: * OK, or ERROR if the input parameter is invalid, the state of the * connection specified at is not "closed," * the specified connection is not found, a socket is not associated * with the connection, or the close() call fails. * * SEE ALSO: * m2TcpInit(), m2TcpGroupInfoGet(), m2TcpConnEntryGet(), m2TcpDelete() */ STATUS m2TcpConnEntrySet ( M2_TCPCONNTBL * pReqTcpConnEntry /* pointer to TCP connection to close */ ) { Ipcom_mib2_TcpConnectionEntry pSetEntry; pReqTcpConnEntry->tcpConnLocalAddress = htonl(pReqTcpConnEntry->tcpConnLocalAddress); pReqTcpConnEntry->tcpConnRemAddress = htonl(pReqTcpConnEntry->tcpConnRemAddress); /* Fill the request info. and set address type to 1 as only IPV4 is required */ pSetEntry.tcpConnectionLocalPort = pReqTcpConnEntry->tcpConnLocalPort; memcpy(&pSetEntry.tcpConnectionLocalAddress, &pReqTcpConnEntry->tcpConnLocalAddress, sizeof(Mib2_IpAddress)); pSetEntry.tcpConnectionRemPort = pReqTcpConnEntry->tcpConnRemPort; memcpy(&pSetEntry.tcpConnectionRemAddress, &pReqTcpConnEntry->tcpConnRemAddress, sizeof(Mib2_IpAddress)); pSetEntry.tcpConnectionLocalAddressType = 1; pSetEntry.tcpConnectionRemAddressType = 1; /* tcpConnState must be 12 (deleteTCB) for closing the connection */ if(ipcom_mib2_set_tcpConnectionState(&pSetEntry, pReqTcpConnEntry->tcpConnState) != OK) return (ERROR); return (OK); } /******************************************************************************* * * m2TcpDelete - delete all resources used to access the TCP group * * This routine frees all the resources allocated at the time the group was * initialized. The TCP group should not be accessed after this routine has been * called. * * RETURNS: OK, always. * * SEE ALSO: * m2TcpInit(), m2TcpGroupInfoGet(), m2TcpConnEntryGet(), m2TcpConnEntrySet() */ STATUS m2TcpDelete (void) { return (OK); }