winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
June 2008
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
3 participants
944 discussions
Start a n
N
ew thread
Eric Durbin : iphlpapi: Implement getInterfaceStatsByName on FreeBSD.
by Alexandre Julliard
26 Jun '08
26 Jun '08
Module: wine Branch: master Commit: 53058e86e83b4b6c9cf3994378287e0761039732 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=53058e86e83b4b6c9cf399437…
Author: Eric Durbin <eadurbin(a)freebsd.org> Date: Tue Jun 24 22:42:51 2008 -0500 iphlpapi: Implement getInterfaceStatsByName on FreeBSD. --- dlls/iphlpapi/ipstats.c | 59 +++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 54 insertions(+), 5 deletions(-) diff --git a/dlls/iphlpapi/ipstats.c b/dlls/iphlpapi/ipstats.c index a7fd40d..3a537b1 100644 --- a/dlls/iphlpapi/ipstats.c +++ b/dlls/iphlpapi/ipstats.c @@ -43,6 +43,9 @@ #ifdef HAVE_NET_IF_H #include <net/if.h> #endif +#ifdef HAVE_NET_IF_TYPES_H +#include <net/if_types.h> +#endif #ifdef HAVE_NET_ROUTE_H #include <net/route.h> #endif @@ -102,15 +105,60 @@ WINE_DEFAULT_DEBUG_CHANNEL(iphlpapi); DWORD getInterfaceStatsByName(const char *name, PMIB_IFROW entry) { - FILE *fp; - - if (!name) - return ERROR_INVALID_PARAMETER; - if (!entry) +#if defined(HAVE_SYS_SYSCTL_H) && defined(NET_RT_IFLIST) + int mib[] = {CTL_NET, PF_ROUTE, 0, AF_INET, NET_RT_IFLIST, if_nametoindex(name)}; +#define MIB_LEN (sizeof(mib) / sizeof(mib[0])) + + size_t needed; + char *buf, *end; + struct if_msghdr *ifm; + struct if_data ifdata; + if (!name || !entry) return ERROR_INVALID_PARAMETER; + if(sysctl(mib, MIB_LEN, NULL, &needed, NULL, 0) == -1) + { + ERR ("failed to get size of iflist\n"); + return ERROR_NOT_SUPPORTED; + } + buf = HeapAlloc (GetProcessHeap (), 0, needed); + if (!buf) return ERROR_NOT_SUPPORTED; + if(sysctl(mib, MIB_LEN, buf, &needed, NULL, 0) == -1) + { + ERR ("failed to get iflist\n"); + HeapFree (GetProcessHeap (), 0, buf); + return ERROR_NOT_SUPPORTED; + } + else + for ( end = buf + needed; buf < end; buf += ifm->ifm_msglen) + { + ifm = (struct if_msghdr *) buf; + if(ifm->ifm_type == RTM_IFINFO && ifm->ifm_data.ifi_type == IFT_ETHER) + { + ifdata = ifm->ifm_data; + entry->dwMtu = ifdata.ifi_mtu; + entry->dwSpeed = ifdata.ifi_baudrate; + entry->dwInOctets = ifdata.ifi_ibytes; + entry->dwInErrors = ifdata.ifi_ierrors; + entry->dwInDiscards = ifdata.ifi_iqdrops; + entry->dwInUcastPkts = ifdata.ifi_ipackets; + entry->dwInNUcastPkts = ifdata.ifi_imcasts; + entry->dwOutOctets = ifdata.ifi_obytes; + entry->dwOutUcastPkts = ifdata.ifi_opackets; + entry->dwOutErrors = ifdata.ifi_oerrors; + HeapFree (GetProcessHeap (), 0, buf); + return NO_ERROR; + } + } + HeapFree (GetProcessHeap (), 0, buf); + return ERROR_NOT_SUPPORTED; +#else /* get interface stats from /proc/net/dev, no error if can't no inUnknownProtos, outNUcastPkts, outQLen */ + FILE *fp; + + if (!name || !entry) + return ERROR_INVALID_PARAMETER; fp = fopen("/proc/net/dev", "r"); if (fp) { char buf[512] = { 0 }, *ptr; @@ -188,6 +236,7 @@ DWORD getInterfaceStatsByName(const char *name, PMIB_IFROW entry) } return NO_ERROR; +#endif } DWORD getICMPStats(MIB_ICMP *stats)
1
0
0
0
Alex Villacís Lasso : richedit: Fix failing EM_GETCHARFORMAT test on all platforms.
by Alexandre Julliard
26 Jun '08
26 Jun '08
Module: wine Branch: master Commit: c774d681ce40c560ee781bfcfd90fd284de8ee30 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=c774d681ce40c560ee781bfcf…
Author: Alex Villacís Lasso <a_villacis(a)palosanto.com> Date: Wed Jun 25 01:22:00 2008 -0500 richedit: Fix failing EM_GETCHARFORMAT test on all platforms. Default richedit font (System) in Windows causes richedit to report CFM_BOLD as always set. Switch to Courier New in order to see that richedit really sets the CFM_BOLD attribute in the correct selection. --- dlls/riched20/tests/editor.c | 32 ++++++++++++++++++++++++++++++-- 1 files changed, 30 insertions(+), 2 deletions(-) diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c index 8838d05..2de076e 100644 --- a/dlls/riched20/tests/editor.c +++ b/dlls/riched20/tests/editor.c @@ -657,6 +657,27 @@ static void test_EM_SETCHARFORMAT(void) hwndRichEdit = new_richedit(NULL); SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"wine"); + /* Need to set a TrueType font to get consistent CFM_BOLD results */ + memset(&cf2, 0, sizeof(CHARFORMAT2)); + cf2.cbSize = sizeof(CHARFORMAT2); + cf2.dwMask = CFM_FACE|CFM_WEIGHT; + cf2.dwEffects = 0; + strcpy(cf2.szFaceName, "Courier New"); + cf2.wWeight = FW_DONTCARE; + SendMessage(hwndRichEdit, EM_SETCHARFORMAT, SCF_ALL, (LPARAM) &cf2); + + memset(&cf2, 0, sizeof(CHARFORMAT2)); + cf2.cbSize = sizeof(CHARFORMAT2); + SendMessage(hwndRichEdit, EM_SETSEL, 0, 4); + SendMessage(hwndRichEdit, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM) &cf2); + ok ((((tested_effects[i] == CFE_SUBSCRIPT || tested_effects[i] == CFE_SUPERSCRIPT) && + (cf2.dwMask & CFM_SUPERSCRIPT) == CFM_SUPERSCRIPT) + || + (cf2.dwMask & tested_effects[i]) == tested_effects[i]), + "%d, cf2.dwMask == 0x%08x expected mask 0x%08x\n", i, cf2.dwMask, tested_effects[i]); + ok((cf2.dwEffects & tested_effects[i]) == 0, + "%d, cf2.dwEffects == 0x%08x expected effect 0x%08x clear\n", i, cf2.dwEffects, tested_effects[i]); + memset(&cf2, 0, sizeof(CHARFORMAT2)); cf2.cbSize = sizeof(CHARFORMAT2); cf2.dwMask = tested_effects[i]; @@ -699,8 +720,6 @@ static void test_EM_SETCHARFORMAT(void) || (cf2.dwMask & tested_effects[i]) == 0), "%d, cf2.dwMask == 0x%08x expected mask 0x%08x clear\n", i, cf2.dwMask, tested_effects[i]); - ok((cf2.dwEffects & tested_effects[i]) == 0, - "%d, cf2.dwEffects == 0x%08x expected effect 0x%08x clear\n", i, cf2.dwEffects, tested_effects[i]); DestroyWindow(hwndRichEdit); } @@ -710,6 +729,15 @@ static void test_EM_SETCHARFORMAT(void) hwndRichEdit = new_richedit(NULL); SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"wine"); + /* Need to set a TrueType font to get consistent CFM_BOLD results */ + memset(&cf2, 0, sizeof(CHARFORMAT2)); + cf2.cbSize = sizeof(CHARFORMAT2); + cf2.dwMask = CFM_FACE|CFM_WEIGHT; + cf2.dwEffects = 0; + strcpy(cf2.szFaceName, "Courier New"); + cf2.wWeight = FW_DONTCARE; + SendMessage(hwndRichEdit, EM_SETCHARFORMAT, SCF_ALL, (LPARAM) &cf2); + memset(&cf2, 0, sizeof(CHARFORMAT2)); cf2.cbSize = sizeof(CHARFORMAT2); cf2.dwMask = tested_effects[i];
1
0
0
0
Juan Lang : inetmib1: Sort the tables keyed by IP address, and use bsearch to find entries in them.
by Alexandre Julliard
25 Jun '08
25 Jun '08
Module: wine Branch: master Commit: 9e919b8ae9d739a0a36e54ad2ad5b17b83bc01f9 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=9e919b8ae9d739a0a36e54ad2…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Wed Jun 25 09:42:16 2008 -0700 inetmib1: Sort the tables keyed by IP address, and use bsearch to find entries in them. --- dlls/inetmib1/main.c | 95 +++++++++++++++++++++++++++++++++++--------------- 1 files changed, 67 insertions(+), 28 deletions(-) diff --git a/dlls/inetmib1/main.c b/dlls/inetmib1/main.c index d514653..20fc0b9 100644 --- a/dlls/inetmib1/main.c +++ b/dlls/inetmib1/main.c @@ -19,6 +19,7 @@ #include "config.h" #include <assert.h> #include <stdarg.h> +#include <stdlib.h> #include <limits.h> #include "windef.h" #include "winbase.h" @@ -317,26 +318,35 @@ struct GenericTable BYTE entries[1]; }; -/* Finds the index in table whose IP address (at offset addressOffset within the - * entry) matches that given the OID, which is assumed to have at least 4 IDs. - */ -static UINT findOIDIPAddressInTable(AsnObjectIdentifier *oid, - struct GenericTable *table, size_t tableEntrySize, size_t addressOffset) +static DWORD oidToIpAddr(AsnObjectIdentifier *oid) { - DWORD addr; - UINT i, index = 0; - + assert(oid && oid->idLength >= 4); /* Map the IDs to an IP address in little-endian order */ - addr = (BYTE)oid->ids[3] << 24 | (BYTE)oid->ids[2] << 16 | + return (BYTE)oid->ids[3] << 24 | (BYTE)oid->ids[2] << 16 | (BYTE)oid->ids[1] << 8 | (BYTE)oid->ids[0]; - /* Find the item whose address matches */ - for (i = 0; !index && i < table->numEntries; i++) - { - DWORD tableAddr = - *(DWORD *)(table->entries + i * tableEntrySize + addressOffset); +} + +typedef void (*oidToKeyFunc)(AsnObjectIdentifier *oid, void *dst); +typedef int (*compareFunc)(const void *key, const void *value); + +static UINT findValueInTable(AsnObjectIdentifier *oid, + struct GenericTable *table, size_t tableEntrySize, oidToKeyFunc makeKey, + compareFunc compare) +{ + UINT index = 0; + void *key = HeapAlloc(GetProcessHeap(), 0, tableEntrySize); - if (addr == tableAddr) - index = i + 1; + if (key) + { + void *value; + + makeKey(oid, key); + value = bsearch(key, table->entries, table->numEntries, tableEntrySize, + compare); + if (value) + index = ((BYTE *)value - (BYTE *)table->entries) / tableEntrySize + + 1; + HeapFree(GetProcessHeap(), 0, key); } return index; } @@ -352,7 +362,8 @@ static UINT findOIDIPAddressInTable(AsnObjectIdentifier *oid, */ static AsnInteger32 getItemAndIpAddressInstanceFromOid(AsnObjectIdentifier *oid, AsnObjectIdentifier *base, BYTE bPduType, struct GenericTable *table, - size_t tableEntrySize, size_t addressOffset, UINT *item, UINT *instance) + size_t tableEntrySize, oidToKeyFunc makeKey, compareFunc compare, + UINT *item, UINT *instance) { AsnInteger32 ret = SNMP_ERRORSTATUS_NOERROR; @@ -398,8 +409,8 @@ static AsnInteger32 getItemAndIpAddressInstanceFromOid(AsnObjectIdentifier *oid, AsnObjectIdentifier ipOid = { 4, oid->ids + base->idLength + 1 }; - *instance = findOIDIPAddressInTable(&ipOid, table, - tableEntrySize, addressOffset) + 1; + *instance = findValueInTable(&ipOid, table, tableEntrySize, + makeKey, compare) + 1; if (*instance > table->numEntries) ret = SNMP_ERRORSTATUS_NOSUCHNAME; } @@ -419,8 +430,8 @@ static AsnInteger32 getItemAndIpAddressInstanceFromOid(AsnObjectIdentifier *oid, AsnObjectIdentifier ipOid = { 4, oid->ids + base->idLength + 1 }; - *instance = findOIDIPAddressInTable(&ipOid, table, - tableEntrySize, addressOffset); + *instance = findValueInTable(&ipOid, table, tableEntrySize, + makeKey, compare); if (!*instance) ret = SNMP_ERRORSTATUS_NOSUCHNAME; } @@ -632,16 +643,30 @@ static struct structToAsnValue mib2IpAddrMap[] = { static void mib2IpAddrInit(void) { - DWORD size = 0, ret = GetIpAddrTable(NULL, &size, FALSE); + DWORD size = 0, ret = GetIpAddrTable(NULL, &size, TRUE); if (ret == ERROR_INSUFFICIENT_BUFFER) { ipAddrTable = HeapAlloc(GetProcessHeap(), 0, size); if (ipAddrTable) - GetIpAddrTable(ipAddrTable, &size, FALSE); + GetIpAddrTable(ipAddrTable, &size, TRUE); } } +static void oidToIpAddrRow(AsnObjectIdentifier *oid, void *dst) +{ + MIB_IPADDRROW *row = dst; + + row->dwAddr = oidToIpAddr(oid); +} + +static int compareIpAddrRow(const void *a, const void *b) +{ + const MIB_IPADDRROW *key = a, *value = b; + + return key->dwAddr - value->dwAddr; +} + static BOOL mib2IpAddrQuery(BYTE bPduType, SnmpVarBind *pVarBind, AsnInteger32 *pErrorStatus) { @@ -657,7 +682,7 @@ static BOOL mib2IpAddrQuery(BYTE bPduType, SnmpVarBind *pVarBind, case SNMP_PDU_GETNEXT: *pErrorStatus = getItemAndIpAddressInstanceFromOid(&pVarBind->name, &myOid, bPduType, (struct GenericTable *)ipAddrTable, - sizeof(MIB_IPADDRROW), FIELD_OFFSET(MIB_IPADDRROW, dwAddr), &item, + sizeof(MIB_IPADDRROW), oidToIpAddrRow, compareIpAddrRow, &item, &tableIndex); if (!*pErrorStatus) { @@ -701,16 +726,30 @@ static struct structToAsnValue mib2IpRouteMap[] = { static void mib2IpRouteInit(void) { - DWORD size = 0, ret = GetIpForwardTable(NULL, &size, FALSE); + DWORD size = 0, ret = GetIpForwardTable(NULL, &size, TRUE); if (ret == ERROR_INSUFFICIENT_BUFFER) { ipRouteTable = HeapAlloc(GetProcessHeap(), 0, size); if (ipRouteTable) - GetIpForwardTable(ipRouteTable, &size, FALSE); + GetIpForwardTable(ipRouteTable, &size, TRUE); } } +static void oidToIpForwardRow(AsnObjectIdentifier *oid, void *dst) +{ + MIB_IPFORWARDROW *row = dst; + + row->dwForwardDest = oidToIpAddr(oid); +} + +static int compareIpForwardRow(const void *a, const void *b) +{ + const MIB_IPFORWARDROW *key = a, *value = b; + + return key->dwForwardDest - value->dwForwardDest; +} + static BOOL mib2IpRouteQuery(BYTE bPduType, SnmpVarBind *pVarBind, AsnInteger32 *pErrorStatus) { @@ -726,8 +765,8 @@ static BOOL mib2IpRouteQuery(BYTE bPduType, SnmpVarBind *pVarBind, case SNMP_PDU_GETNEXT: *pErrorStatus = getItemAndIpAddressInstanceFromOid(&pVarBind->name, &myOid, bPduType, (struct GenericTable *)ipRouteTable, - sizeof(MIB_IPFORWARDROW), - FIELD_OFFSET(MIB_IPFORWARDROW, dwForwardDest), &item, &tableIndex); + sizeof(MIB_IPFORWARDROW), oidToIpForwardRow, compareIpForwardRow, + &item, &tableIndex); if (!*pErrorStatus) { assert(tableIndex);
1
0
0
0
Juan Lang : inetmib1: Support the MIB2 UDP statistics.
by Alexandre Julliard
25 Jun '08
25 Jun '08
Module: wine Branch: master Commit: 677946941c4b29911dd0d13027a72c9354f292f3 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=677946941c4b29911dd0d1302…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Wed Jun 25 09:39:47 2008 -0700 inetmib1: Support the MIB2 UDP statistics. --- dlls/inetmib1/main.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 49 insertions(+), 0 deletions(-) diff --git a/dlls/inetmib1/main.c b/dlls/inetmib1/main.c index 48fad9d..d514653 100644 --- a/dlls/inetmib1/main.c +++ b/dlls/inetmib1/main.c @@ -950,6 +950,54 @@ static BOOL mib2TcpQuery(BYTE bPduType, SnmpVarBind *pVarBind, return TRUE; } +static UINT mib2Udp[] = { 1,3,6,1,2,1,7 }; +static MIB_UDPSTATS udpStats; + +static void mib2UdpInit(void) +{ + GetUdpStatistics(&udpStats); +} + +static struct structToAsnValue mib2UdpMap[] = { + { FIELD_OFFSET(MIB_UDPSTATS, dwInDatagrams), copyInt }, + { FIELD_OFFSET(MIB_UDPSTATS, dwNoPorts), copyInt }, + { FIELD_OFFSET(MIB_UDPSTATS, dwInErrors), copyInt }, + { FIELD_OFFSET(MIB_UDPSTATS, dwOutDatagrams), copyInt }, +}; + +static BOOL mib2UdpQuery(BYTE bPduType, SnmpVarBind *pVarBind, + AsnInteger32 *pErrorStatus) +{ + AsnObjectIdentifier myOid = DEFINE_OID(mib2Udp); + UINT item; + + TRACE("(0x%02x, %s, %p)\n", bPduType, SnmpUtilOidToA(&pVarBind->name), + pErrorStatus); + + switch (bPduType) + { + case SNMP_PDU_GET: + case SNMP_PDU_GETNEXT: + *pErrorStatus = getItemFromOid(&pVarBind->name, &myOid, bPduType, + &item); + if (!*pErrorStatus) + { + *pErrorStatus = mapStructEntryToValue(mib2UdpMap, + DEFINE_SIZEOF(mib2UdpMap), &udpStats, item, bPduType, pVarBind); + if (!*pErrorStatus && bPduType == SNMP_PDU_GETNEXT) + setOidWithItem(&pVarBind->name, &myOid, item); + } + break; + case SNMP_PDU_SET: + *pErrorStatus = SNMP_ERRORSTATUS_READONLY; + break; + default: + FIXME("0x%02x: unsupported PDU type\n", bPduType); + *pErrorStatus = SNMP_ERRORSTATUS_NOSUCHNAME; + } + return TRUE; +} + /* This list MUST BE lexicographically sorted */ static struct mibImplementation supportedIDs[] = { { DEFINE_OID(mib2IfNumber), mib2IfNumberInit, mib2IfNumberQuery }, @@ -960,6 +1008,7 @@ static struct mibImplementation supportedIDs[] = { { DEFINE_OID(mib2IpNet), mib2IpNetInit, mib2IpNetQuery }, { DEFINE_OID(mib2Icmp), mib2IcmpInit, mib2IcmpQuery }, { DEFINE_OID(mib2Tcp), mib2TcpInit, mib2TcpQuery }, + { DEFINE_OID(mib2Udp), mib2UdpInit, mib2UdpQuery }, }; static UINT minSupportedIDLength;
1
0
0
0
Juan Lang : inetmib1: Use a helper function to set the Oid with an item.
by Alexandre Julliard
25 Jun '08
25 Jun '08
Module: wine Branch: master Commit: 0fb70c6d8e07f4485807559f746741780cd50e1a URL:
http://source.winehq.org/git/wine.git/?a=commit;h=0fb70c6d8e07f4485807559f7…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Wed Jun 25 09:39:03 2008 -0700 inetmib1: Use a helper function to set the Oid with an item. --- dlls/inetmib1/main.c | 50 +++++++++++++++++++------------------------------- 1 files changed, 19 insertions(+), 31 deletions(-) diff --git a/dlls/inetmib1/main.c b/dlls/inetmib1/main.c index c6a2695..48fad9d 100644 --- a/dlls/inetmib1/main.c +++ b/dlls/inetmib1/main.c @@ -431,11 +431,10 @@ static AsnInteger32 getItemAndIpAddressInstanceFromOid(AsnObjectIdentifier *oid, return ret; } -static void setOidWithItemAndIpAddr(AsnObjectIdentifier *dst, - AsnObjectIdentifier *base, UINT item, DWORD addr) +static void setOidWithItem(AsnObjectIdentifier *dst, AsnObjectIdentifier *base, + UINT item) { UINT id; - BYTE *ptr; AsnObjectIdentifier oid; SnmpUtilOidCpy(dst, base); @@ -443,6 +442,18 @@ static void setOidWithItemAndIpAddr(AsnObjectIdentifier *dst, oid.ids = &id; id = item; SnmpUtilOidAppend(dst, &oid); +} + +static void setOidWithItemAndIpAddr(AsnObjectIdentifier *dst, + AsnObjectIdentifier *base, UINT item, DWORD addr) +{ + UINT id; + BYTE *ptr; + AsnObjectIdentifier oid; + + setOidWithItem(dst, base, item); + oid.idLength = 1; + oid.ids = &id; for (ptr = (BYTE *)&addr; ptr < (BYTE *)&addr + sizeof(DWORD); ptr++) { id = *ptr; @@ -455,10 +466,8 @@ static void setOidWithItemAndInteger(AsnObjectIdentifier *dst, { AsnObjectIdentifier oid; - SnmpUtilOidCpy(dst, base); + setOidWithItem(dst, base, item); oid.idLength = 1; - oid.ids = &item; - SnmpUtilOidAppend(dst, &oid); oid.ids = &instance; SnmpUtilOidAppend(dst, &oid); } @@ -597,14 +606,7 @@ static BOOL mib2IpStatsQuery(BYTE bPduType, SnmpVarBind *pVarBind, *pErrorStatus = mapStructEntryToValue(mib2IpMap, DEFINE_SIZEOF(mib2IpMap), &ipStats, item, bPduType, pVarBind); if (!*pErrorStatus && bPduType == SNMP_PDU_GETNEXT) - { - AsnObjectIdentifier oid; - - SnmpUtilOidCpy(&pVarBind->name, &myOid); - oid.idLength = 1; - oid.ids = &item; - SnmpUtilOidAppend(&pVarBind->name, &oid); - } + setOidWithItem(&pVarBind->name, &myOid, item); } break; case SNMP_PDU_SET: @@ -875,15 +877,8 @@ static BOOL mib2IcmpQuery(BYTE bPduType, SnmpVarBind *pVarBind, *pErrorStatus = mapStructEntryToValue(mib2IcmpMap, DEFINE_SIZEOF(mib2IcmpMap), &icmpStats, item, bPduType, pVarBind); - if (!*pErrorStatus) - { - AsnObjectIdentifier oid; - - SnmpUtilOidCpy(&pVarBind->name, &myOid); - oid.idLength = 1; - oid.ids = &item; - SnmpUtilOidAppend(&pVarBind->name, &oid); - } + if (!*pErrorStatus && bPduType == SNMP_PDU_GETNEXT) + setOidWithItem(&pVarBind->name, &myOid, item); } break; case SNMP_PDU_SET: @@ -942,14 +937,7 @@ static BOOL mib2TcpQuery(BYTE bPduType, SnmpVarBind *pVarBind, *pErrorStatus = mapStructEntryToValue(mib2TcpMap, DEFINE_SIZEOF(mib2TcpMap), &tcpStats, item, bPduType, pVarBind); if (!*pErrorStatus && bPduType == SNMP_PDU_GETNEXT) - { - AsnObjectIdentifier oid; - - SnmpUtilOidCpy(&pVarBind->name, &myOid); - oid.idLength = 1; - oid.ids = &item; - SnmpUtilOidAppend(&pVarBind->name, &oid); - } + setOidWithItem(&pVarBind->name, &myOid, item); } break; case SNMP_PDU_SET:
1
0
0
0
Juan Lang : inetmib1: Use a helper function to set the Oid with an integer instance.
by Alexandre Julliard
25 Jun '08
25 Jun '08
Module: wine Branch: master Commit: 81b0db24930aa3959d1e7a59b9431c0f07abbe9d URL:
http://source.winehq.org/git/wine.git/?a=commit;h=81b0db24930aa3959d1e7a59b…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Wed Jun 25 09:38:27 2008 -0700 inetmib1: Use a helper function to set the Oid with an integer instance. --- dlls/inetmib1/main.c | 45 +++++++++++++++++---------------------------- 1 files changed, 17 insertions(+), 28 deletions(-) diff --git a/dlls/inetmib1/main.c b/dlls/inetmib1/main.c index 3ce7b6c..c6a2695 100644 --- a/dlls/inetmib1/main.c +++ b/dlls/inetmib1/main.c @@ -450,6 +450,19 @@ static void setOidWithItemAndIpAddr(AsnObjectIdentifier *dst, } } +static void setOidWithItemAndInteger(AsnObjectIdentifier *dst, + AsnObjectIdentifier *base, UINT item, UINT instance) +{ + AsnObjectIdentifier oid; + + SnmpUtilOidCpy(dst, base); + oid.idLength = 1; + oid.ids = &item; + SnmpUtilOidAppend(dst, &oid); + oid.ids = &instance; + SnmpUtilOidAppend(dst, &oid); +} + static struct structToAsnValue mib2IfEntryMap[] = { { FIELD_OFFSET(MIB_IFROW, dwIndex), copyInt }, { FIELD_OFFSET(MIB_IFROW, dwDescrLen), copyLengthPrecededString }, @@ -514,23 +527,8 @@ static BOOL mib2IfEntryQuery(BYTE bPduType, SnmpVarBind *pVarBind, &ifTable->table[tableIndex - 1], item, bPduType, pVarBind); if (bPduType == SNMP_PDU_GETNEXT) - { - AsnObjectIdentifier oid; - - SnmpUtilOidCpy(&pVarBind->name, &entryOid); - oid.idLength = 1; - oid.ids = &item; - SnmpUtilOidAppend(&pVarBind->name, &oid); - /* According to RFC1158, the value of the interface - * index must vary between 1 and ifNumber (the number - * of interfaces), so use the 1-based table index - * directly, rather than assuming that IPHlpApi's - * dwIndex will have the correct range. - */ - oid.idLength = 1; - oid.ids = &tableIndex; - SnmpUtilOidAppend(&pVarBind->name, &oid); - } + setOidWithItemAndInteger(&pVarBind->name, &entryOid, + item, tableIndex); } } } @@ -804,17 +802,8 @@ static BOOL mib2IpNetQuery(BYTE bPduType, SnmpVarBind *pVarBind, DEFINE_SIZEOF(mib2IpNetMap), &ipNetTable[tableIndex - 1], item, bPduType, pVarBind); if (!*pErrorStatus && bPduType == SNMP_PDU_GETNEXT) - { - AsnObjectIdentifier oid; - - SnmpUtilOidCpy(&pVarBind->name, &myOid); - oid.idLength = 1; - oid.ids = &item; - SnmpUtilOidAppend(&pVarBind->name, &oid); - oid.idLength = 1; - oid.ids = &tableIndex; - SnmpUtilOidAppend(&pVarBind->name, &oid); - } + setOidWithItemAndInteger(&pVarBind->name, &myOid, item, + tableIndex); } } }
1
0
0
0
Juan Lang : inetmib1: Use a helper function to set the Oid with an IP address-based instance.
by Alexandre Julliard
25 Jun '08
25 Jun '08
Module: wine Branch: master Commit: d3f0e8c9dbb98159d32baffdf9b45ffdeb76d7e8 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=d3f0e8c9dbb98159d32baffdf…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Wed Jun 25 09:35:13 2008 -0700 inetmib1: Use a helper function to set the Oid with an IP address-based instance. --- dlls/inetmib1/main.c | 61 ++++++++++++++++++------------------------------- 1 files changed, 23 insertions(+), 38 deletions(-) diff --git a/dlls/inetmib1/main.c b/dlls/inetmib1/main.c index e7bb28e..3ce7b6c 100644 --- a/dlls/inetmib1/main.c +++ b/dlls/inetmib1/main.c @@ -431,6 +431,25 @@ static AsnInteger32 getItemAndIpAddressInstanceFromOid(AsnObjectIdentifier *oid, return ret; } +static void setOidWithItemAndIpAddr(AsnObjectIdentifier *dst, + AsnObjectIdentifier *base, UINT item, DWORD addr) +{ + UINT id; + BYTE *ptr; + AsnObjectIdentifier oid; + + SnmpUtilOidCpy(dst, base); + oid.idLength = 1; + oid.ids = &id; + id = item; + SnmpUtilOidAppend(dst, &oid); + for (ptr = (BYTE *)&addr; ptr < (BYTE *)&addr + sizeof(DWORD); ptr++) + { + id = *ptr; + SnmpUtilOidAppend(dst, &oid); + } +} + static struct structToAsnValue mib2IfEntryMap[] = { { FIELD_OFFSET(MIB_IFROW, dwIndex), copyInt }, { FIELD_OFFSET(MIB_IFROW, dwDescrLen), copyLengthPrecededString }, @@ -648,24 +667,8 @@ static BOOL mib2IpAddrQuery(BYTE bPduType, SnmpVarBind *pVarBind, DEFINE_SIZEOF(mib2IpAddrMap), &ipAddrTable->table[tableIndex - 1], item, bPduType, pVarBind); if (!*pErrorStatus && bPduType == SNMP_PDU_GETNEXT) - { - UINT id; - BYTE *ptr; - AsnObjectIdentifier oid; - - SnmpUtilOidCpy(&pVarBind->name, &myOid); - oid.idLength = 1; - oid.ids = &id; - id = item; - SnmpUtilOidAppend(&pVarBind->name, &oid); - for (ptr = (BYTE *)&ipAddrTable->table[tableIndex - 1].dwAddr; - ptr < (BYTE *)&ipAddrTable->table[tableIndex - 1].dwAddr + - sizeof(DWORD); ptr++) - { - id = *ptr; - SnmpUtilOidAppend(&pVarBind->name, &oid); - } - } + setOidWithItemAndIpAddr(&pVarBind->name, &myOid, item, + ipAddrTable->table[tableIndex - 1].dwAddr); } break; case SNMP_PDU_SET: @@ -733,26 +736,8 @@ static BOOL mib2IpRouteQuery(BYTE bPduType, SnmpVarBind *pVarBind, DEFINE_SIZEOF(mib2IpRouteMap), &ipRouteTable->table[tableIndex - 1], item, bPduType, pVarBind); if (!*pErrorStatus && bPduType == SNMP_PDU_GETNEXT) - { - UINT id; - BYTE *ptr; - AsnObjectIdentifier oid; - - SnmpUtilOidCpy(&pVarBind->name, &myOid); - oid.idLength = 1; - oid.ids = &id; - id = item; - SnmpUtilOidAppend(&pVarBind->name, &oid); - for (ptr = - (BYTE *)&ipRouteTable->table[tableIndex - 1].dwForwardDest; - ptr < - (BYTE *)&ipRouteTable->table[tableIndex - 1].dwForwardDest - + sizeof(DWORD); ptr++) - { - id = *ptr; - SnmpUtilOidAppend(&pVarBind->name, &oid); - } - } + setOidWithItemAndIpAddr(&pVarBind->name, &myOid, item, + ipRouteTable->table[tableIndex - 1].dwForwardDest); } break; case SNMP_PDU_SET:
1
0
0
0
Juan Lang : inetmib1: Support the MIB2 IP net (ARP) table.
by Alexandre Julliard
25 Jun '08
25 Jun '08
Module: wine Branch: master Commit: e5afadab3f88b99b7e43c1b179e026f0790e91a7 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=e5afadab3f88b99b7e43c1b17…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Wed Jun 25 09:34:40 2008 -0700 inetmib1: Support the MIB2 IP net (ARP) table. --- dlls/inetmib1/main.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 80 insertions(+), 0 deletions(-) diff --git a/dlls/inetmib1/main.c b/dlls/inetmib1/main.c index fd8d216..e7bb28e 100644 --- a/dlls/inetmib1/main.c +++ b/dlls/inetmib1/main.c @@ -765,6 +765,85 @@ static BOOL mib2IpRouteQuery(BYTE bPduType, SnmpVarBind *pVarBind, return TRUE; } +static UINT mib2IpNet[] = { 1,3,6,1,2,1,4,22,1 }; +static PMIB_IPNETTABLE ipNetTable; + +static struct structToAsnValue mib2IpNetMap[] = { + { FIELD_OFFSET(MIB_IPNETROW, dwIndex), copyInt }, + { FIELD_OFFSET(MIB_IPNETROW, dwPhysAddrLen), copyLengthPrecededString }, + { FIELD_OFFSET(MIB_IPNETROW, dwAddr), copyIpAddr }, + { FIELD_OFFSET(MIB_IPNETROW, dwType), copyInt }, +}; + +static void mib2IpNetInit(void) +{ + DWORD size = 0, ret = GetIpNetTable(NULL, &size, FALSE); + + if (ret == ERROR_INSUFFICIENT_BUFFER) + { + ipNetTable = HeapAlloc(GetProcessHeap(), 0, size); + if (ipNetTable) + GetIpNetTable(ipNetTable, &size, FALSE); + } +} + +static BOOL mib2IpNetQuery(BYTE bPduType, SnmpVarBind *pVarBind, + AsnInteger32 *pErrorStatus) +{ + AsnObjectIdentifier myOid = DEFINE_OID(mib2IpNet); + + TRACE("(0x%02x, %s, %p)\n", bPduType, SnmpUtilOidToA(&pVarBind->name), + pErrorStatus); + + switch (bPduType) + { + case SNMP_PDU_GET: + case SNMP_PDU_GETNEXT: + if (!ipNetTable) + *pErrorStatus = SNMP_ERRORSTATUS_NOSUCHNAME; + else + { + UINT tableIndex = 0, item = 0; + + *pErrorStatus = getItemAndIntegerInstanceFromOid(&pVarBind->name, + &myOid, bPduType, &item, &tableIndex); + if (!*pErrorStatus) + { + assert(tableIndex); + assert(item); + if (tableIndex > ipNetTable->dwNumEntries) + *pErrorStatus = SNMP_ERRORSTATUS_NOSUCHNAME; + else + { + *pErrorStatus = mapStructEntryToValue(mib2IpNetMap, + DEFINE_SIZEOF(mib2IpNetMap), + &ipNetTable[tableIndex - 1], item, bPduType, pVarBind); + if (!*pErrorStatus && bPduType == SNMP_PDU_GETNEXT) + { + AsnObjectIdentifier oid; + + SnmpUtilOidCpy(&pVarBind->name, &myOid); + oid.idLength = 1; + oid.ids = &item; + SnmpUtilOidAppend(&pVarBind->name, &oid); + oid.idLength = 1; + oid.ids = &tableIndex; + SnmpUtilOidAppend(&pVarBind->name, &oid); + } + } + } + } + break; + case SNMP_PDU_SET: + *pErrorStatus = SNMP_ERRORSTATUS_READONLY; + break; + default: + FIXME("0x%02x: unsupported PDU type\n", bPduType); + *pErrorStatus = SNMP_ERRORSTATUS_NOSUCHNAME; + } + return TRUE; +} + static UINT mib2Icmp[] = { 1,3,6,1,2,1,5 }; static MIB_ICMP icmpStats; @@ -916,6 +995,7 @@ static struct mibImplementation supportedIDs[] = { { DEFINE_OID(mib2Ip), mib2IpStatsInit, mib2IpStatsQuery }, { DEFINE_OID(mib2IpAddr), mib2IpAddrInit, mib2IpAddrQuery }, { DEFINE_OID(mib2IpRoute), mib2IpRouteInit, mib2IpRouteQuery }, + { DEFINE_OID(mib2IpNet), mib2IpNetInit, mib2IpNetQuery }, { DEFINE_OID(mib2Icmp), mib2IcmpInit, mib2IcmpQuery }, { DEFINE_OID(mib2Tcp), mib2TcpInit, mib2TcpQuery }, };
1
0
0
0
Juan Lang : inetmib1: Support the MIB2 IP route table.
by Alexandre Julliard
25 Jun '08
25 Jun '08
Module: wine Branch: master Commit: d3baf1dcdadc81d106bf89fe903c1dd949650f1b URL:
http://source.winehq.org/git/wine.git/?a=commit;h=d3baf1dcdadc81d106bf89fe9…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Wed Jun 25 09:33:28 2008 -0700 inetmib1: Support the MIB2 IP route table. --- dlls/inetmib1/main.c | 88 ++++++++++++++++++++++++++++++++++++++++++++ dlls/inetmib1/tests/main.c | 57 ++++++++++++++++++++++++++++ 2 files changed, 145 insertions(+), 0 deletions(-) diff --git a/dlls/inetmib1/main.c b/dlls/inetmib1/main.c index 110780b..fd8d216 100644 --- a/dlls/inetmib1/main.c +++ b/dlls/inetmib1/main.c @@ -678,6 +678,93 @@ static BOOL mib2IpAddrQuery(BYTE bPduType, SnmpVarBind *pVarBind, return TRUE; } +static UINT mib2IpRoute[] = { 1,3,6,1,2,1,4,21,1 }; +static PMIB_IPFORWARDTABLE ipRouteTable; + +static struct structToAsnValue mib2IpRouteMap[] = { + { FIELD_OFFSET(MIB_IPFORWARDROW, dwForwardDest), copyIpAddr }, + { FIELD_OFFSET(MIB_IPFORWARDROW, dwForwardIfIndex), copyInt }, + { FIELD_OFFSET(MIB_IPFORWARDROW, dwForwardMetric1), copyInt }, + { FIELD_OFFSET(MIB_IPFORWARDROW, dwForwardMetric2), copyInt }, + { FIELD_OFFSET(MIB_IPFORWARDROW, dwForwardMetric3), copyInt }, + { FIELD_OFFSET(MIB_IPFORWARDROW, dwForwardMetric4), copyInt }, + { FIELD_OFFSET(MIB_IPFORWARDROW, dwForwardNextHop), copyIpAddr }, + { FIELD_OFFSET(MIB_IPFORWARDROW, dwForwardType), copyInt }, + { FIELD_OFFSET(MIB_IPFORWARDROW, dwForwardProto), copyInt }, + { FIELD_OFFSET(MIB_IPFORWARDROW, dwForwardAge), copyInt }, + { FIELD_OFFSET(MIB_IPFORWARDROW, dwForwardMask), copyIpAddr }, + { FIELD_OFFSET(MIB_IPFORWARDROW, dwForwardMetric5), copyInt }, +}; + +static void mib2IpRouteInit(void) +{ + DWORD size = 0, ret = GetIpForwardTable(NULL, &size, FALSE); + + if (ret == ERROR_INSUFFICIENT_BUFFER) + { + ipRouteTable = HeapAlloc(GetProcessHeap(), 0, size); + if (ipRouteTable) + GetIpForwardTable(ipRouteTable, &size, FALSE); + } +} + +static BOOL mib2IpRouteQuery(BYTE bPduType, SnmpVarBind *pVarBind, + AsnInteger32 *pErrorStatus) +{ + AsnObjectIdentifier myOid = DEFINE_OID(mib2IpRoute); + UINT tableIndex = 0, item = 0; + + TRACE("(0x%02x, %s, %p)\n", bPduType, SnmpUtilOidToA(&pVarBind->name), + pErrorStatus); + + switch (bPduType) + { + case SNMP_PDU_GET: + case SNMP_PDU_GETNEXT: + *pErrorStatus = getItemAndIpAddressInstanceFromOid(&pVarBind->name, + &myOid, bPduType, (struct GenericTable *)ipRouteTable, + sizeof(MIB_IPFORWARDROW), + FIELD_OFFSET(MIB_IPFORWARDROW, dwForwardDest), &item, &tableIndex); + if (!*pErrorStatus) + { + assert(tableIndex); + assert(item); + *pErrorStatus = mapStructEntryToValue(mib2IpRouteMap, + DEFINE_SIZEOF(mib2IpRouteMap), + &ipRouteTable->table[tableIndex - 1], item, bPduType, pVarBind); + if (!*pErrorStatus && bPduType == SNMP_PDU_GETNEXT) + { + UINT id; + BYTE *ptr; + AsnObjectIdentifier oid; + + SnmpUtilOidCpy(&pVarBind->name, &myOid); + oid.idLength = 1; + oid.ids = &id; + id = item; + SnmpUtilOidAppend(&pVarBind->name, &oid); + for (ptr = + (BYTE *)&ipRouteTable->table[tableIndex - 1].dwForwardDest; + ptr < + (BYTE *)&ipRouteTable->table[tableIndex - 1].dwForwardDest + + sizeof(DWORD); ptr++) + { + id = *ptr; + SnmpUtilOidAppend(&pVarBind->name, &oid); + } + } + } + break; + case SNMP_PDU_SET: + *pErrorStatus = SNMP_ERRORSTATUS_READONLY; + break; + default: + FIXME("0x%02x: unsupported PDU type\n", bPduType); + *pErrorStatus = SNMP_ERRORSTATUS_NOSUCHNAME; + } + return TRUE; +} + static UINT mib2Icmp[] = { 1,3,6,1,2,1,5 }; static MIB_ICMP icmpStats; @@ -828,6 +915,7 @@ static struct mibImplementation supportedIDs[] = { { DEFINE_OID(mib2IfEntry), NULL, mib2IfEntryQuery }, { DEFINE_OID(mib2Ip), mib2IpStatsInit, mib2IpStatsQuery }, { DEFINE_OID(mib2IpAddr), mib2IpAddrInit, mib2IpAddrQuery }, + { DEFINE_OID(mib2IpRoute), mib2IpRouteInit, mib2IpRouteQuery }, { DEFINE_OID(mib2Icmp), mib2IcmpInit, mib2IcmpQuery }, { DEFINE_OID(mib2Tcp), mib2TcpInit, mib2TcpQuery }, }; diff --git a/dlls/inetmib1/tests/main.c b/dlls/inetmib1/tests/main.c index 4193d56..012d6d2 100644 --- a/dlls/inetmib1/tests/main.c +++ b/dlls/inetmib1/tests/main.c @@ -64,6 +64,7 @@ static void testQuery(void) UINT mib2IfAdminStatus[] = { 1,3,6,1,2,1,2,2,1,7 }; UINT mib2IfOperStatus[] = { 1,3,6,1,2,1,2,2,1,8 }; UINT mib2IpAddr[] = { 1,3,6,1,2,1,4,20,1,1 }; + UINT mib2IpRouteTable[] = { 1,3,6,1,2,1,4,21,1,1 }; SnmpVarBind vars[3], vars2[3]; UINT entry; @@ -299,6 +300,62 @@ static void testQuery(void) } } while (moreData); SnmpUtilVarBindFree(&vars2[0]); + + /* Check the type and OIDs of the IP route table */ + vars[0].name.idLength = DEFINE_SIZEOF(mib2IpRouteTable); + vars[0].name.ids = mib2IpRouteTable; + SnmpUtilOidCpy(&vars2[0].name, &vars[0].name); + vars2[0].value.asnType = 0; + list.len = 1; + list.list = vars2; + moreData = TRUE; + do { + ret = pQuery(SNMP_PDU_GETNEXT, &list, &error, &index); + ok(ret, "SnmpExtensionQuery failed: %d\n", GetLastError()); + ok(error == SNMP_ERRORSTATUS_NOERROR, + "expected SNMP_ERRORSTATUS_NOERROR, got %d\n", error); + ok(index == 0, "expected index 0, got %d\n", index); + if (!ret) + moreData = FALSE; + else if (error) + moreData = FALSE; + else if (SnmpUtilOidNCmp(&vars2[0].name, &vars[0].name, + vars[0].name.idLength)) + moreData = FALSE; + if (moreData) + { + /* Make sure the size of the OID is right. + * FIXME: don't know if IPv6 addrs are shared with this table. + * Don't think so, but I'm not certain. + */ + ok(vars2[0].name.idLength = vars[0].name.idLength + 4, + "expected length %d, got %d\n", vars[0].name.idLength + 4, + vars2[0].name.idLength); + /* Make sure the type is right */ + ok(vars2[0].value.asnType == ASN_IPADDRESS, + "expected type ASN_IPADDRESS, got %02x\n", + vars2[0].value.asnType); + if (vars2[0].value.asnType == ASN_IPADDRESS) + { + UINT i; + + /* The base OID for the route table, 1.3.6.1.2.1.4.21.1.1, is + * appended with the dest IP address of the entry. So e.g. a + * route entry for 224.0.0.0 is identified in MIB2 as + * 1.3.6.1.2.1.4.21.1.1.224.0.0.0 + */ + for (i = 0; i < vars2[0].value.asnValue.address.length; i++) + { + ok(vars2[0].value.asnValue.address.stream[i] == + vars2[0].name.ids[vars2[0].name.idLength - 4 + i], + "expected ident byte %d to be %d, got %d\n", i, + vars2[0].value.asnValue.address.stream[i], + vars2[0].name.ids[vars2[0].name.idLength - 4 + i]); + } + } + } + } while (moreData); + SnmpUtilVarBindFree(&vars2[0]); } START_TEST(main)
1
0
0
0
Juan Lang : inetmib1: Support the MIB2 TCP statistics.
by Alexandre Julliard
25 Jun '08
25 Jun '08
Module: wine Branch: master Commit: 74310cb0e38a8c6e8b24921458f83267d9e71caf URL:
http://source.winehq.org/git/wine.git/?a=commit;h=74310cb0e38a8c6e8b2492145…
Author: Juan Lang <juan.lang(a)gmail.com> Date: Wed Jun 25 09:31:56 2008 -0700 inetmib1: Support the MIB2 TCP statistics. --- dlls/inetmib1/main.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 67 insertions(+), 0 deletions(-) diff --git a/dlls/inetmib1/main.c b/dlls/inetmib1/main.c index b6dea35..110780b 100644 --- a/dlls/inetmib1/main.c +++ b/dlls/inetmib1/main.c @@ -756,6 +756,72 @@ static BOOL mib2IcmpQuery(BYTE bPduType, SnmpVarBind *pVarBind, return TRUE; } +static UINT mib2Tcp[] = { 1,3,6,1,2,1,6 }; +static MIB_TCPSTATS tcpStats; + +static void mib2TcpInit(void) +{ + GetTcpStatistics(&tcpStats); +} + +static struct structToAsnValue mib2TcpMap[] = { + { FIELD_OFFSET(MIB_TCPSTATS, dwRtoAlgorithm), copyInt }, + { FIELD_OFFSET(MIB_TCPSTATS, dwRtoMin), copyInt }, + { FIELD_OFFSET(MIB_TCPSTATS, dwRtoMax), copyInt }, + { FIELD_OFFSET(MIB_TCPSTATS, dwMaxConn), copyInt }, + { FIELD_OFFSET(MIB_TCPSTATS, dwActiveOpens), copyInt }, + { FIELD_OFFSET(MIB_TCPSTATS, dwPassiveOpens), copyInt }, + { FIELD_OFFSET(MIB_TCPSTATS, dwAttemptFails), copyInt }, + { FIELD_OFFSET(MIB_TCPSTATS, dwEstabResets), copyInt }, + { FIELD_OFFSET(MIB_TCPSTATS, dwCurrEstab), copyInt }, + { FIELD_OFFSET(MIB_TCPSTATS, dwInSegs), copyInt }, + { FIELD_OFFSET(MIB_TCPSTATS, dwOutSegs), copyInt }, + { FIELD_OFFSET(MIB_TCPSTATS, dwRetransSegs), copyInt }, + { FIELD_OFFSET(MIB_TCPSTATS, dwInErrs), copyInt }, + { FIELD_OFFSET(MIB_TCPSTATS, dwOutRsts), copyInt }, + { FIELD_OFFSET(MIB_TCPSTATS, dwNumConns), copyInt }, +}; + +static BOOL mib2TcpQuery(BYTE bPduType, SnmpVarBind *pVarBind, + AsnInteger32 *pErrorStatus) +{ + AsnObjectIdentifier myOid = DEFINE_OID(mib2Tcp); + UINT item = 0; + + TRACE("(0x%02x, %s, %p)\n", bPduType, SnmpUtilOidToA(&pVarBind->name), + pErrorStatus); + + switch (bPduType) + { + case SNMP_PDU_GET: + case SNMP_PDU_GETNEXT: + *pErrorStatus = getItemFromOid(&pVarBind->name, &myOid, bPduType, + &item); + if (!*pErrorStatus) + { + *pErrorStatus = mapStructEntryToValue(mib2TcpMap, + DEFINE_SIZEOF(mib2TcpMap), &tcpStats, item, bPduType, pVarBind); + if (!*pErrorStatus && bPduType == SNMP_PDU_GETNEXT) + { + AsnObjectIdentifier oid; + + SnmpUtilOidCpy(&pVarBind->name, &myOid); + oid.idLength = 1; + oid.ids = &item; + SnmpUtilOidAppend(&pVarBind->name, &oid); + } + } + break; + case SNMP_PDU_SET: + *pErrorStatus = SNMP_ERRORSTATUS_READONLY; + break; + default: + FIXME("0x%02x: unsupported PDU type\n", bPduType); + *pErrorStatus = SNMP_ERRORSTATUS_NOSUCHNAME; + } + return TRUE; +} + /* This list MUST BE lexicographically sorted */ static struct mibImplementation supportedIDs[] = { { DEFINE_OID(mib2IfNumber), mib2IfNumberInit, mib2IfNumberQuery }, @@ -763,6 +829,7 @@ static struct mibImplementation supportedIDs[] = { { DEFINE_OID(mib2Ip), mib2IpStatsInit, mib2IpStatsQuery }, { DEFINE_OID(mib2IpAddr), mib2IpAddrInit, mib2IpAddrQuery }, { DEFINE_OID(mib2Icmp), mib2IcmpInit, mib2IcmpQuery }, + { DEFINE_OID(mib2Tcp), mib2TcpInit, mib2TcpQuery }, }; static UINT minSupportedIDLength;
1
0
0
0
← Newer
1
...
16
17
18
19
20
21
22
...
95
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
Results per page:
10
25
50
100
200