Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1602 lines
44 KiB

  1. //////////////////////////////////////////////////////////////////////
  2. // IPUtil.cpp : Implementation for the socket related util functions
  3. // Copyright (c)1997-2001 Microsoft Corporation
  4. //
  5. // Original Create Date: 5/16/2001
  6. // Original Author: shawnwu
  7. //////////////////////////////////////////////////////////////////////
  8. #include "IPUtil.h"
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <string.h>
  12. #include <ctype.h>
  13. #include <time.h>
  14. #include <nt.h>
  15. #include <ntrtl.h>
  16. #include <nturtl.h>
  17. #include <snmp.h>
  18. #include <winsock2.h>
  19. #include <Mgmtapi.h>
  20. //
  21. // for active socket
  22. //
  23. //
  24. // The following section is copied from \nt\net\tcpip\commands\common2\snmpinfo.c
  25. // that implements the common helper functions inside declared inside \nt\net\tcpip\commands\common2\common2.h,
  26. // which is now copied into our header ActiveSocket.h
  27. //
  28. ulong verbose = 0;
  29. //
  30. // Definitions
  31. //
  32. #define MAX_ID_LENGTH 50
  33. #define MAX_RETRY_COUNT 10
  34. // Interface ID values
  35. #define ID_IF_INDEX 1
  36. #define ID_IF_DESC 2
  37. #define ID_IF_TYPE 3
  38. #define ID_IF_MTU 4
  39. #define ID_IF_SPEED 5
  40. #define ID_IF_PHYSADDR 6
  41. #define ID_IF_ADMINSTATUS 7
  42. #define ID_IF_OPERSTATUS 8
  43. #define ID_IF_LASTCHANGE 9
  44. #define ID_IF_INOCTETS 10
  45. #define ID_IF_INUCASTPKTS 11
  46. #define ID_IF_INNUCASTPKTS 12
  47. #define ID_IF_INDISCARDS 13
  48. #define ID_IF_INERRORS 14
  49. #define ID_IF_INUKNOWNPROTOS 15
  50. #define ID_IF_OUTOCTETS 16
  51. #define ID_IF_OUTUCASTPKTS 17
  52. #define ID_IF_OUTNUCASTPKTS 18
  53. #define ID_IF_OUTDISCARDS 19
  54. #define ID_IF_OUTERRORS 20
  55. #define ID_IF_OUTQLEN 21
  56. // IP ID Values
  57. #define ID_IP_FORWARDING 1
  58. #define ID_IP_DEFAULTTTL 2
  59. #define ID_IP_INRECEIVES 3
  60. #define ID_IP_INHDRERRORS 4
  61. #define ID_IP_INADDRERRORS 5
  62. #define ID_IP_FORWDATAGRAMS 6
  63. #define ID_IP_INUNKNOWNPROTOS 7
  64. #define ID_IP_INDISCARDS 8
  65. #define ID_IP_INDELIVERS 9
  66. #define ID_IP_OUTREQUESTS 10
  67. #define ID_IP_OUTDISCARDS 11
  68. #define ID_IP_OUTNOROUTES 12
  69. #define ID_IP_REASMTIMEOUTS 13
  70. #define ID_IP_REASMREQDS 14
  71. #define ID_IP_REASMOKS 15
  72. #define ID_IP_REASMFAILS 16
  73. #define ID_IP_FRAGOKS 17
  74. #define ID_IP_FRAGFAILS 18
  75. #define ID_IP_FRAGCREATES 19
  76. #define ID_IP_ADDRTABLE 20
  77. #define ID_IP_ROUTETABLE 21
  78. #define ID_IP_ARPTABLE 22
  79. #define ID_IP_ROUTINGDISCARDS 23
  80. // IPAddr ID Values
  81. #define ID_IPADDR_ADDR 1
  82. #define ID_IPADDR_INDEX 2
  83. #define ID_IPADDR_MASK 3
  84. #define ID_IPADDR_BCASTADDR 4
  85. #define ID_IPADDR_REASMSIZE 5
  86. // Route ID values
  87. #define ID_ROUTE_DEST 1
  88. #define ID_ROUTE_IFINDEX 2
  89. #define ID_ROUTE_METRIC1 3
  90. #define ID_ROUTE_METRIC2 4
  91. #define ID_ROUTE_METRIC3 5
  92. #define ID_ROUTE_METRIC4 6
  93. #define ID_ROUTE_NEXTHOP 7
  94. #define ID_ROUTE_TYPE 8
  95. #define ID_ROUTE_PROTO 9
  96. #define ID_ROUTE_AGE 10
  97. #define ID_ROUTE_MASK 11
  98. #define ID_ROUTE_METRIC5 12
  99. // ARP ID Values
  100. #define ID_ARP_IFINDEX 1
  101. #define ID_ARP_PHYSADDR 2
  102. #define ID_ARP_NETADDR 3
  103. #define ID_ARP_TYPE 4
  104. // ICMP ID Values
  105. #define ID_ICMP_INMSGS 1
  106. #define ID_ICMP_INERRORS 2
  107. #define ID_ICMP_INDESTUNREACHES 3
  108. #define ID_ICMP_INTIMEEXCDS 4
  109. #define ID_ICMP_INPARMPROBS 5
  110. #define ID_ICMP_INSRCQUENCHS 6
  111. #define ID_ICMP_INREDIRECTS 7
  112. #define ID_ICMP_INECHOS 8
  113. #define ID_ICMP_INECHOREPS 9
  114. #define ID_ICMP_INTIMESTAMPS 10
  115. #define ID_ICMP_INTIMESTAMPREPS 11
  116. #define ID_ICMP_INADDRMASKS 12
  117. #define ID_ICMP_INADDRMASKREPS 13
  118. #define ID_ICMP_OUTMSGS 14
  119. #define ID_ICMP_OUTERRORS 15
  120. #define ID_ICMP_OUTDESTUNREACHES 16
  121. #define ID_ICMP_OUTTIMEEXCDS 17
  122. #define ID_ICMP_OUTPARMPROBS 18
  123. #define ID_ICMP_OUTSRCQUENCHS 19
  124. #define ID_ICMP_OUTREDIRECTS 20
  125. #define ID_ICMP_OUTECHOS 21
  126. #define ID_ICMP_OUTECHOREPS 22
  127. #define ID_ICMP_OUTTIMESTAMPS 23
  128. #define ID_ICMP_OUTTIMESTAMPREPS 24
  129. #define ID_ICMP_OUTADDRMASKS 25
  130. #define ID_ICMP_OUTADDRMASKREPS 26
  131. // TCP ID Values
  132. #define ID_TCP_RTOALGORITHM 1
  133. #define ID_TCP_RTOMIN 2
  134. #define ID_TCP_RTOMAX 3
  135. #define ID_TCP_MAXCONN 4
  136. #define ID_TCP_ACTIVEOPENS 5
  137. #define ID_TCP_PASSIVEOPENS 6
  138. #define ID_TCP_ATTEMPTFAILS 7
  139. #define ID_TCP_ESTABRESETS 8
  140. #define ID_TCP_CURRESTABS 9
  141. #define ID_TCP_INSEGS 10
  142. #define ID_TCP_OUTSEGS 11
  143. #define ID_TCP_RETRANSSEGS 12
  144. #define ID_TCP_CONNTABLE 13
  145. #define ID_TCP_INERRS 14
  146. #define ID_TCP_OUTRSTS 15
  147. // TCP CONN ID Values
  148. #define ID_TCPCONN_STATE 1
  149. #define ID_TCPCONN_LOCALADDR 2
  150. #define ID_TCPCONN_LOCALPORT 3
  151. #define ID_TCPCONN_REMOTEADDR 4
  152. #define ID_TCPCONN_REMOTEPORT 5
  153. // UDP ID Values
  154. #define ID_UDP_INDATAGRAMS 1
  155. #define ID_UDP_NOPORTS 2
  156. #define ID_UDP_INERRORS 3
  157. #define ID_UDP_OUTDATAGRAMS 4
  158. #define ID_UDP_CONNTABLE 5
  159. // UDP CONN ID Values
  160. #define ID_UDPCONN_LOCALADDR 1
  161. #define ID_UDPCONN_LOCALPORT 2
  162. //
  163. // Structure Definitions
  164. //
  165. typedef struct _OIDdef {
  166. ulong Length;
  167. ulong Val[MAX_ID_LENGTH];
  168. ulong EntElemOffset;
  169. ulong BackOffset;
  170. } OIDdef;
  171. //
  172. // Local Function Prototypes
  173. //
  174. ulong ReadTable( GenericTable *pList, ulong Type, ulong Size );
  175. void SaveData_IF( GenericTable *pEntry,
  176. RFC1157VarBind item,
  177. OIDdef *pOid );
  178. void SaveData_IP( GenericTable *pEntry,
  179. RFC1157VarBind item,
  180. OIDdef *pOid );
  181. void SaveData_IPAddr( GenericTable *pEntry,
  182. RFC1157VarBind item,
  183. OIDdef *pOid );
  184. void SaveData_ROUTE( GenericTable *pEntry,
  185. RFC1157VarBind item,
  186. OIDdef *pOid );
  187. void SaveData_ARP( GenericTable *pEntry,
  188. RFC1157VarBind item,
  189. OIDdef *pOid );
  190. void SaveData_ICMP( GenericTable *pEntry,
  191. RFC1157VarBind item,
  192. OIDdef *pOid );
  193. void SaveData_TCP( GenericTable *pEntry,
  194. RFC1157VarBind item,
  195. OIDdef *pOid );
  196. void SaveData_TCPCONN( GenericTable *pEntry,
  197. RFC1157VarBind item,
  198. OIDdef *pOid );
  199. void SaveData_UDP( GenericTable *pEntry,
  200. RFC1157VarBind item,
  201. OIDdef *pOid );
  202. void SaveData_UDPCONN( GenericTable *pEntry,
  203. RFC1157VarBind item,
  204. OIDdef *pOid );
  205. //
  206. // Global Variables
  207. //
  208. // These are used to create object id's
  209. OIDdef PreambleDef = { 6, { 1, 3, 6, 1, 2, 1 }, 0, 0 };
  210. OIDdef IfInfoDef = { 4, { 2, 2, 1, 1 }, 9, 2 };
  211. OIDdef IPInfoDef = { 2, { 4, 1 }, 7, 1 };
  212. OIDdef IPAddrInfoDef = { 4, { 4, 20, 1, 1 }, 9, 2 };
  213. OIDdef RouteInfoDef = { 4, { 4, 21, 1, 1 }, 9, 2 };
  214. OIDdef ARPInfoDef = { 4, { 4, 22, 1, 1 }, 9, 2 };
  215. OIDdef ICMPInfoDef = { 2, { 5, 1, }, 7, 1 };
  216. OIDdef TCPInfoDef = { 2, { 6, 1 }, 7, 1 };
  217. OIDdef TCPConnDef = { 4, { 6, 13, 1, 1 }, 9, 2 };
  218. OIDdef UDPInfoDef = { 2, { 7, 1 }, 7, 1 };
  219. OIDdef UDPConnDef = { 4, { 7, 5, 1, 1 }, 9, 2 };
  220. // These are used to hold the addresses of the functions we use in inetmib1.dll
  221. FARPROC gQueryAddr;
  222. FARPROC gInitAddr;
  223. //
  224. // Exported Functions
  225. //
  226. //*****************************************************************************
  227. //
  228. // Name: GetTable
  229. //
  230. // Description: Gets a consistent table from snmp. Consistency is achieved by
  231. // reading the table, reading the table a second time and
  232. // comparing the two. If they match, we are done. If they don't
  233. // match, we read the table again and compare again. Repeating
  234. // until we have a match, or our retry count exceeds a threshold.
  235. //
  236. // Parameters: ulong Type: type of table to get.
  237. // ulong *pResult: pointer to location to receive the result code.
  238. //
  239. // Returns: void *: NULL if some error, otherwise pointer to table.
  240. //
  241. // History:
  242. // 01/12/94 JayPh Created.
  243. // 18-Feb-97 MohsinA Removed while loop and pList1.
  244. //*****************************************************************************
  245. void *GetTable( ulong Type, ulong *pResult )
  246. {
  247. GenericTable *pList2;
  248. ulong Result;
  249. ulong RetryCount = 0;
  250. ulong Size;
  251. if( verbose ){
  252. fprintf(stderr, "GetTable: type = %d\n", Type );
  253. }
  254. if ( Type > TYPE_UDPCONN )
  255. {
  256. *pResult = ERROR_INVALID_PARAMETER;
  257. return ( NULL );
  258. }
  259. // Allocate memory for the list heads
  260. switch ( Type )
  261. {
  262. case TYPE_IF:
  263. Size = sizeof( IfEntry ) + MAX_IFDESCR_LEN;
  264. break;
  265. case TYPE_IP:
  266. Size = sizeof( IpEntry );
  267. break;
  268. case TYPE_IPADDR:
  269. Size = sizeof( IpAddrEntry );
  270. break;
  271. case TYPE_ROUTE:
  272. Size = sizeof( RouteEntry );
  273. break;
  274. case TYPE_ARP:
  275. Size = sizeof( ArpEntry );
  276. break;
  277. case TYPE_ICMP:
  278. Size = sizeof( IcmpEntry );
  279. break;
  280. case TYPE_TCP:
  281. Size = sizeof( TcpEntry );
  282. break;
  283. case TYPE_TCPCONN:
  284. Size = sizeof( TcpConnEntry );
  285. break;
  286. case TYPE_UDP:
  287. Size = sizeof( UdpEntry );
  288. break;
  289. case TYPE_UDPCONN:
  290. Size = sizeof( UdpConnEntry );
  291. break;
  292. }
  293. // Don't need pList1 - MohsinA, 18-Feb-97.
  294. pList2 = (GenericTable *)SNMP_malloc( Size );
  295. if ( pList2 == NULL )
  296. {
  297. *pResult = ERROR_NOT_ENOUGH_MEMORY;
  298. return ( NULL );
  299. }
  300. InitializeListHead( &pList2->ListEntry );
  301. // Read the table into List2
  302. Result = ReadTable( pList2, Type, Size );
  303. if ( Result != NO_ERROR )
  304. {
  305. FreeTable( pList2 );
  306. *pResult = Result;
  307. return ( NULL );
  308. }
  309. // Useless while loop removed. - MohsinA, 18-Feb-97.
  310. *pResult = NO_ERROR;
  311. return ( pList2 );
  312. }
  313. //*****************************************************************************
  314. //
  315. // Name: FreeTable
  316. //
  317. // Description: Free all entries in the list, including the list head.
  318. //
  319. // Parameters: GenericTable *pList: pointer to head of list.
  320. //
  321. // Returns: void.
  322. //
  323. // History:
  324. // 01/12/94 JayPh Created.
  325. //
  326. //*****************************************************************************
  327. void FreeTable( GenericTable *pList )
  328. {
  329. GenericTable *pTmp;
  330. LIST_ENTRY *pTmpList;
  331. while ( !IsListEmpty( &pList->ListEntry ) )
  332. {
  333. pTmpList = RemoveHeadList( &pList->ListEntry );
  334. pTmp = CONTAINING_RECORD( pTmpList,
  335. GenericTable,
  336. ListEntry );
  337. SNMP_free( pTmp );
  338. }
  339. SNMP_free( pList );
  340. }
  341. //*****************************************************************************
  342. //
  343. // Name: MapSnmpErrorToNt
  344. //
  345. // Description: Given an Snmp error, return the 'equivalent' Nt error.
  346. //
  347. // Parameters: ulong ErrCode: Snmp error code.
  348. //
  349. // Returns: ulong: Nt error code.
  350. //
  351. // History:
  352. // 01/05/93 JayPh Created.
  353. //
  354. //*****************************************************************************
  355. ulong MapSnmpErrorToNt( ulong ErrCode )
  356. {
  357. switch ( ErrCode )
  358. {
  359. case SNMP_ERRORSTATUS_NOERROR:
  360. return ( NO_ERROR );
  361. case SNMP_ERRORSTATUS_TOOBIG:
  362. return ( ERROR_INVALID_PARAMETER );
  363. case SNMP_ERRORSTATUS_NOSUCHNAME:
  364. return ( ERROR_INVALID_PARAMETER );
  365. case SNMP_ERRORSTATUS_BADVALUE:
  366. return ( ERROR_INVALID_PARAMETER );
  367. case SNMP_ERRORSTATUS_READONLY:
  368. return ( ERROR_INVALID_ACCESS );
  369. case SNMP_ERRORSTATUS_GENERR:
  370. return ( ERROR_INVALID_PARAMETER );
  371. }
  372. return ( ERROR_INVALID_PARAMETER );
  373. }
  374. //
  375. // Internal Functions
  376. //
  377. //*****************************************************************************
  378. //
  379. // Name: ReadTable
  380. //
  381. // Description: Queries the MIB and builds a table representing the data we are
  382. // interested in.
  383. //
  384. // Parameters: GenericTable *pList: address of unitialized head of the entry
  385. // list.
  386. // ulong Type: type of table we want.
  387. // ulong Size: size of a table entry.
  388. //
  389. // Returns: ulong: NO_ERROR if no error, and table is built.
  390. //
  391. // History:
  392. // 01/12/94 JayPh Created.
  393. //
  394. //*****************************************************************************
  395. ulong ReadTable( GenericTable *pList, ulong Type, ulong Size )
  396. {
  397. AsnInteger GetNextReq = ASN_RFC1157_GETNEXTREQUEST;
  398. RFC1157VarBind item;
  399. RFC1157VarBindList VarBinds = { &item, 1 };
  400. AsnObjectIdentifier oidBackup;
  401. AsnInteger ErrorStatus = 0;
  402. AsnInteger ErrorIndex = 0;
  403. UINT *pId;
  404. GenericTable *pTable;
  405. ulong LastField = 0;
  406. uchar *pTmp;
  407. ulong i;
  408. OIDdef *pOid;
  409. UINT BreakLoop = FALSE;
  410. if( verbose ){
  411. fprintf(stderr,"ReadTable: type = %d\n", Type);
  412. }
  413. // Walk SNMP database, building local table.
  414. pId = (UINT *)SNMP_malloc( (sizeof( ulong ) * MAX_ID_LENGTH) );
  415. if ( pId == NULL )
  416. {
  417. return ( ERROR_NOT_ENOUGH_MEMORY );
  418. }
  419. item.name.ids = pId;
  420. // Build OID from preamble and table-specific suffix
  421. // Copy preamble
  422. for ( i = 0; i < PreambleDef.Length; i++ )
  423. {
  424. *pId++ = PreambleDef.Val[i];
  425. }
  426. // Get pointer to table-specific info
  427. switch ( Type )
  428. {
  429. case TYPE_IF:
  430. pOid = &IfInfoDef;
  431. break;
  432. case TYPE_IP:
  433. pOid = &IPInfoDef;
  434. break;
  435. case TYPE_IPADDR:
  436. pOid = &IPAddrInfoDef;
  437. break;
  438. case TYPE_ROUTE:
  439. pOid = &RouteInfoDef;
  440. break;
  441. case TYPE_ARP:
  442. pOid = &ARPInfoDef;
  443. break;
  444. case TYPE_ICMP:
  445. pOid = &ICMPInfoDef;
  446. break;
  447. case TYPE_TCP:
  448. pOid = &TCPInfoDef;
  449. break;
  450. case TYPE_TCPCONN:
  451. pOid = &TCPConnDef;
  452. break;
  453. case TYPE_UDP:
  454. pOid = &UDPInfoDef;
  455. break;
  456. case TYPE_UDPCONN:
  457. pOid = &UDPConnDef;
  458. break;
  459. }
  460. // Copy table-specific info
  461. for ( i = 0; i < pOid->Length; i++ )
  462. {
  463. *pId++ = pOid->Val[i];
  464. }
  465. item.name.idLength = PreambleDef.Length + pOid->Length;
  466. item.value.asnType = ASN_NULL;
  467. pTable = pList;
  468. // Walk the mib until the table-specific termination condition is met.
  469. while( 1 )
  470. {
  471. // Get next
  472. SnmpExtensionQuery( SNMP_PDU_GETNEXT, &VarBinds, &ErrorStatus, &ErrorIndex );
  473. if( verbose )
  474. {
  475. int q;
  476. fprintf(stderr,"value=%8d oid= ", item.value.asnValue.number );
  477. //
  478. // Print the object name
  479. //
  480. LPSTR String = NULL;
  481. int err = SnmpMgrOidToStr ( &item.name, &String );
  482. if( SNMPAPI_ERROR != err ){
  483. fprintf(stderr," %s ", String );
  484. }
  485. SnmpUtilMemFree( String );
  486. if ( (verbose > 1) ){
  487. //
  488. // Print the oid, in ``1.3.6.1.2.1'' style.
  489. //
  490. for ( q = 0; q < (int) item.name.idLength; q++ ){
  491. // Must align the output to read huge tables.
  492. if( q < 6 ){
  493. fprintf( stderr,"%d.", item.name.ids[q]);
  494. }else if( q < 9 ){
  495. fprintf( stderr,"%2d.", item.name.ids[q]);
  496. }else{
  497. fprintf( stderr,"%3d.", item.name.ids[q]);
  498. }
  499. }
  500. }
  501. fprintf(stderr,"\n");
  502. }
  503. if ( ErrorStatus != 0 )
  504. {
  505. SnmpUtilVarBindFree( &item );
  506. return ( MapSnmpErrorToNt( ErrorStatus ) );
  507. }
  508. // We want to break out of this while loop if the defining part of the
  509. // OID changes
  510. if ( item.name.idLength < ( PreambleDef.Length + pOid->Length ) )
  511. {
  512. break;
  513. }
  514. for ( i = PreambleDef.Length;
  515. i < PreambleDef.Length + pOid->Length - pOid->BackOffset;
  516. i++ )
  517. {
  518. if ( item.name.ids[i] != pOid->Val[i - PreambleDef.Length] )
  519. {
  520. BreakLoop = TRUE;
  521. break;
  522. }
  523. }
  524. if ( BreakLoop )
  525. {
  526. break;
  527. }
  528. // We want to ignore certain entries. EG: the TCP statistics will also
  529. // return the TCP connection table, which we don't want (there is a
  530. // separate Type code for that).
  531. switch ( Type )
  532. {
  533. case TYPE_IP:
  534. if ( ( item.name.ids[pOid->EntElemOffset] == ID_IP_ADDRTABLE ) ||
  535. ( item.name.ids[pOid->EntElemOffset] == ID_IP_ROUTETABLE ) ||
  536. ( item.name.ids[pOid->EntElemOffset] == ID_IP_ARPTABLE ) )
  537. {
  538. continue;
  539. }
  540. break;
  541. case TYPE_TCP:
  542. if ( item.name.ids[pOid->EntElemOffset] == ID_TCP_CONNTABLE )
  543. {
  544. continue;
  545. }
  546. break;
  547. case TYPE_UDP:
  548. if ( item.name.ids[pOid->EntElemOffset] == ID_UDP_CONNTABLE )
  549. {
  550. continue;
  551. }
  552. break;
  553. }
  554. // Entry handling:
  555. //
  556. // There are 3 cases to consider:
  557. // 1. If the list is empty, OR at the end of the list AND the
  558. // CurrField == LastField.
  559. // Then add a new entry to the list.
  560. // 2. CurrField != LastField.
  561. // Then reset pointer to start of the list.
  562. // 3. Otherwise
  563. // Then go to next entry in the list.
  564. if ( ( pTable == pList ) ||
  565. ( ( pTable->ListEntry.Flink == &pList->ListEntry ) &&
  566. ( item.name.ids[pOid->EntElemOffset] == LastField ) ) )
  567. {
  568. // Add new entry to table
  569. pTable = (GenericTable *)SNMP_malloc( Size );
  570. if ( pTable == NULL )
  571. {
  572. SnmpUtilVarBindFree( &item );
  573. return ( ERROR_NOT_ENOUGH_MEMORY );
  574. }
  575. InsertTailList( &pList->ListEntry, &pTable->ListEntry );
  576. }
  577. else if ( item.name.ids[pOid->EntElemOffset] != LastField )
  578. {
  579. // Reset pointer to start of list
  580. pTable = CONTAINING_RECORD( pList->ListEntry.Flink,
  581. GenericTable,
  582. ListEntry );
  583. }
  584. else
  585. {
  586. // Move pointer to next entry in list
  587. pTable = CONTAINING_RECORD( pTable->ListEntry.Flink,
  588. GenericTable,
  589. ListEntry );
  590. }
  591. LastField = item.name.ids[pOid->EntElemOffset];
  592. // Save info in our list. pTable points to desired entry.
  593. switch ( Type )
  594. {
  595. case TYPE_IF:
  596. SaveData_IF( pTable, item, pOid );
  597. break;
  598. case TYPE_IP:
  599. SaveData_IP( pTable, item, pOid );
  600. break;
  601. case TYPE_IPADDR:
  602. SaveData_IPAddr( pTable, item, pOid );
  603. break;
  604. case TYPE_ROUTE:
  605. SaveData_ROUTE( pTable, item, pOid );
  606. break;
  607. case TYPE_ARP:
  608. SaveData_ARP( pTable, item, pOid );
  609. break;
  610. case TYPE_ICMP:
  611. SaveData_ICMP( pTable, item, pOid );
  612. break;
  613. case TYPE_TCP:
  614. SaveData_TCP( pTable, item, pOid );
  615. break;
  616. case TYPE_TCPCONN:
  617. SaveData_TCPCONN( pTable, item, pOid );
  618. break;
  619. case TYPE_UDP:
  620. SaveData_UDP( pTable, item, pOid );
  621. break;
  622. case TYPE_UDPCONN:
  623. SaveData_UDPCONN( pTable, item, pOid );
  624. break;
  625. }
  626. SnmpUtilOidCpy( &oidBackup, &(item.name));
  627. SnmpUtilVarBindFree( &item );
  628. item.name.idLength = oidBackup.idLength;
  629. item.name.ids = oidBackup.ids;
  630. }
  631. SnmpUtilVarBindFree( &item );
  632. return ( NO_ERROR );
  633. }
  634. //*****************************************************************************
  635. //
  636. // Name: SaveData_IF
  637. //
  638. // Description: Saves an element of the data in the interface table.
  639. //
  640. // Parameters: GenericTable *pEntry; pointer to table entry.
  641. // RFC1157VarBind item: contains value returned from mib.
  642. // OIDdef *pOid: contains table-specific data.
  643. //
  644. // Returns: void.
  645. //
  646. // History:
  647. // 01/12/94 JayPh Created.
  648. //
  649. //*****************************************************************************
  650. void SaveData_IF( GenericTable *pEntry,
  651. RFC1157VarBind item,
  652. OIDdef *pOid )
  653. {
  654. IfEntry *pIf = ( IfEntry *)pEntry;
  655. uchar *pTmp;
  656. ulong i;
  657. switch ( item.name.ids[pOid->EntElemOffset] )
  658. {
  659. case ID_IF_INDEX:
  660. pIf->Info.if_index = item.value.asnValue.number;
  661. break;
  662. case ID_IF_DESC:
  663. pIf->Info.if_descrlen = item.value.asnValue.string.length;
  664. for ( i = 0; i < pIf->Info.if_descrlen; i++ )
  665. {
  666. pIf->Info.if_descr[i] = item.value.asnValue.string.stream[i];
  667. }
  668. break;
  669. case ID_IF_TYPE:
  670. pIf->Info.if_type = item.value.asnValue.number;
  671. break;
  672. case ID_IF_MTU:
  673. pIf->Info.if_mtu = item.value.asnValue.number;
  674. break;
  675. case ID_IF_SPEED:
  676. pIf->Info.if_speed = item.value.asnValue.number;
  677. break;
  678. case ID_IF_PHYSADDR:
  679. pIf->Info.if_physaddrlen = item.value.asnValue.string.length;
  680. for ( i = 0; i < pIf->Info.if_physaddrlen; i++ )
  681. {
  682. pIf->Info.if_physaddr[i] = item.value.asnValue.string.stream[i];
  683. }
  684. break;
  685. case ID_IF_ADMINSTATUS:
  686. pIf->Info.if_adminstatus = item.value.asnValue.number;
  687. break;
  688. case ID_IF_OPERSTATUS:
  689. pIf->Info.if_operstatus = item.value.asnValue.number;
  690. break;
  691. case ID_IF_LASTCHANGE:
  692. pIf->Info.if_lastchange = item.value.asnValue.number;
  693. break;
  694. case ID_IF_INOCTETS:
  695. pIf->Info.if_inoctets = item.value.asnValue.number;
  696. break;
  697. case ID_IF_INUCASTPKTS:
  698. pIf->Info.if_inucastpkts = item.value.asnValue.number;
  699. break;
  700. case ID_IF_INNUCASTPKTS:
  701. pIf->Info.if_innucastpkts = item.value.asnValue.number;
  702. break;
  703. case ID_IF_INDISCARDS:
  704. pIf->Info.if_indiscards = item.value.asnValue.number;
  705. break;
  706. case ID_IF_INERRORS:
  707. pIf->Info.if_inerrors = item.value.asnValue.number;
  708. break;
  709. case ID_IF_INUKNOWNPROTOS:
  710. pIf->Info.if_inunknownprotos = item.value.asnValue.number;
  711. break;
  712. case ID_IF_OUTOCTETS:
  713. pIf->Info.if_outoctets = item.value.asnValue.number;
  714. break;
  715. case ID_IF_OUTUCASTPKTS:
  716. pIf->Info.if_outucastpkts = item.value.asnValue.number;
  717. break;
  718. case ID_IF_OUTNUCASTPKTS:
  719. pIf->Info.if_outnucastpkts = item.value.asnValue.number;
  720. break;
  721. case ID_IF_OUTDISCARDS:
  722. pIf->Info.if_outdiscards = item.value.asnValue.number;
  723. break;
  724. case ID_IF_OUTERRORS:
  725. pIf->Info.if_outerrors = item.value.asnValue.number;
  726. break;
  727. case ID_IF_OUTQLEN:
  728. pIf->Info.if_outqlen = item.value.asnValue.number;
  729. break;
  730. }
  731. }
  732. //*****************************************************************************
  733. //
  734. // Name: SaveData_IP
  735. //
  736. // Description: Saves an element of the data in the IP table.
  737. //
  738. // Parameters: GenericTable *pEntry; pointer to table entry.
  739. // RFC1157VarBind item: contains value returned from mib.
  740. // OIDdef *pOid: contains table-specific data.
  741. //
  742. // Returns: void.
  743. //
  744. // History:
  745. // 01/12/94 JayPh Created.
  746. //
  747. //*****************************************************************************
  748. void SaveData_IP( GenericTable *pEntry,
  749. RFC1157VarBind item,
  750. OIDdef *pOid )
  751. {
  752. IpEntry *pIp = (IpEntry *)pEntry;
  753. uchar *pTmp;
  754. switch ( item.name.ids[pOid->EntElemOffset] )
  755. {
  756. case ID_IP_FORWARDING:
  757. pIp->Info.ipsi_forwarding = item.value.asnValue.number;
  758. break;
  759. case ID_IP_DEFAULTTTL:
  760. pIp->Info.ipsi_defaultttl = item.value.asnValue.number;
  761. break;
  762. case ID_IP_INRECEIVES:
  763. pIp->Info.ipsi_inreceives = item.value.asnValue.number;
  764. break;
  765. case ID_IP_INHDRERRORS:
  766. pIp->Info.ipsi_inhdrerrors = item.value.asnValue.number;
  767. break;
  768. case ID_IP_INADDRERRORS:
  769. pIp->Info.ipsi_inaddrerrors = item.value.asnValue.number;
  770. break;
  771. case ID_IP_FORWDATAGRAMS:
  772. pIp->Info.ipsi_forwdatagrams = item.value.asnValue.number;
  773. break;
  774. case ID_IP_INUNKNOWNPROTOS:
  775. pIp->Info.ipsi_inunknownprotos = item.value.asnValue.number;
  776. break;
  777. case ID_IP_INDISCARDS:
  778. pIp->Info.ipsi_indiscards = item.value.asnValue.number;
  779. break;
  780. case ID_IP_INDELIVERS:
  781. pIp->Info.ipsi_indelivers = item.value.asnValue.number;
  782. break;
  783. case ID_IP_OUTREQUESTS:
  784. pIp->Info.ipsi_outrequests = item.value.asnValue.number;
  785. break;
  786. case ID_IP_OUTDISCARDS:
  787. pIp->Info.ipsi_outdiscards = item.value.asnValue.number;
  788. break;
  789. case ID_IP_OUTNOROUTES:
  790. pIp->Info.ipsi_outnoroutes = item.value.asnValue.number;
  791. break;
  792. case ID_IP_REASMTIMEOUTS:
  793. pIp->Info.ipsi_reasmtimeout = item.value.asnValue.number;
  794. break;
  795. case ID_IP_REASMREQDS:
  796. pIp->Info.ipsi_reasmreqds = item.value.asnValue.number;
  797. break;
  798. case ID_IP_REASMOKS:
  799. pIp->Info.ipsi_reasmoks = item.value.asnValue.number;
  800. break;
  801. case ID_IP_REASMFAILS:
  802. pIp->Info.ipsi_reasmfails = item.value.asnValue.number;
  803. break;
  804. case ID_IP_FRAGOKS:
  805. pIp->Info.ipsi_fragoks = item.value.asnValue.number;
  806. break;
  807. case ID_IP_FRAGFAILS:
  808. pIp->Info.ipsi_fragfails = item.value.asnValue.number;
  809. break;
  810. case ID_IP_FRAGCREATES:
  811. pIp->Info.ipsi_fragcreates = item.value.asnValue.number;
  812. break;
  813. }
  814. }
  815. //*****************************************************************************
  816. //
  817. // Name: SaveData_IPAddr
  818. //
  819. // Description: Saves an element of the data in the IP table.
  820. //
  821. // Parameters: GenericTable *pEntry; pointer to table entry.
  822. // RFC1157VarBind item: contains value returned from mib.
  823. // OIDdef *pOid: contains table-specific data.
  824. //
  825. // Returns: void.
  826. //
  827. // History:
  828. // 01/12/94 JayPh Created.
  829. //
  830. //*****************************************************************************
  831. void SaveData_IPAddr( GenericTable *pEntry,
  832. RFC1157VarBind item,
  833. OIDdef *pOid )
  834. {
  835. IpAddrEntry *pIpAddr = (IpAddrEntry *)pEntry;
  836. uchar *pTmp;
  837. switch ( item.name.ids[pOid->EntElemOffset] )
  838. {
  839. case ID_IPADDR_ADDR:
  840. pTmp = (uchar *)&(pIpAddr->Info.iae_addr);
  841. pTmp[0] = item.value.asnValue.string.stream[0];
  842. pTmp[1] = item.value.asnValue.string.stream[1];
  843. pTmp[2] = item.value.asnValue.string.stream[2];
  844. pTmp[3] = item.value.asnValue.string.stream[3];
  845. break;
  846. case ID_IPADDR_INDEX:
  847. pIpAddr->Info.iae_index = item.value.asnValue.number;
  848. break;
  849. case ID_IPADDR_MASK:
  850. pTmp = (uchar *)&(pIpAddr->Info.iae_mask);
  851. pTmp[0] = item.value.asnValue.string.stream[0];
  852. pTmp[1] = item.value.asnValue.string.stream[1];
  853. pTmp[2] = item.value.asnValue.string.stream[2];
  854. pTmp[3] = item.value.asnValue.string.stream[3];
  855. break;
  856. case ID_IPADDR_BCASTADDR:
  857. pIpAddr->Info.iae_bcastaddr = item.value.asnValue.number;
  858. break;
  859. case ID_IPADDR_REASMSIZE:
  860. pIpAddr->Info.iae_reasmsize = item.value.asnValue.number;
  861. break;
  862. }
  863. }
  864. //*****************************************************************************
  865. //
  866. // Name: SaveData_ROUTE
  867. //
  868. // Description: Saves an element of the data in the ROUTE table.
  869. //
  870. // Parameters: GenericTable *pEntry; pointer to table entry.
  871. // RFC1157VarBind item: contains value returned from mib.
  872. // OIDdef *pOid: contains table-specific data.
  873. //
  874. // Returns: void.
  875. //
  876. // History:
  877. // 01/12/94 JayPh Created.
  878. //
  879. //*****************************************************************************
  880. void SaveData_ROUTE( GenericTable *pEntry,
  881. RFC1157VarBind item,
  882. OIDdef *pOid )
  883. {
  884. RouteEntry *pRoute = (RouteEntry *)pEntry;
  885. uchar *pTmp;
  886. switch ( item.name.ids[pOid->EntElemOffset] )
  887. {
  888. case ID_ROUTE_DEST:
  889. pTmp = (uchar *)&(pRoute->Info.ire_dest);
  890. pTmp[0] = item.value.asnValue.string.stream[0];
  891. pTmp[1] = item.value.asnValue.string.stream[1];
  892. pTmp[2] = item.value.asnValue.string.stream[2];
  893. pTmp[3] = item.value.asnValue.string.stream[3];
  894. break;
  895. case ID_ROUTE_IFINDEX:
  896. pRoute->Info.ire_index = item.value.asnValue.number;
  897. break;
  898. case ID_ROUTE_METRIC1:
  899. pRoute->Info.ire_metric1 = item.value.asnValue.number;
  900. break;
  901. case ID_ROUTE_METRIC2:
  902. pRoute->Info.ire_metric2 = item.value.asnValue.number;
  903. break;
  904. case ID_ROUTE_METRIC3:
  905. pRoute->Info.ire_metric3 = item.value.asnValue.number;
  906. break;
  907. case ID_ROUTE_METRIC4:
  908. pRoute->Info.ire_metric4 = item.value.asnValue.number;
  909. break;
  910. case ID_ROUTE_NEXTHOP:
  911. pTmp = (uchar *)&(pRoute->Info.ire_nexthop);
  912. pTmp[0] = item.value.asnValue.string.stream[0];
  913. pTmp[1] = item.value.asnValue.string.stream[1];
  914. pTmp[2] = item.value.asnValue.string.stream[2];
  915. pTmp[3] = item.value.asnValue.string.stream[3];
  916. break;
  917. case ID_ROUTE_TYPE:
  918. pRoute->Info.ire_type = item.value.asnValue.number;
  919. break;
  920. case ID_ROUTE_PROTO:
  921. pRoute->Info.ire_proto = item.value.asnValue.number;
  922. break;
  923. case ID_ROUTE_AGE:
  924. pRoute->Info.ire_age = item.value.asnValue.number;
  925. break;
  926. case ID_ROUTE_MASK:
  927. pTmp = (uchar *)&(pRoute->Info.ire_mask);
  928. pTmp[0] = item.value.asnValue.string.stream[0];
  929. pTmp[1] = item.value.asnValue.string.stream[1];
  930. pTmp[2] = item.value.asnValue.string.stream[2];
  931. pTmp[3] = item.value.asnValue.string.stream[3];
  932. break;
  933. case ID_ROUTE_METRIC5:
  934. pRoute->Info.ire_metric5 = item.value.asnValue.number;
  935. break;
  936. }
  937. }
  938. //*****************************************************************************
  939. //
  940. // Name: SaveData_ARP
  941. //
  942. // Description: Saves an element of the data in the ARP table.
  943. //
  944. // Parameters: GenericTable *pEntry; pointer to table entry.
  945. // RFC1157VarBind item: contains value returned from mib.
  946. // OIDdef *pOid: contains table-specific data.
  947. //
  948. // Returns: void.
  949. //
  950. // History:
  951. // 01/12/94 JayPh Created.
  952. //
  953. //*****************************************************************************
  954. void SaveData_ARP( GenericTable *pEntry,
  955. RFC1157VarBind item,
  956. OIDdef *pOid )
  957. {
  958. ArpEntry *pArp = (ArpEntry *)pEntry;
  959. uchar *pTmp;
  960. ulong i;
  961. switch ( item.name.ids[pOid->EntElemOffset] )
  962. {
  963. case ID_ARP_IFINDEX:
  964. pArp->Info.inme_index = item.value.asnValue.number;
  965. break;
  966. case ID_ARP_PHYSADDR:
  967. pArp->Info.inme_physaddrlen = item.value.asnValue.string.length;
  968. for ( i = 0; i < pArp->Info.inme_physaddrlen; i++ )
  969. {
  970. pArp->Info.inme_physaddr[i] = item.value.asnValue.string.stream[i];
  971. }
  972. break;
  973. case ID_ARP_NETADDR:
  974. pTmp = (uchar *)&(pArp->Info.inme_addr);
  975. pTmp[0] = item.value.asnValue.string.stream[0];
  976. pTmp[1] = item.value.asnValue.string.stream[1];
  977. pTmp[2] = item.value.asnValue.string.stream[2];
  978. pTmp[3] = item.value.asnValue.string.stream[3];
  979. break;
  980. case ID_ARP_TYPE:
  981. pArp->Info.inme_type = item.value.asnValue.number;
  982. break;
  983. }
  984. }
  985. //*****************************************************************************
  986. //
  987. // Name: SaveData_ICMP
  988. //
  989. // Description: Saves an element of the data in the ICMP table.
  990. //
  991. // Parameters: GenericTable *pEntry; pointer to table entry.
  992. // RFC1157VarBind item: contains value returned from mib.
  993. // OIDdef *pOid: contains table-specific data.
  994. //
  995. // Returns: void.
  996. //
  997. // History:
  998. // 01/12/94 JayPh Created.
  999. //
  1000. //*****************************************************************************
  1001. void SaveData_ICMP( GenericTable *pEntry,
  1002. RFC1157VarBind item,
  1003. OIDdef *pOid )
  1004. {
  1005. IcmpEntry *pIcmp = (IcmpEntry *)pEntry;
  1006. uchar *pTmp;
  1007. switch ( item.name.ids[pOid->EntElemOffset] )
  1008. {
  1009. case ID_ICMP_INMSGS:
  1010. pIcmp->InInfo.icmps_msgs = item.value.asnValue.number;
  1011. break;
  1012. case ID_ICMP_INERRORS:
  1013. pIcmp->InInfo.icmps_errors = item.value.asnValue.number;
  1014. break;
  1015. case ID_ICMP_INDESTUNREACHES:
  1016. pIcmp->InInfo.icmps_destunreachs = item.value.asnValue.number;
  1017. break;
  1018. case ID_ICMP_INTIMEEXCDS:
  1019. pIcmp->InInfo.icmps_timeexcds = item.value.asnValue.number;
  1020. break;
  1021. case ID_ICMP_INPARMPROBS:
  1022. pIcmp->InInfo.icmps_parmprobs = item.value.asnValue.number;
  1023. break;
  1024. case ID_ICMP_INSRCQUENCHS:
  1025. pIcmp->InInfo.icmps_srcquenchs = item.value.asnValue.number;
  1026. break;
  1027. case ID_ICMP_INREDIRECTS:
  1028. pIcmp->InInfo.icmps_redirects = item.value.asnValue.number;
  1029. break;
  1030. case ID_ICMP_INECHOS:
  1031. pIcmp->InInfo.icmps_echos = item.value.asnValue.number;
  1032. break;
  1033. case ID_ICMP_INECHOREPS:
  1034. pIcmp->InInfo.icmps_echoreps = item.value.asnValue.number;
  1035. break;
  1036. case ID_ICMP_INTIMESTAMPS:
  1037. pIcmp->InInfo.icmps_timestamps = item.value.asnValue.number;
  1038. break;
  1039. case ID_ICMP_INTIMESTAMPREPS:
  1040. pIcmp->InInfo.icmps_timestampreps = item.value.asnValue.number;
  1041. break;
  1042. case ID_ICMP_INADDRMASKS:
  1043. pIcmp->InInfo.icmps_addrmasks = item.value.asnValue.number;
  1044. break;
  1045. case ID_ICMP_INADDRMASKREPS:
  1046. pIcmp->InInfo.icmps_addrmaskreps = item.value.asnValue.number;
  1047. break;
  1048. case ID_ICMP_OUTMSGS:
  1049. pIcmp->OutInfo.icmps_msgs = item.value.asnValue.number;
  1050. break;
  1051. case ID_ICMP_OUTERRORS:
  1052. pIcmp->OutInfo.icmps_errors = item.value.asnValue.number;
  1053. break;
  1054. case ID_ICMP_OUTDESTUNREACHES:
  1055. pIcmp->OutInfo.icmps_destunreachs = item.value.asnValue.number;
  1056. break;
  1057. case ID_ICMP_OUTTIMEEXCDS:
  1058. pIcmp->OutInfo.icmps_timeexcds = item.value.asnValue.number;
  1059. break;
  1060. case ID_ICMP_OUTPARMPROBS:
  1061. pIcmp->OutInfo.icmps_parmprobs = item.value.asnValue.number;
  1062. break;
  1063. case ID_ICMP_OUTSRCQUENCHS:
  1064. pIcmp->OutInfo.icmps_srcquenchs = item.value.asnValue.number;
  1065. break;
  1066. case ID_ICMP_OUTREDIRECTS:
  1067. pIcmp->OutInfo.icmps_redirects = item.value.asnValue.number;
  1068. break;
  1069. case ID_ICMP_OUTECHOS:
  1070. pIcmp->OutInfo.icmps_echos = item.value.asnValue.number;
  1071. break;
  1072. case ID_ICMP_OUTECHOREPS:
  1073. pIcmp->OutInfo.icmps_echoreps = item.value.asnValue.number;
  1074. break;
  1075. case ID_ICMP_OUTTIMESTAMPS:
  1076. pIcmp->OutInfo.icmps_timestamps = item.value.asnValue.number;
  1077. break;
  1078. case ID_ICMP_OUTTIMESTAMPREPS:
  1079. pIcmp->OutInfo.icmps_timestampreps = item.value.asnValue.number;
  1080. break;
  1081. case ID_ICMP_OUTADDRMASKS:
  1082. pIcmp->OutInfo.icmps_addrmasks = item.value.asnValue.number;
  1083. break;
  1084. case ID_ICMP_OUTADDRMASKREPS:
  1085. pIcmp->OutInfo.icmps_addrmaskreps = item.value.asnValue.number;
  1086. break;
  1087. }
  1088. }
  1089. //*****************************************************************************
  1090. //
  1091. // Name: SaveData_TCP
  1092. //
  1093. // Description: Saves an element of the data in the TCP table.
  1094. //
  1095. // Parameters: GenericTable *pEntry; pointer to table entry.
  1096. // RFC1157VarBind item: contains value returned from mib.
  1097. // OIDdef *pOid: contains table-specific data.
  1098. //
  1099. // Returns: void.
  1100. //
  1101. // History:
  1102. // 01/12/94 JayPh Created.
  1103. //
  1104. //*****************************************************************************
  1105. void SaveData_TCP( GenericTable *pEntry,
  1106. RFC1157VarBind item,
  1107. OIDdef *pOid )
  1108. {
  1109. TcpEntry *pTcp = (TcpEntry *)pEntry;
  1110. uchar *pTmp;
  1111. switch ( item.name.ids[pOid->EntElemOffset] )
  1112. {
  1113. case ID_TCP_RTOALGORITHM:
  1114. pTcp->Info.ts_rtoalgorithm = item.value.asnValue.number;
  1115. break;
  1116. case ID_TCP_RTOMIN:
  1117. pTcp->Info.ts_rtomin = item.value.asnValue.number;
  1118. break;
  1119. case ID_TCP_RTOMAX:
  1120. pTcp->Info.ts_rtomax = item.value.asnValue.number;
  1121. break;
  1122. case ID_TCP_MAXCONN:
  1123. pTcp->Info.ts_maxconn = item.value.asnValue.number;
  1124. break;
  1125. case ID_TCP_ACTIVEOPENS:
  1126. pTcp->Info.ts_activeopens = item.value.asnValue.number;
  1127. break;
  1128. case ID_TCP_PASSIVEOPENS:
  1129. pTcp->Info.ts_passiveopens = item.value.asnValue.number;
  1130. break;
  1131. case ID_TCP_ATTEMPTFAILS:
  1132. pTcp->Info.ts_attemptfails = item.value.asnValue.number;
  1133. break;
  1134. case ID_TCP_ESTABRESETS:
  1135. pTcp->Info.ts_estabresets = item.value.asnValue.number;
  1136. break;
  1137. case ID_TCP_CURRESTABS:
  1138. pTcp->Info.ts_currestab = item.value.asnValue.number;
  1139. break;
  1140. case ID_TCP_INSEGS:
  1141. pTcp->Info.ts_insegs = item.value.asnValue.number;
  1142. break;
  1143. case ID_TCP_OUTSEGS:
  1144. pTcp->Info.ts_outsegs = item.value.asnValue.number;
  1145. break;
  1146. case ID_TCP_RETRANSSEGS:
  1147. pTcp->Info.ts_retranssegs = item.value.asnValue.number;
  1148. break;
  1149. case ID_TCP_INERRS:
  1150. pTcp->Info.ts_inerrs = item.value.asnValue.number;
  1151. break;
  1152. case ID_TCP_OUTRSTS:
  1153. pTcp->Info.ts_outrsts = item.value.asnValue.number;
  1154. break;
  1155. }
  1156. }
  1157. //*****************************************************************************
  1158. //
  1159. // Name: SaveData_TCPCONN
  1160. //
  1161. // Description: Saves an element of the data in the TCP connection table.
  1162. //
  1163. // Parameters: GenericTable *pEntry; pointer to table entry.
  1164. // RFC1157VarBind item: contains value returned from mib.
  1165. // OIDdef *pOid: contains table-specific data.
  1166. //
  1167. // Returns: void.
  1168. //
  1169. // History:
  1170. // 01/12/94 JayPh Created.
  1171. //
  1172. //*****************************************************************************
  1173. void SaveData_TCPCONN( GenericTable *pEntry,
  1174. RFC1157VarBind item,
  1175. OIDdef *pOid )
  1176. {
  1177. TcpConnEntry *pTcp = (TcpConnEntry *)pEntry;
  1178. uchar *pTmp;
  1179. switch ( item.name.ids[pOid->EntElemOffset] )
  1180. {
  1181. case ID_TCPCONN_STATE:
  1182. pTcp->Info.tct_state = item.value.asnValue.number;
  1183. break;
  1184. case ID_TCPCONN_LOCALADDR:
  1185. pTmp = (uchar *)&(pTcp->Info.tct_localaddr);
  1186. pTmp[0] = item.value.asnValue.string.stream[0];
  1187. pTmp[1] = item.value.asnValue.string.stream[1];
  1188. pTmp[2] = item.value.asnValue.string.stream[2];
  1189. pTmp[3] = item.value.asnValue.string.stream[3];
  1190. break;
  1191. case ID_TCPCONN_LOCALPORT:
  1192. pTcp->Info.tct_localport = item.value.asnValue.number;
  1193. break;
  1194. case ID_TCPCONN_REMOTEADDR:
  1195. pTmp = (uchar *)&(pTcp->Info.tct_remoteaddr);
  1196. pTmp[0] = item.value.asnValue.string.stream[0];
  1197. pTmp[1] = item.value.asnValue.string.stream[1];
  1198. pTmp[2] = item.value.asnValue.string.stream[2];
  1199. pTmp[3] = item.value.asnValue.string.stream[3];
  1200. break;
  1201. case ID_TCPCONN_REMOTEPORT:
  1202. pTcp->Info.tct_remoteport = item.value.asnValue.number;
  1203. break;
  1204. }
  1205. }
  1206. //*****************************************************************************
  1207. //
  1208. // Name: SaveData_UDP
  1209. //
  1210. // Description: Saves an element of the data in the UDP table.
  1211. //
  1212. // Parameters: GenericTable *pEntry; pointer to table entry.
  1213. // RFC1157VarBind item: contains value returned from mib.
  1214. // OIDdef *pOid: contains table-specific data.
  1215. //
  1216. // Returns: void.
  1217. //
  1218. // History:
  1219. // 01/12/94 JayPh Created.
  1220. //
  1221. //*****************************************************************************
  1222. void SaveData_UDP( GenericTable *pEntry,
  1223. RFC1157VarBind item,
  1224. OIDdef *pOid )
  1225. {
  1226. UdpEntry *pUdp = (UdpEntry *)pEntry;
  1227. uchar *pTmp;
  1228. switch ( item.name.ids[pOid->EntElemOffset] )
  1229. {
  1230. case ID_UDP_INDATAGRAMS:
  1231. pUdp->Info.us_indatagrams = item.value.asnValue.number;
  1232. break;
  1233. case ID_UDP_NOPORTS:
  1234. pUdp->Info.us_noports = item.value.asnValue.number;
  1235. break;
  1236. case ID_UDP_INERRORS:
  1237. pUdp->Info.us_inerrors = item.value.asnValue.number;
  1238. break;
  1239. case ID_UDP_OUTDATAGRAMS:
  1240. pUdp->Info.us_outdatagrams = item.value.asnValue.number;
  1241. break;
  1242. }
  1243. }
  1244. //*****************************************************************************
  1245. //
  1246. // Name: SaveData_UDPCONN
  1247. //
  1248. // Description: Saves an element of the data in the UDP connection table.
  1249. //
  1250. // Parameters: GenericTable *pEntry; pointer to table entry.
  1251. // RFC1157VarBind item: contains value returned from mib.
  1252. // OIDdef *pOid: contains table-specific data.
  1253. //
  1254. // Returns: void.
  1255. //
  1256. // History:
  1257. // 01/12/94 JayPh Created.
  1258. //
  1259. //*****************************************************************************
  1260. void SaveData_UDPCONN( GenericTable *pEntry,
  1261. RFC1157VarBind item,
  1262. OIDdef *pOid )
  1263. {
  1264. UdpConnEntry *pUdp = (UdpConnEntry *)pEntry;
  1265. uchar *pTmp;
  1266. switch ( item.name.ids[pOid->EntElemOffset] )
  1267. {
  1268. case ID_UDPCONN_LOCALADDR:
  1269. pTmp = (uchar *)&(pUdp->Info.ue_localaddr);
  1270. pTmp[0] = item.value.asnValue.string.stream[0];
  1271. pTmp[1] = item.value.asnValue.string.stream[1];
  1272. pTmp[2] = item.value.asnValue.string.stream[2];
  1273. pTmp[3] = item.value.asnValue.string.stream[3];
  1274. break;
  1275. case ID_UDPCONN_LOCALPORT:
  1276. pUdp->Info.ue_localport = item.value.asnValue.number;
  1277. break;
  1278. }
  1279. }