2 * Copyright 2008 Juan Lang
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
28 #include "wine/debug.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(inetmib1);
35 static void copyInt(AsnAny *value, void *src)
37 value->asnType = ASN_INTEGER;
38 value->asnValue.number = *(DWORD *)src;
41 static void setStringValue(AsnAny *value, BYTE type, DWORD len, BYTE *str)
45 strValue.asnType = type;
46 strValue.asnValue.string.stream = str;
47 strValue.asnValue.string.length = len;
48 strValue.asnValue.string.dynamic = TRUE;
49 SnmpUtilAsnAnyCpy(value, &strValue);
52 static void copyLengthPrecededString(AsnAny *value, void *src)
54 DWORD len = *(DWORD *)src;
56 setStringValue(value, ASN_OCTETSTRING, len, (BYTE *)src + sizeof(DWORD));
59 typedef void (*copyValueFunc)(AsnAny *value, void *src);
61 struct structToAsnValue
67 static AsnInteger32 mapStructEntryToValue(struct structToAsnValue *map,
68 UINT mapLen, void *record, UINT id, BYTE bPduType, SnmpVarBind *pVarBind)
70 /* OIDs are 1-based */
72 return SNMP_ERRORSTATUS_NOSUCHNAME;
75 return SNMP_ERRORSTATUS_NOSUCHNAME;
77 return SNMP_ERRORSTATUS_NOSUCHNAME;
78 map[id].copy(&pVarBind->value, (BYTE *)record + map[id].offset);
79 return SNMP_ERRORSTATUS_NOERROR;
82 static void copyIpAddr(AsnAny *value, void *src)
84 setStringValue(value, ASN_IPADDRESS, sizeof(DWORD), src);
87 static UINT mib2[] = { 1,3,6,1,2,1 };
88 static UINT mib2System[] = { 1,3,6,1,2,1,1 };
90 typedef BOOL (*varqueryfunc)(BYTE bPduType, SnmpVarBind *pVarBind,
91 AsnInteger32 *pErrorStatus);
93 struct mibImplementation
95 AsnObjectIdentifier name;
98 void (*cleanup)(void);
101 static UINT mib2IfNumber[] = { 1,3,6,1,2,1,2,1 };
102 static PMIB_IFTABLE ifTable;
104 static void mib2IfNumberInit(void)
106 DWORD size = 0, ret = GetIfTable(NULL, &size, FALSE);
108 if (ret == ERROR_INSUFFICIENT_BUFFER)
110 MIB_IFTABLE *table = HeapAlloc(GetProcessHeap(), 0, size);
113 if (!GetIfTable(table, &size, FALSE)) ifTable = table;
114 else HeapFree(GetProcessHeap(), 0, table );
119 static void mib2IfNumberCleanup(void)
121 HeapFree(GetProcessHeap(), 0, ifTable);
124 static BOOL mib2IfNumberQuery(BYTE bPduType, SnmpVarBind *pVarBind,
125 AsnInteger32 *pErrorStatus)
127 AsnObjectIdentifier numberOid = DEFINE_OID(mib2IfNumber);
129 TRACE("(0x%02x, %s, %p)\n", bPduType, SnmpUtilOidToA(&pVarBind->name),
135 case SNMP_PDU_GETNEXT:
136 if ((bPduType == SNMP_PDU_GET &&
137 !SnmpUtilOidNCmp(&pVarBind->name, &numberOid, numberOid.idLength))
138 || SnmpUtilOidNCmp(&pVarBind->name, &numberOid, numberOid.idLength)
141 DWORD numIfs = ifTable ? ifTable->dwNumEntries : 0;
143 copyInt(&pVarBind->value, &numIfs);
144 if (bPduType == SNMP_PDU_GETNEXT)
145 SnmpUtilOidCpy(&pVarBind->name, &numberOid);
146 *pErrorStatus = SNMP_ERRORSTATUS_NOERROR;
150 *pErrorStatus = SNMP_ERRORSTATUS_NOSUCHNAME;
151 /* Caller deals with OID if bPduType == SNMP_PDU_GETNEXT, so don't
152 * need to set it here.
157 *pErrorStatus = SNMP_ERRORSTATUS_READONLY;
160 FIXME("0x%02x: unsupported PDU type\n", bPduType);
161 *pErrorStatus = SNMP_ERRORSTATUS_NOSUCHNAME;
166 static void copyOperStatus(AsnAny *value, void *src)
168 value->asnType = ASN_INTEGER;
169 /* The IPHlpApi definition of operational status differs from the MIB2 one,
170 * so map it to the MIB2 value.
172 switch (*(DWORD *)src)
174 case MIB_IF_OPER_STATUS_OPERATIONAL:
175 value->asnValue.number = MIB_IF_ADMIN_STATUS_UP;
177 case MIB_IF_OPER_STATUS_CONNECTING:
178 case MIB_IF_OPER_STATUS_CONNECTED:
179 value->asnValue.number = MIB_IF_ADMIN_STATUS_TESTING;
182 value->asnValue.number = MIB_IF_ADMIN_STATUS_DOWN;
186 /* Given an OID and a base OID that it must begin with, finds the item and
187 * integer instance from the OID. E.g., given an OID foo.1.2 and a base OID
188 * foo, returns item 1 and instance 2.
189 * If bPduType is not SNMP_PDU_GETNEXT and either the item or instance is
190 * missing, returns SNMP_ERRORSTATUS_NOSUCHNAME.
191 * If bPduType is SNMP_PDU_GETNEXT, returns the successor to the item and
192 * instance, or item 1, instance 1 if either is missing.
194 static AsnInteger32 getItemAndIntegerInstanceFromOid(AsnObjectIdentifier *oid,
195 AsnObjectIdentifier *base, BYTE bPduType, UINT *item, UINT *instance)
197 AsnInteger32 ret = SNMP_ERRORSTATUS_NOERROR;
201 case SNMP_PDU_GETNEXT:
202 if (SnmpUtilOidNCmp(oid, base, base->idLength) < 0)
207 else if (!SnmpUtilOidNCmp(oid, base, base->idLength))
209 if (oid->idLength == base->idLength ||
210 oid->idLength == base->idLength + 1)
212 /* Either the table or an item within the table is specified,
213 * but the instance is not. Get the first instance.
216 if (oid->idLength == base->idLength + 1)
217 *item = oid->ids[base->idLength];
223 *item = oid->ids[base->idLength];
224 *instance = oid->ids[base->idLength + 1] + 1;
228 ret = SNMP_ERRORSTATUS_NOSUCHNAME;
231 if (!SnmpUtilOidNCmp(oid, base, base->idLength))
233 if (oid->idLength == base->idLength ||
234 oid->idLength == base->idLength + 1)
236 /* Either the table or an item within the table is specified,
237 * but the instance is not.
239 ret = SNMP_ERRORSTATUS_NOSUCHNAME;
243 *item = oid->ids[base->idLength];
244 *instance = oid->ids[base->idLength + 1];
248 ret = SNMP_ERRORSTATUS_NOSUCHNAME;
253 /* Given an OID and a base OID that it must begin with, finds the item from the
254 * OID. E.g., given an OID foo.1 and a base OID foo, returns item 1.
255 * If bPduType is not SNMP_PDU_GETNEXT and the item is missing, returns
256 * SNMP_ERRORSTATUS_NOSUCHNAME.
257 * If bPduType is SNMP_PDU_GETNEXT, returns the successor to the item, or item
258 * 1 if the item is missing.
260 static AsnInteger32 getItemFromOid(AsnObjectIdentifier *oid,
261 AsnObjectIdentifier *base, BYTE bPduType, UINT *item)
263 AsnInteger32 ret = SNMP_ERRORSTATUS_NOERROR;
267 case SNMP_PDU_GETNEXT:
268 if (SnmpUtilOidNCmp(oid, base, base->idLength) < 0)
270 else if (!SnmpUtilOidNCmp(oid, base, base->idLength))
272 if (oid->idLength == base->idLength)
274 /* The item is missing, assume the first item */
278 *item = oid->ids[base->idLength] + 1;
281 ret = SNMP_ERRORSTATUS_NOSUCHNAME;
284 if (!SnmpUtilOidNCmp(oid, base, base->idLength))
286 if (oid->idLength == base->idLength)
288 /* The item is missing */
289 ret = SNMP_ERRORSTATUS_NOSUCHNAME;
293 *item = oid->ids[base->idLength];
295 ret = SNMP_ERRORSTATUS_NOSUCHNAME;
299 ret = SNMP_ERRORSTATUS_NOSUCHNAME;
310 static DWORD oidToIpAddr(AsnObjectIdentifier *oid)
312 assert(oid && oid->idLength >= 4);
313 /* Map the IDs to an IP address in little-endian order */
314 return (BYTE)oid->ids[3] << 24 | (BYTE)oid->ids[2] << 16 |
315 (BYTE)oid->ids[1] << 8 | (BYTE)oid->ids[0];
318 typedef void (*oidToKeyFunc)(AsnObjectIdentifier *oid, void *dst);
319 typedef int (*compareFunc)(const void *key, const void *value);
321 static UINT findValueInTable(AsnObjectIdentifier *oid,
322 struct GenericTable *table, size_t tableEntrySize, oidToKeyFunc makeKey,
326 void *key = HeapAlloc(GetProcessHeap(), 0, tableEntrySize);
333 value = bsearch(key, table->entries, table->numEntries, tableEntrySize,
336 index = ((BYTE *)value - (BYTE *)table->entries) / tableEntrySize
338 HeapFree(GetProcessHeap(), 0, key);
343 /* Given an OID and a base OID that it must begin with, finds the item and
344 * element of the table whose value matches the instance from the OID.
345 * The OID is converted to a key with the function makeKey, and compared
346 * against entries in the table with the function compare.
347 * If bPduType is not SNMP_PDU_GETNEXT and either the item or instance is
348 * missing, returns SNMP_ERRORSTATUS_NOSUCHNAME.
349 * If bPduType is SNMP_PDU_GETNEXT, returns the successor to the item and
350 * instance, or item 1, instance 1 if either is missing.
352 static AsnInteger32 getItemAndInstanceFromTable(AsnObjectIdentifier *oid,
353 AsnObjectIdentifier *base, UINT instanceLen, BYTE bPduType,
354 struct GenericTable *table, size_t tableEntrySize, oidToKeyFunc makeKey,
355 compareFunc compare, UINT *item, UINT *instance)
357 AsnInteger32 ret = SNMP_ERRORSTATUS_NOERROR;
360 return SNMP_ERRORSTATUS_NOSUCHNAME;
364 case SNMP_PDU_GETNEXT:
365 if (SnmpUtilOidNCmp(oid, base, base->idLength) < 0)
367 /* Return the first item and instance from the table */
371 else if (!SnmpUtilOidNCmp(oid, base, base->idLength) &&
372 oid->idLength < base->idLength + instanceLen + 1)
374 /* Either the table or an item is specified, but the instance is
378 if (oid->idLength >= base->idLength + 1)
380 *item = oid->ids[base->idLength];
387 else if (!SnmpUtilOidNCmp(oid, base, base->idLength) &&
388 oid->idLength == base->idLength + instanceLen + 1)
390 *item = oid->ids[base->idLength];
398 AsnObjectIdentifier ipOid = { instanceLen,
399 oid->ids + base->idLength + 1 };
401 *instance = findValueInTable(&ipOid, table, tableEntrySize,
402 makeKey, compare) + 1;
403 if (*instance > table->numEntries)
404 ret = SNMP_ERRORSTATUS_NOSUCHNAME;
408 ret = SNMP_ERRORSTATUS_NOSUCHNAME;
411 if (!SnmpUtilOidNCmp(oid, base, base->idLength) &&
412 oid->idLength == base->idLength + instanceLen + 1)
414 *item = oid->ids[base->idLength];
416 ret = SNMP_ERRORSTATUS_NOSUCHNAME;
419 AsnObjectIdentifier ipOid = { instanceLen,
420 oid->ids + base->idLength + 1 };
422 *instance = findValueInTable(&ipOid, table, tableEntrySize,
425 ret = SNMP_ERRORSTATUS_NOSUCHNAME;
429 ret = SNMP_ERRORSTATUS_NOSUCHNAME;
434 static void setOidWithItem(AsnObjectIdentifier *dst, AsnObjectIdentifier *base,
438 AsnObjectIdentifier oid;
440 SnmpUtilOidCpy(dst, base);
444 SnmpUtilOidAppend(dst, &oid);
447 static void setOidWithItemAndIpAddr(AsnObjectIdentifier *dst,
448 AsnObjectIdentifier *base, UINT item, DWORD addr)
452 AsnObjectIdentifier oid;
454 setOidWithItem(dst, base, item);
457 for (ptr = (BYTE *)&addr; ptr < (BYTE *)&addr + sizeof(DWORD); ptr++)
460 SnmpUtilOidAppend(dst, &oid);
464 static void setOidWithItemAndInteger(AsnObjectIdentifier *dst,
465 AsnObjectIdentifier *base, UINT item, UINT instance)
467 AsnObjectIdentifier oid;
469 setOidWithItem(dst, base, item);
472 SnmpUtilOidAppend(dst, &oid);
475 static struct structToAsnValue mib2IfEntryMap[] = {
476 { FIELD_OFFSET(MIB_IFROW, dwIndex), copyInt },
477 { FIELD_OFFSET(MIB_IFROW, dwDescrLen), copyLengthPrecededString },
478 { FIELD_OFFSET(MIB_IFROW, dwType), copyInt },
479 { FIELD_OFFSET(MIB_IFROW, dwMtu), copyInt },
480 { FIELD_OFFSET(MIB_IFROW, dwSpeed), copyInt },
481 { FIELD_OFFSET(MIB_IFROW, dwPhysAddrLen), copyLengthPrecededString },
482 { FIELD_OFFSET(MIB_IFROW, dwAdminStatus), copyInt },
483 { FIELD_OFFSET(MIB_IFROW, dwOperStatus), copyOperStatus },
484 { FIELD_OFFSET(MIB_IFROW, dwLastChange), copyInt },
485 { FIELD_OFFSET(MIB_IFROW, dwInOctets), copyInt },
486 { FIELD_OFFSET(MIB_IFROW, dwInUcastPkts), copyInt },
487 { FIELD_OFFSET(MIB_IFROW, dwInNUcastPkts), copyInt },
488 { FIELD_OFFSET(MIB_IFROW, dwInDiscards), copyInt },
489 { FIELD_OFFSET(MIB_IFROW, dwInErrors), copyInt },
490 { FIELD_OFFSET(MIB_IFROW, dwInUnknownProtos), copyInt },
491 { FIELD_OFFSET(MIB_IFROW, dwOutOctets), copyInt },
492 { FIELD_OFFSET(MIB_IFROW, dwOutUcastPkts), copyInt },
493 { FIELD_OFFSET(MIB_IFROW, dwOutNUcastPkts), copyInt },
494 { FIELD_OFFSET(MIB_IFROW, dwOutDiscards), copyInt },
495 { FIELD_OFFSET(MIB_IFROW, dwOutErrors), copyInt },
496 { FIELD_OFFSET(MIB_IFROW, dwOutQLen), copyInt },
499 static UINT mib2IfEntry[] = { 1,3,6,1,2,1,2,2,1 };
501 static BOOL mib2IfEntryQuery(BYTE bPduType, SnmpVarBind *pVarBind,
502 AsnInteger32 *pErrorStatus)
504 AsnObjectIdentifier entryOid = DEFINE_OID(mib2IfEntry);
506 TRACE("(0x%02x, %s, %p)\n", bPduType, SnmpUtilOidToA(&pVarBind->name),
512 case SNMP_PDU_GETNEXT:
515 /* There is no interface present, so let the caller deal
516 * with finding the successor.
518 *pErrorStatus = SNMP_ERRORSTATUS_NOSUCHNAME;
522 UINT tableIndex = 0, item = 0;
524 *pErrorStatus = getItemAndIntegerInstanceFromOid(&pVarBind->name,
525 &entryOid, bPduType, &item, &tableIndex);
530 if (tableIndex > ifTable->dwNumEntries)
531 *pErrorStatus = SNMP_ERRORSTATUS_NOSUCHNAME;
534 *pErrorStatus = mapStructEntryToValue(mib2IfEntryMap,
535 DEFINE_SIZEOF(mib2IfEntryMap),
536 &ifTable->table[tableIndex - 1], item, bPduType,
538 if (bPduType == SNMP_PDU_GETNEXT)
539 setOidWithItemAndInteger(&pVarBind->name, &entryOid,
546 *pErrorStatus = SNMP_ERRORSTATUS_READONLY;
549 FIXME("0x%02x: unsupported PDU type\n", bPduType);
550 *pErrorStatus = SNMP_ERRORSTATUS_NOSUCHNAME;
555 static UINT mib2Ip[] = { 1,3,6,1,2,1,4 };
556 static MIB_IPSTATS ipStats;
558 static void mib2IpStatsInit(void)
560 GetIpStatistics(&ipStats);
563 static struct structToAsnValue mib2IpMap[] = {
564 { FIELD_OFFSET(MIB_IPSTATS, dwForwarding), copyInt }, /* 1 */
565 { FIELD_OFFSET(MIB_IPSTATS, dwDefaultTTL), copyInt }, /* 2 */
566 { FIELD_OFFSET(MIB_IPSTATS, dwInReceives), copyInt }, /* 3 */
567 { FIELD_OFFSET(MIB_IPSTATS, dwInHdrErrors), copyInt }, /* 4 */
568 { FIELD_OFFSET(MIB_IPSTATS, dwInAddrErrors), copyInt }, /* 5 */
569 { FIELD_OFFSET(MIB_IPSTATS, dwForwDatagrams), copyInt }, /* 6 */
570 { FIELD_OFFSET(MIB_IPSTATS, dwInUnknownProtos), copyInt }, /* 7 */
571 { FIELD_OFFSET(MIB_IPSTATS, dwInDiscards), copyInt }, /* 8 */
572 { FIELD_OFFSET(MIB_IPSTATS, dwInDelivers), copyInt }, /* 9 */
573 { FIELD_OFFSET(MIB_IPSTATS, dwOutRequests), copyInt }, /* 10 */
574 { FIELD_OFFSET(MIB_IPSTATS, dwOutDiscards), copyInt }, /* 11 */
575 { FIELD_OFFSET(MIB_IPSTATS, dwOutNoRoutes), copyInt }, /* 12 */
576 { FIELD_OFFSET(MIB_IPSTATS, dwReasmTimeout), copyInt }, /* 13 */
577 { FIELD_OFFSET(MIB_IPSTATS, dwReasmReqds), copyInt }, /* 14 */
578 { FIELD_OFFSET(MIB_IPSTATS, dwReasmOks), copyInt }, /* 15 */
579 { FIELD_OFFSET(MIB_IPSTATS, dwReasmFails), copyInt }, /* 16 */
580 { FIELD_OFFSET(MIB_IPSTATS, dwFragOks), copyInt }, /* 17 */
581 { FIELD_OFFSET(MIB_IPSTATS, dwFragFails), copyInt }, /* 18 */
582 { FIELD_OFFSET(MIB_IPSTATS, dwFragCreates), copyInt }, /* 19 */
583 { 0, NULL }, /* 20: not used, IP addr table */
584 { 0, NULL }, /* 21: not used, route table */
585 { 0, NULL }, /* 22: not used, net to media (ARP) table */
586 { FIELD_OFFSET(MIB_IPSTATS, dwRoutingDiscards), copyInt }, /* 23 */
589 static BOOL mib2IpStatsQuery(BYTE bPduType, SnmpVarBind *pVarBind,
590 AsnInteger32 *pErrorStatus)
592 AsnObjectIdentifier myOid = DEFINE_OID(mib2Ip);
595 TRACE("(0x%02x, %s, %p)\n", bPduType, SnmpUtilOidToA(&pVarBind->name),
601 case SNMP_PDU_GETNEXT:
602 *pErrorStatus = getItemFromOid(&pVarBind->name, &myOid, bPduType,
606 *pErrorStatus = mapStructEntryToValue(mib2IpMap,
607 DEFINE_SIZEOF(mib2IpMap), &ipStats, item, bPduType, pVarBind);
608 if (!*pErrorStatus && bPduType == SNMP_PDU_GETNEXT)
609 setOidWithItem(&pVarBind->name, &myOid, item);
613 *pErrorStatus = SNMP_ERRORSTATUS_READONLY;
616 FIXME("0x%02x: unsupported PDU type\n", bPduType);
617 *pErrorStatus = SNMP_ERRORSTATUS_NOSUCHNAME;
622 static UINT mib2IpAddr[] = { 1,3,6,1,2,1,4,20,1 };
623 static PMIB_IPADDRTABLE ipAddrTable;
625 static struct structToAsnValue mib2IpAddrMap[] = {
626 { FIELD_OFFSET(MIB_IPADDRROW, dwAddr), copyIpAddr },
627 { FIELD_OFFSET(MIB_IPADDRROW, dwIndex), copyInt },
628 { FIELD_OFFSET(MIB_IPADDRROW, dwMask), copyIpAddr },
629 { FIELD_OFFSET(MIB_IPADDRROW, dwBCastAddr), copyInt },
630 { FIELD_OFFSET(MIB_IPADDRROW, dwReasmSize), copyInt },
633 static void mib2IpAddrInit(void)
635 DWORD size = 0, ret = GetIpAddrTable(NULL, &size, TRUE);
637 if (ret == ERROR_INSUFFICIENT_BUFFER)
639 MIB_IPADDRTABLE *table = HeapAlloc(GetProcessHeap(), 0, size);
642 if (!GetIpAddrTable(table, &size, TRUE)) ipAddrTable = table;
643 else HeapFree(GetProcessHeap(), 0, table );
648 static void mib2IpAddrCleanup(void)
650 HeapFree(GetProcessHeap(), 0, ipAddrTable);
653 static void oidToIpAddrRow(AsnObjectIdentifier *oid, void *dst)
655 MIB_IPADDRROW *row = dst;
657 row->dwAddr = oidToIpAddr(oid);
660 static int compareIpAddrRow(const void *a, const void *b)
662 const MIB_IPADDRROW *key = a, *value = b;
664 return key->dwAddr - value->dwAddr;
667 static BOOL mib2IpAddrQuery(BYTE bPduType, SnmpVarBind *pVarBind,
668 AsnInteger32 *pErrorStatus)
670 AsnObjectIdentifier myOid = DEFINE_OID(mib2IpAddr);
671 UINT tableIndex = 0, item = 0;
673 TRACE("(0x%02x, %s, %p)\n", bPduType, SnmpUtilOidToA(&pVarBind->name),
679 case SNMP_PDU_GETNEXT:
680 *pErrorStatus = getItemAndInstanceFromTable(&pVarBind->name,
681 &myOid, 4, bPduType, (struct GenericTable *)ipAddrTable,
682 sizeof(MIB_IPADDRROW), oidToIpAddrRow, compareIpAddrRow, &item,
688 *pErrorStatus = mapStructEntryToValue(mib2IpAddrMap,
689 DEFINE_SIZEOF(mib2IpAddrMap),
690 &ipAddrTable->table[tableIndex - 1], item, bPduType, pVarBind);
691 if (!*pErrorStatus && bPduType == SNMP_PDU_GETNEXT)
692 setOidWithItemAndIpAddr(&pVarBind->name, &myOid, item,
693 ipAddrTable->table[tableIndex - 1].dwAddr);
697 *pErrorStatus = SNMP_ERRORSTATUS_READONLY;
700 FIXME("0x%02x: unsupported PDU type\n", bPduType);
701 *pErrorStatus = SNMP_ERRORSTATUS_NOSUCHNAME;
706 static UINT mib2IpRoute[] = { 1,3,6,1,2,1,4,21,1 };
707 static PMIB_IPFORWARDTABLE ipRouteTable;
709 static struct structToAsnValue mib2IpRouteMap[] = {
710 { FIELD_OFFSET(MIB_IPFORWARDROW, dwForwardDest), copyIpAddr },
711 { FIELD_OFFSET(MIB_IPFORWARDROW, dwForwardIfIndex), copyInt },
712 { FIELD_OFFSET(MIB_IPFORWARDROW, dwForwardMetric1), copyInt },
713 { FIELD_OFFSET(MIB_IPFORWARDROW, dwForwardMetric2), copyInt },
714 { FIELD_OFFSET(MIB_IPFORWARDROW, dwForwardMetric3), copyInt },
715 { FIELD_OFFSET(MIB_IPFORWARDROW, dwForwardMetric4), copyInt },
716 { FIELD_OFFSET(MIB_IPFORWARDROW, dwForwardNextHop), copyIpAddr },
717 { FIELD_OFFSET(MIB_IPFORWARDROW, dwForwardType), copyInt },
718 { FIELD_OFFSET(MIB_IPFORWARDROW, dwForwardProto), copyInt },
719 { FIELD_OFFSET(MIB_IPFORWARDROW, dwForwardAge), copyInt },
720 { FIELD_OFFSET(MIB_IPFORWARDROW, dwForwardMask), copyIpAddr },
721 { FIELD_OFFSET(MIB_IPFORWARDROW, dwForwardMetric5), copyInt },
724 static void mib2IpRouteInit(void)
726 DWORD size = 0, ret = GetIpForwardTable(NULL, &size, TRUE);
728 if (ret == ERROR_INSUFFICIENT_BUFFER)
730 MIB_IPFORWARDTABLE *table = HeapAlloc(GetProcessHeap(), 0, size);
733 if (!GetIpForwardTable(ipRouteTable, &size, TRUE)) ipRouteTable = table;
734 else HeapFree(GetProcessHeap(), 0, table );
739 static void mib2IpRouteCleanup(void)
741 HeapFree(GetProcessHeap(), 0, ipRouteTable);
744 static void oidToIpForwardRow(AsnObjectIdentifier *oid, void *dst)
746 MIB_IPFORWARDROW *row = dst;
748 row->dwForwardDest = oidToIpAddr(oid);
751 static int compareIpForwardRow(const void *a, const void *b)
753 const MIB_IPFORWARDROW *key = a, *value = b;
755 return key->dwForwardDest - value->dwForwardDest;
758 static BOOL mib2IpRouteQuery(BYTE bPduType, SnmpVarBind *pVarBind,
759 AsnInteger32 *pErrorStatus)
761 AsnObjectIdentifier myOid = DEFINE_OID(mib2IpRoute);
762 UINT tableIndex = 0, item = 0;
764 TRACE("(0x%02x, %s, %p)\n", bPduType, SnmpUtilOidToA(&pVarBind->name),
770 case SNMP_PDU_GETNEXT:
771 *pErrorStatus = getItemAndInstanceFromTable(&pVarBind->name,
772 &myOid, 4, bPduType, (struct GenericTable *)ipRouteTable,
773 sizeof(MIB_IPFORWARDROW), oidToIpForwardRow, compareIpForwardRow,
779 *pErrorStatus = mapStructEntryToValue(mib2IpRouteMap,
780 DEFINE_SIZEOF(mib2IpRouteMap),
781 &ipRouteTable->table[tableIndex - 1], item, bPduType, pVarBind);
782 if (!*pErrorStatus && bPduType == SNMP_PDU_GETNEXT)
783 setOidWithItemAndIpAddr(&pVarBind->name, &myOid, item,
784 ipRouteTable->table[tableIndex - 1].dwForwardDest);
788 *pErrorStatus = SNMP_ERRORSTATUS_READONLY;
791 FIXME("0x%02x: unsupported PDU type\n", bPduType);
792 *pErrorStatus = SNMP_ERRORSTATUS_NOSUCHNAME;
797 static UINT mib2IpNet[] = { 1,3,6,1,2,1,4,22,1 };
798 static PMIB_IPNETTABLE ipNetTable;
800 static struct structToAsnValue mib2IpNetMap[] = {
801 { FIELD_OFFSET(MIB_IPNETROW, dwIndex), copyInt },
802 { FIELD_OFFSET(MIB_IPNETROW, dwPhysAddrLen), copyLengthPrecededString },
803 { FIELD_OFFSET(MIB_IPNETROW, dwAddr), copyIpAddr },
804 { FIELD_OFFSET(MIB_IPNETROW, dwType), copyInt },
807 static void mib2IpNetInit(void)
809 DWORD size = 0, ret = GetIpNetTable(NULL, &size, FALSE);
811 if (ret == ERROR_INSUFFICIENT_BUFFER)
813 MIB_IPNETTABLE *table = HeapAlloc(GetProcessHeap(), 0, size);
816 if (!GetIpNetTable(ipNetTable, &size, FALSE)) ipNetTable = table;
817 else HeapFree(GetProcessHeap(), 0, table );
822 static void mib2IpNetCleanup(void)
824 HeapFree(GetProcessHeap(), 0, ipNetTable);
827 static BOOL mib2IpNetQuery(BYTE bPduType, SnmpVarBind *pVarBind,
828 AsnInteger32 *pErrorStatus)
830 AsnObjectIdentifier myOid = DEFINE_OID(mib2IpNet);
832 TRACE("(0x%02x, %s, %p)\n", bPduType, SnmpUtilOidToA(&pVarBind->name),
838 case SNMP_PDU_GETNEXT:
840 *pErrorStatus = SNMP_ERRORSTATUS_NOSUCHNAME;
843 UINT tableIndex = 0, item = 0;
845 *pErrorStatus = getItemAndIntegerInstanceFromOid(&pVarBind->name,
846 &myOid, bPduType, &item, &tableIndex);
851 if (tableIndex > ipNetTable->dwNumEntries)
852 *pErrorStatus = SNMP_ERRORSTATUS_NOSUCHNAME;
855 *pErrorStatus = mapStructEntryToValue(mib2IpNetMap,
856 DEFINE_SIZEOF(mib2IpNetMap),
857 &ipNetTable[tableIndex - 1], item, bPduType, pVarBind);
858 if (!*pErrorStatus && bPduType == SNMP_PDU_GETNEXT)
859 setOidWithItemAndInteger(&pVarBind->name, &myOid, item,
866 *pErrorStatus = SNMP_ERRORSTATUS_READONLY;
869 FIXME("0x%02x: unsupported PDU type\n", bPduType);
870 *pErrorStatus = SNMP_ERRORSTATUS_NOSUCHNAME;
875 static UINT mib2Icmp[] = { 1,3,6,1,2,1,5 };
876 static MIB_ICMP icmpStats;
878 static void mib2IcmpInit(void)
880 GetIcmpStatistics(&icmpStats);
883 static struct structToAsnValue mib2IcmpMap[] = {
884 { FIELD_OFFSET(MIBICMPINFO, icmpInStats.dwMsgs), copyInt },
885 { FIELD_OFFSET(MIBICMPINFO, icmpInStats.dwErrors), copyInt },
886 { FIELD_OFFSET(MIBICMPINFO, icmpInStats.dwDestUnreachs), copyInt },
887 { FIELD_OFFSET(MIBICMPINFO, icmpInStats.dwTimeExcds), copyInt },
888 { FIELD_OFFSET(MIBICMPINFO, icmpInStats.dwParmProbs), copyInt },
889 { FIELD_OFFSET(MIBICMPINFO, icmpInStats.dwSrcQuenchs), copyInt },
890 { FIELD_OFFSET(MIBICMPINFO, icmpInStats.dwRedirects), copyInt },
891 { FIELD_OFFSET(MIBICMPINFO, icmpInStats.dwEchos), copyInt },
892 { FIELD_OFFSET(MIBICMPINFO, icmpInStats.dwEchoReps), copyInt },
893 { FIELD_OFFSET(MIBICMPINFO, icmpInStats.dwTimestamps), copyInt },
894 { FIELD_OFFSET(MIBICMPINFO, icmpInStats.dwTimestampReps), copyInt },
895 { FIELD_OFFSET(MIBICMPINFO, icmpInStats.dwAddrMasks), copyInt },
896 { FIELD_OFFSET(MIBICMPINFO, icmpInStats.dwAddrMaskReps), copyInt },
897 { FIELD_OFFSET(MIBICMPINFO, icmpOutStats.dwMsgs), copyInt },
898 { FIELD_OFFSET(MIBICMPINFO, icmpOutStats.dwErrors), copyInt },
899 { FIELD_OFFSET(MIBICMPINFO, icmpOutStats.dwDestUnreachs), copyInt },
900 { FIELD_OFFSET(MIBICMPINFO, icmpOutStats.dwTimeExcds), copyInt },
901 { FIELD_OFFSET(MIBICMPINFO, icmpOutStats.dwParmProbs), copyInt },
902 { FIELD_OFFSET(MIBICMPINFO, icmpOutStats.dwSrcQuenchs), copyInt },
903 { FIELD_OFFSET(MIBICMPINFO, icmpOutStats.dwRedirects), copyInt },
904 { FIELD_OFFSET(MIBICMPINFO, icmpOutStats.dwEchos), copyInt },
905 { FIELD_OFFSET(MIBICMPINFO, icmpOutStats.dwEchoReps), copyInt },
906 { FIELD_OFFSET(MIBICMPINFO, icmpOutStats.dwTimestamps), copyInt },
907 { FIELD_OFFSET(MIBICMPINFO, icmpOutStats.dwTimestampReps), copyInt },
908 { FIELD_OFFSET(MIBICMPINFO, icmpOutStats.dwAddrMasks), copyInt },
909 { FIELD_OFFSET(MIBICMPINFO, icmpOutStats.dwAddrMaskReps), copyInt },
912 static BOOL mib2IcmpQuery(BYTE bPduType, SnmpVarBind *pVarBind,
913 AsnInteger32 *pErrorStatus)
915 AsnObjectIdentifier myOid = DEFINE_OID(mib2Icmp);
918 TRACE("(0x%02x, %s, %p)\n", bPduType, SnmpUtilOidToA(&pVarBind->name),
924 case SNMP_PDU_GETNEXT:
925 *pErrorStatus = getItemFromOid(&pVarBind->name, &myOid, bPduType,
929 *pErrorStatus = mapStructEntryToValue(mib2IcmpMap,
930 DEFINE_SIZEOF(mib2IcmpMap), &icmpStats, item, bPduType,
932 if (!*pErrorStatus && bPduType == SNMP_PDU_GETNEXT)
933 setOidWithItem(&pVarBind->name, &myOid, item);
937 *pErrorStatus = SNMP_ERRORSTATUS_READONLY;
940 FIXME("0x%02x: unsupported PDU type\n", bPduType);
941 *pErrorStatus = SNMP_ERRORSTATUS_NOSUCHNAME;
946 static UINT mib2Tcp[] = { 1,3,6,1,2,1,6 };
947 static MIB_TCPSTATS tcpStats;
949 static void mib2TcpInit(void)
951 GetTcpStatistics(&tcpStats);
954 static struct structToAsnValue mib2TcpMap[] = {
955 { FIELD_OFFSET(MIB_TCPSTATS, dwRtoAlgorithm), copyInt },
956 { FIELD_OFFSET(MIB_TCPSTATS, dwRtoMin), copyInt },
957 { FIELD_OFFSET(MIB_TCPSTATS, dwRtoMax), copyInt },
958 { FIELD_OFFSET(MIB_TCPSTATS, dwMaxConn), copyInt },
959 { FIELD_OFFSET(MIB_TCPSTATS, dwActiveOpens), copyInt },
960 { FIELD_OFFSET(MIB_TCPSTATS, dwPassiveOpens), copyInt },
961 { FIELD_OFFSET(MIB_TCPSTATS, dwAttemptFails), copyInt },
962 { FIELD_OFFSET(MIB_TCPSTATS, dwEstabResets), copyInt },
963 { FIELD_OFFSET(MIB_TCPSTATS, dwCurrEstab), copyInt },
964 { FIELD_OFFSET(MIB_TCPSTATS, dwInSegs), copyInt },
965 { FIELD_OFFSET(MIB_TCPSTATS, dwOutSegs), copyInt },
966 { FIELD_OFFSET(MIB_TCPSTATS, dwRetransSegs), copyInt },
967 { FIELD_OFFSET(MIB_TCPSTATS, dwInErrs), copyInt },
968 { FIELD_OFFSET(MIB_TCPSTATS, dwOutRsts), copyInt },
969 { FIELD_OFFSET(MIB_TCPSTATS, dwNumConns), copyInt },
972 static BOOL mib2TcpQuery(BYTE bPduType, SnmpVarBind *pVarBind,
973 AsnInteger32 *pErrorStatus)
975 AsnObjectIdentifier myOid = DEFINE_OID(mib2Tcp);
978 TRACE("(0x%02x, %s, %p)\n", bPduType, SnmpUtilOidToA(&pVarBind->name),
984 case SNMP_PDU_GETNEXT:
985 *pErrorStatus = getItemFromOid(&pVarBind->name, &myOid, bPduType,
989 *pErrorStatus = mapStructEntryToValue(mib2TcpMap,
990 DEFINE_SIZEOF(mib2TcpMap), &tcpStats, item, bPduType, pVarBind);
991 if (!*pErrorStatus && bPduType == SNMP_PDU_GETNEXT)
992 setOidWithItem(&pVarBind->name, &myOid, item);
996 *pErrorStatus = SNMP_ERRORSTATUS_READONLY;
999 FIXME("0x%02x: unsupported PDU type\n", bPduType);
1000 *pErrorStatus = SNMP_ERRORSTATUS_NOSUCHNAME;
1005 static UINT mib2Udp[] = { 1,3,6,1,2,1,7 };
1006 static MIB_UDPSTATS udpStats;
1008 static void mib2UdpInit(void)
1010 GetUdpStatistics(&udpStats);
1013 static struct structToAsnValue mib2UdpMap[] = {
1014 { FIELD_OFFSET(MIB_UDPSTATS, dwInDatagrams), copyInt },
1015 { FIELD_OFFSET(MIB_UDPSTATS, dwNoPorts), copyInt },
1016 { FIELD_OFFSET(MIB_UDPSTATS, dwInErrors), copyInt },
1017 { FIELD_OFFSET(MIB_UDPSTATS, dwOutDatagrams), copyInt },
1020 static BOOL mib2UdpQuery(BYTE bPduType, SnmpVarBind *pVarBind,
1021 AsnInteger32 *pErrorStatus)
1023 AsnObjectIdentifier myOid = DEFINE_OID(mib2Udp);
1026 TRACE("(0x%02x, %s, %p)\n", bPduType, SnmpUtilOidToA(&pVarBind->name),
1032 case SNMP_PDU_GETNEXT:
1033 *pErrorStatus = getItemFromOid(&pVarBind->name, &myOid, bPduType,
1037 *pErrorStatus = mapStructEntryToValue(mib2UdpMap,
1038 DEFINE_SIZEOF(mib2UdpMap), &udpStats, item, bPduType, pVarBind);
1039 if (!*pErrorStatus && bPduType == SNMP_PDU_GETNEXT)
1040 setOidWithItem(&pVarBind->name, &myOid, item);
1044 *pErrorStatus = SNMP_ERRORSTATUS_READONLY;
1047 FIXME("0x%02x: unsupported PDU type\n", bPduType);
1048 *pErrorStatus = SNMP_ERRORSTATUS_NOSUCHNAME;
1053 static UINT mib2UdpEntry[] = { 1,3,6,1,2,1,7,5,1 };
1054 static PMIB_UDPTABLE udpTable;
1056 static void mib2UdpEntryInit(void)
1058 DWORD size = 0, ret = GetUdpTable(NULL, &size, TRUE);
1060 if (ret == ERROR_INSUFFICIENT_BUFFER)
1062 MIB_UDPTABLE *table = HeapAlloc(GetProcessHeap(), 0, size);
1065 if (!GetUdpTable(table, &size, TRUE)) udpTable = table;
1066 else HeapFree(GetProcessHeap(), 0, table);
1071 static void mib2UdpEntryCleanup(void)
1073 HeapFree(GetProcessHeap(), 0, udpTable);
1076 static struct structToAsnValue mib2UdpEntryMap[] = {
1077 { FIELD_OFFSET(MIB_UDPROW, dwLocalAddr), copyIpAddr },
1078 { FIELD_OFFSET(MIB_UDPROW, dwLocalPort), copyInt },
1081 static void oidToUdpRow(AsnObjectIdentifier *oid, void *dst)
1083 MIB_UDPROW *row = dst;
1085 assert(oid && oid->idLength >= 5);
1086 row->dwLocalAddr = oidToIpAddr(oid);
1087 row->dwLocalPort = oid->ids[4];
1090 static int compareUdpRow(const void *a, const void *b)
1092 const MIB_UDPROW *key = a, *value = b;
1095 ret = key->dwLocalAddr - value->dwLocalAddr;
1097 ret = key->dwLocalPort - value->dwLocalPort;
1101 static BOOL mib2UdpEntryQuery(BYTE bPduType, SnmpVarBind *pVarBind,
1102 AsnInteger32 *pErrorStatus)
1104 AsnObjectIdentifier myOid = DEFINE_OID(mib2UdpEntry);
1106 TRACE("(0x%02x, %s, %p)\n", bPduType, SnmpUtilOidToA(&pVarBind->name),
1112 case SNMP_PDU_GETNEXT:
1114 *pErrorStatus = SNMP_ERRORSTATUS_NOSUCHNAME;
1117 UINT tableIndex = 0, item = 0;
1119 *pErrorStatus = getItemAndInstanceFromTable(&pVarBind->name, &myOid,
1120 5, bPduType, (struct GenericTable *)udpTable,
1121 sizeof(MIB_UDPROW), oidToUdpRow, compareUdpRow, &item,
1127 *pErrorStatus = mapStructEntryToValue(mib2UdpEntryMap,
1128 DEFINE_SIZEOF(mib2UdpEntryMap),
1129 &udpTable->table[tableIndex - 1], item, bPduType, pVarBind);
1130 if (!*pErrorStatus && bPduType == SNMP_PDU_GETNEXT)
1132 AsnObjectIdentifier oid;
1134 setOidWithItemAndIpAddr(&pVarBind->name, &myOid, item,
1135 udpTable->table[tableIndex - 1].dwLocalAddr);
1137 oid.ids = &udpTable->table[tableIndex - 1].dwLocalPort;
1138 SnmpUtilOidAppend(&pVarBind->name, &oid);
1144 *pErrorStatus = SNMP_ERRORSTATUS_READONLY;
1147 FIXME("0x%02x: unsupported PDU type\n", bPduType);
1148 *pErrorStatus = SNMP_ERRORSTATUS_NOSUCHNAME;
1153 /* This list MUST BE lexicographically sorted */
1154 static struct mibImplementation supportedIDs[] = {
1155 { DEFINE_OID(mib2IfNumber), mib2IfNumberInit, mib2IfNumberQuery,
1156 mib2IfNumberCleanup },
1157 { DEFINE_OID(mib2IfEntry), NULL, mib2IfEntryQuery, NULL },
1158 { DEFINE_OID(mib2Ip), mib2IpStatsInit, mib2IpStatsQuery, NULL },
1159 { DEFINE_OID(mib2IpAddr), mib2IpAddrInit, mib2IpAddrQuery,
1160 mib2IpAddrCleanup },
1161 { DEFINE_OID(mib2IpRoute), mib2IpRouteInit, mib2IpRouteQuery,
1162 mib2IpRouteCleanup },
1163 { DEFINE_OID(mib2IpNet), mib2IpNetInit, mib2IpNetQuery, mib2IpNetCleanup },
1164 { DEFINE_OID(mib2Icmp), mib2IcmpInit, mib2IcmpQuery, NULL },
1165 { DEFINE_OID(mib2Tcp), mib2TcpInit, mib2TcpQuery, NULL },
1166 { DEFINE_OID(mib2Udp), mib2UdpInit, mib2UdpQuery, NULL },
1167 { DEFINE_OID(mib2UdpEntry), mib2UdpEntryInit, mib2UdpEntryQuery,
1168 mib2UdpEntryCleanup },
1170 static UINT minSupportedIDLength;
1172 /*****************************************************************************
1173 * SnmpExtensionInit [INETMIB1.@]
1175 BOOL WINAPI SnmpExtensionInit(DWORD dwUptimeReference,
1176 HANDLE *phSubagentTrapEvent, AsnObjectIdentifier *pFirstSupportedRegion)
1178 AsnObjectIdentifier myOid = DEFINE_OID(mib2System);
1181 TRACE("(%d, %p, %p)\n", dwUptimeReference, phSubagentTrapEvent,
1182 pFirstSupportedRegion);
1184 minSupportedIDLength = UINT_MAX;
1185 for (i = 0; i < sizeof(supportedIDs) / sizeof(supportedIDs[0]); i++)
1187 if (supportedIDs[i].init)
1188 supportedIDs[i].init();
1189 if (supportedIDs[i].name.idLength < minSupportedIDLength)
1190 minSupportedIDLength = supportedIDs[i].name.idLength;
1192 *phSubagentTrapEvent = NULL;
1193 SnmpUtilOidCpy(pFirstSupportedRegion, &myOid);
1197 static void cleanup(void)
1201 for (i = 0; i < sizeof(supportedIDs) / sizeof(supportedIDs[0]); i++)
1202 if (supportedIDs[i].cleanup)
1203 supportedIDs[i].cleanup();
1206 static struct mibImplementation *findSupportedQuery(UINT *ids, UINT idLength,
1207 UINT *matchingIndex)
1209 int indexHigh = DEFINE_SIZEOF(supportedIDs) - 1, indexLow = 0, i;
1210 struct mibImplementation *impl = NULL;
1211 AsnObjectIdentifier oid1 = { idLength, ids};
1215 for (i = (indexLow + indexHigh) / 2; !impl && indexLow <= indexHigh;
1216 i = (indexLow + indexHigh) / 2)
1220 cmp = SnmpUtilOidNCmp(&oid1, &supportedIDs[i].name, idLength);
1223 impl = &supportedIDs[i];
1234 /*****************************************************************************
1235 * SnmpExtensionQuery [INETMIB1.@]
1237 BOOL WINAPI SnmpExtensionQuery(BYTE bPduType, SnmpVarBindList *pVarBindList,
1238 AsnInteger32 *pErrorStatus, AsnInteger32 *pErrorIndex)
1240 AsnObjectIdentifier mib2oid = DEFINE_OID(mib2);
1241 AsnInteger32 error = SNMP_ERRORSTATUS_NOERROR, errorIndex = 0;
1244 TRACE("(0x%02x, %p, %p, %p)\n", bPduType, pVarBindList,
1245 pErrorStatus, pErrorIndex);
1247 for (i = 0; !error && i < pVarBindList->len; i++)
1249 /* Ignore any OIDs not in MIB2 */
1250 if (!SnmpUtilOidNCmp(&pVarBindList->list[i].name, &mib2oid,
1253 struct mibImplementation *impl = NULL;
1254 UINT len, matchingIndex = 0;
1256 TRACE("%s\n", SnmpUtilOidToA(&pVarBindList->list[i].name));
1257 /* Search for an implementation matching as many octets as possible
1259 for (len = pVarBindList->list[i].name.idLength;
1260 len >= minSupportedIDLength && !impl; len--)
1261 impl = findSupportedQuery(pVarBindList->list[i].name.ids, len,
1263 if (impl && impl->query)
1264 impl->query(bPduType, &pVarBindList->list[i], &error);
1266 error = SNMP_ERRORSTATUS_NOSUCHNAME;
1267 if (error == SNMP_ERRORSTATUS_NOSUCHNAME &&
1268 bPduType == SNMP_PDU_GETNEXT)
1270 /* GetNext is special: it finds the successor to the given OID,
1271 * so we have to continue until an implementation handles the
1272 * query or we exhaust the table of supported OIDs.
1274 for (; error == SNMP_ERRORSTATUS_NOSUCHNAME &&
1275 matchingIndex < DEFINE_SIZEOF(supportedIDs);
1278 error = SNMP_ERRORSTATUS_NOERROR;
1279 impl = &supportedIDs[matchingIndex];
1281 impl->query(bPduType, &pVarBindList->list[i], &error);
1283 error = SNMP_ERRORSTATUS_NOSUCHNAME;
1285 /* If the query still isn't resolved, set the OID to the
1286 * successor to the last entry in the table.
1288 if (error == SNMP_ERRORSTATUS_NOSUCHNAME)
1290 SnmpUtilOidFree(&pVarBindList->list[i].name);
1291 SnmpUtilOidCpy(&pVarBindList->list[i].name,
1292 &supportedIDs[matchingIndex - 1].name);
1293 pVarBindList->list[i].name.ids[
1294 pVarBindList->list[i].name.idLength - 1] += 1;
1301 *pErrorStatus = error;
1302 *pErrorIndex = errorIndex;
1306 /*****************************************************************************
1307 * DllMain [INETMIB1.@]
1309 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
1311 TRACE("(0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
1315 case DLL_PROCESS_ATTACH:
1316 DisableThreadLibraryCalls(hinstDLL);
1318 case DLL_PROCESS_DETACH: