ReactOS 0.4.15-dev-7897-g78dc504
main.c File Reference
#include <stdio.h>
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "snmp.h"
#include "wine/debug.h"
Include dependency graph for main.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (snmpapi)
 
static INT asn_any_copy (AsnAny *dst, const AsnAny *src)
 
static void asn_any_free (AsnAny *any)
 
BOOL WINAPI DllMain (HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
 
DWORD WINAPI SnmpSvcGetUptime (void)
 
VOID WINAPIV SnmpUtilDbgPrint (INT loglevel, LPSTR format,...)
 
LPVOID WINAPI SnmpUtilMemAlloc (UINT nbytes)
 
LPVOID WINAPI SnmpUtilMemReAlloc (LPVOID mem, UINT nbytes)
 
VOID WINAPI SnmpUtilMemFree (LPVOID mem)
 
INT WINAPI SnmpUtilAsnAnyCpy (AsnAny *dst, AsnAny *src)
 
VOID WINAPI SnmpUtilAsnAnyFree (AsnAny *any)
 
INT WINAPI SnmpUtilOctetsCpy (AsnOctetString *dst, AsnOctetString *src)
 
VOID WINAPI SnmpUtilOctetsFree (AsnOctetString *octets)
 
INT WINAPI SnmpUtilOctetsNCmp (AsnOctetString *octets1, AsnOctetString *octets2, UINT count)
 
INT WINAPI SnmpUtilOctetsCmp (AsnOctetString *octets1, AsnOctetString *octets2)
 
INT WINAPI SnmpUtilOidAppend (AsnObjectIdentifier *dst, AsnObjectIdentifier *src)
 
INT WINAPI SnmpUtilOidCpy (AsnObjectIdentifier *dst, AsnObjectIdentifier *src)
 
VOID WINAPI SnmpUtilOidFree (AsnObjectIdentifier *oid)
 
INT WINAPI SnmpUtilOidNCmp (AsnObjectIdentifier *oid1, AsnObjectIdentifier *oid2, UINT count)
 
INT WINAPI SnmpUtilOidCmp (AsnObjectIdentifier *oid1, AsnObjectIdentifier *oid2)
 
INT WINAPI SnmpUtilVarBindCpy (SnmpVarBind *dst, SnmpVarBind *src)
 
VOID WINAPI SnmpUtilVarBindFree (SnmpVarBind *vb)
 
INT WINAPI SnmpUtilVarBindListCpy (SnmpVarBindList *dst, SnmpVarBindList *src)
 
VOID WINAPI SnmpUtilVarBindListFree (SnmpVarBindList *vb)
 
LPSTR WINAPI SnmpUtilIdsToA (UINT *ids, UINT length)
 
LPSTR WINAPI SnmpUtilOidToA (AsnObjectIdentifier *oid)
 
VOID WINAPI SnmpUtilPrintOid (AsnObjectIdentifier *oid)
 
VOID WINAPI SnmpUtilPrintAsnAny (AsnAny *any)
 

Variables

static ULONGLONG startTime
 

Function Documentation

◆ asn_any_copy()

static INT asn_any_copy ( AsnAny dst,
const AsnAny src 
)
static

Definition at line 33 of file main.c.

34{
35 memset(dst, 0, sizeof(AsnAny));
36 switch (src->asnType)
37 {
38 case ASN_INTEGER32: dst->asnValue.number = src->asnValue.number; break;
39 case ASN_UNSIGNED32: dst->asnValue.unsigned32 = src->asnValue.unsigned32; break;
40 case ASN_COUNTER64: dst->asnValue.counter64 = src->asnValue.counter64; break;
41 case ASN_COUNTER32: dst->asnValue.counter = src->asnValue.counter; break;
42 case ASN_GAUGE32: dst->asnValue.gauge = src->asnValue.gauge; break;
43 case ASN_TIMETICKS: dst->asnValue.ticks = src->asnValue.ticks; break;
44
45 case ASN_OCTETSTRING:
46 case ASN_BITS:
47 case ASN_SEQUENCE:
48 case ASN_IPADDRESS:
49 case ASN_OPAQUE:
50 {
51 BYTE *stream;
52 UINT length = src->asnValue.string.length;
53
54 if (!(stream = HeapAlloc(GetProcessHeap(), 0, length))) return SNMPAPI_ERROR;
55 memcpy(stream, src->asnValue.string.stream, length);
56
57 dst->asnValue.string.stream = stream;
58 dst->asnValue.string.length = length;
59 dst->asnValue.string.dynamic = TRUE;
60 break;
61 }
63 {
64 UINT *ids, i, size = src->asnValue.object.idLength * sizeof(UINT);
65
66 if (!(ids = HeapAlloc(GetProcessHeap(), 0, size))) return SNMPAPI_ERROR;
67
68 dst->asnValue.object.ids = ids;
69 dst->asnValue.object.idLength = src->asnValue.object.idLength;
70
71 for (i = 0; i < dst->asnValue.object.idLength; i++)
72 dst->asnValue.object.ids[i] = src->asnValue.object.ids[i];
73 break;
74 }
75 default:
76 {
77 WARN("unknown ASN type: %d\n", src->asnType);
78 return SNMPAPI_ERROR;
79 }
80 }
81 dst->asnType = src->asnType;
82 return SNMPAPI_NOERROR;
83}
#define WARN(fmt,...)
Definition: debug.h:112
#define TRUE
Definition: types.h:120
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
GLsizeiptr size
Definition: glext.h:5919
GLenum src
Definition: glext.h:6340
GLuint * ids
Definition: glext.h:5907
GLenum GLenum dst
Definition: glext.h:6340
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned int UINT
Definition: ndis.h:50
#define ASN_BITS
Definition: snmp.h:104
#define ASN_TIMETICKS
Definition: snmp.h:116
#define ASN_OCTETSTRING
Definition: snmp.h:105
#define ASN_UNSIGNED32
Definition: snmp.h:119
#define ASN_SEQUENCE
Definition: snmp.h:110
#define ASN_OPAQUE
Definition: snmp.h:117
#define ASN_COUNTER32
Definition: snmp.h:114
#define ASN_COUNTER64
Definition: snmp.h:118
#define SNMPAPI_ERROR
Definition: snmp.h:205
#define SNMPAPI_NOERROR
Definition: snmp.h:204
#define ASN_GAUGE32
Definition: snmp.h:115
#define ASN_OBJECTIDENTIFIER
Definition: snmp.h:107
#define ASN_INTEGER32
Definition: snmp.h:108
#define ASN_IPADDRESS
Definition: snmp.h:113
#define memset(x, y, z)
Definition: compat.h:39
Definition: snmp.h:54
Definition: parse.h:23
unsigned char BYTE
Definition: xxhash.c:193

Referenced by SnmpUtilAsnAnyCpy(), and SnmpUtilVarBindCpy().

◆ asn_any_free()

static void asn_any_free ( AsnAny any)
static

Definition at line 85 of file main.c.

86{
87 switch (any->asnType)
88 {
89 case ASN_OCTETSTRING:
90 case ASN_BITS:
91 case ASN_SEQUENCE:
92 case ASN_IPADDRESS:
93 case ASN_OPAQUE:
94 {
95 if (any->asnValue.string.dynamic)
96 {
99 }
100 break;
101 }
103 {
105 any->asnValue.object.ids = NULL;
106 break;
107 }
108 default: break;
109 }
110 any->asnType = ASN_NULL;
111}
#define NULL
Definition: types.h:112
#define HeapFree(x, y, z)
Definition: compat.h:735
#define ASN_NULL
Definition: snmp.h:106
BYTE asnType
Definition: snmp.h:55
AsnObjectIdentifier object
Definition: snmp.h:62
AsnOctetString string
Definition: snmp.h:60
union AsnAny::@3238 asnValue
UINT * ids
Definition: snmp.h:37
BOOL dynamic
Definition: snmp.h:32
BYTE * stream
Definition: snmp.h:30

Referenced by SnmpUtilAsnAnyFree(), and SnmpUtilVarBindFree().

◆ DllMain()

BOOL WINAPI DllMain ( HINSTANCE  hInstDLL,
DWORD  fdwReason,
LPVOID  lpvReserved 
)

Definition at line 118 of file main.c.

122{
123 TRACE("(%p,%d,%p)\n", hInstDLL, fdwReason, lpvReserved);
124
125 switch(fdwReason) {
126 case DLL_WINE_PREATTACH:
127 return FALSE; /* prefer native version */
131 break;
132 }
133
134 return TRUE;
135}
ULONGLONG WINAPI GetTickCount64(VOID)
Definition: GetTickCount64.c:9
#define FALSE
Definition: types.h:117
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
static ULONGLONG startTime
Definition: main.c:113
static IN DWORD IN LPVOID lpvReserved
#define TRACE(s)
Definition: solgame.cpp:4

◆ SnmpSvcGetUptime()

DWORD WINAPI SnmpSvcGetUptime ( void  )

Definition at line 145 of file main.c.

146{
148
149 return (now - startTime) / 10;
150}
time_t now
Definition: finger.c:65
uint64_t ULONGLONG
Definition: typedefs.h:67

◆ SnmpUtilAsnAnyCpy()

INT WINAPI SnmpUtilAsnAnyCpy ( AsnAny dst,
AsnAny src 
)

Definition at line 197 of file main.c.

198{
199 TRACE("(%p, %p)\n", dst, src);
200 return asn_any_copy(dst, src);
201}
static INT asn_any_copy(AsnAny *dst, const AsnAny *src)
Definition: main.c:33

Referenced by InitFunctionPtrs(), and setStringValue().

◆ SnmpUtilAsnAnyFree()

VOID WINAPI SnmpUtilAsnAnyFree ( AsnAny any)

Definition at line 206 of file main.c.

207{
208 TRACE("(%p)\n", any);
209 asn_any_free(any);
210}
static void asn_any_free(AsnAny *any)
Definition: main.c:85

Referenced by InitFunctionPtrs().

◆ SnmpUtilDbgPrint()

VOID WINAPIV SnmpUtilDbgPrint ( INT  loglevel,
LPSTR  format,
  ... 
)

Definition at line 162 of file main.c.

163{
164 FIXME("(%d, %s)\n", loglevel, debugstr_a(format));
165}
#define FIXME(fmt,...)
Definition: debug.h:111
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define debugstr_a
Definition: kernel32.h:31

◆ SnmpUtilIdsToA()

LPSTR WINAPI SnmpUtilIdsToA ( UINT ids,
UINT  length 
)

Definition at line 497 of file main.c.

498{
499 static char one[10], oid[514], null_oid[] = "<null oid>";
500 unsigned int i, len, left = sizeof(oid) - 1;
501
502 TRACE("(%p, %d)\n", ids, length);
503
504 if (!ids || !length) return null_oid;
505
506 *oid = 0;
507 for (i = 0; i < length; i++)
508 {
509 sprintf(one, "%d", ids[i]);
510 len = strlen(one);
511 if (left >= len)
512 {
513 strcat(oid, one);
514 left -= len;
515 }
516 else return oid;
517
518 if (i < length - 1)
519 {
520 if (left > 0)
521 {
522 strcat(oid, ".");
523 left--;
524 }
525 else return oid;
526 }
527 }
528 return oid;
529}
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLint left
Definition: glext.h:7726
GLenum GLsizei len
Definition: glext.h:6722
#define sprintf(buf, format,...)
Definition: sprintf.c:55
int one
Definition: sehframes.cpp:28

Referenced by SnmpUtilOidToA().

◆ SnmpUtilMemAlloc()

LPVOID WINAPI SnmpUtilMemAlloc ( UINT  nbytes)

Definition at line 170 of file main.c.

171{
172 TRACE("(%d)\n", nbytes);
173 return HeapAlloc(GetProcessHeap(), 0, nbytes);
174}

Referenced by test_SnmpUtilOidAppend().

◆ SnmpUtilMemFree()

VOID WINAPI SnmpUtilMemFree ( LPVOID  mem)

Definition at line 188 of file main.c.

189{
190 TRACE("(%p)\n", mem);
192}
Definition: mem.c:156

◆ SnmpUtilMemReAlloc()

LPVOID WINAPI SnmpUtilMemReAlloc ( LPVOID  mem,
UINT  nbytes 
)

Definition at line 179 of file main.c.

180{
181 TRACE("(%p, %d)\n", mem, nbytes);
182 return HeapReAlloc(GetProcessHeap(), 0, mem, nbytes);
183}
#define HeapReAlloc
Definition: compat.h:734

◆ SnmpUtilOctetsCmp()

INT WINAPI SnmpUtilOctetsCmp ( AsnOctetString octets1,
AsnOctetString octets2 
)

Definition at line 276 of file main.c.

277{
278 TRACE("(%p, %p)\n", octets1, octets2);
279
280 if (octets1->length < octets2->length) return -1;
281 if (octets1->length > octets2->length) return 1;
282
283 return SnmpUtilOctetsNCmp(octets1, octets2, octets1->length);
284}
INT WINAPI SnmpUtilOctetsNCmp(AsnOctetString *octets1, AsnOctetString *octets2, UINT count)
Definition: main.c:258
UINT length
Definition: snmp.h:31

Referenced by InitFunctionPtrs().

◆ SnmpUtilOctetsCpy()

INT WINAPI SnmpUtilOctetsCpy ( AsnOctetString dst,
AsnOctetString src 
)

Definition at line 215 of file main.c.

216{
217 TRACE("(%p, %p)\n", dst, src);
218
219 if (!dst) return SNMPAPI_ERROR;
220 if (!src)
221 {
222 dst->dynamic = FALSE;
223 dst->length = 0;
224 dst->stream = NULL;
225 return SNMPAPI_NOERROR;
226 }
227 if ((dst->stream = HeapAlloc(GetProcessHeap(), 0, src->length)))
228 {
229 unsigned int i;
230
231 dst->dynamic = TRUE;
232 dst->length = src->length;
233 for (i = 0; i < dst->length; i++) dst->stream[i] = src->stream[i];
234 return SNMPAPI_NOERROR;
235 }
236 return SNMPAPI_ERROR;
237}

Referenced by InitFunctionPtrs().

◆ SnmpUtilOctetsFree()

VOID WINAPI SnmpUtilOctetsFree ( AsnOctetString octets)

Definition at line 242 of file main.c.

243{
244 TRACE("(%p)\n", octets);
245
246 if (octets)
247 {
248 octets->length = 0;
249 if (octets->dynamic) HeapFree(GetProcessHeap(), 0, octets->stream);
250 octets->stream = NULL;
251 octets->dynamic = FALSE;
252 }
253}

Referenced by InitFunctionPtrs().

◆ SnmpUtilOctetsNCmp()

INT WINAPI SnmpUtilOctetsNCmp ( AsnOctetString octets1,
AsnOctetString octets2,
UINT  count 
)

Definition at line 258 of file main.c.

259{
260 INT ret;
261 unsigned int i;
262
263 TRACE("(%p, %p, %d)\n", octets1, octets2, count);
264
265 if (!octets1 || !octets2) return 0;
266
267 for (i = 0; i < count; i++)
268 if ((ret = octets1->stream[i] - octets2->stream[i])) return ret;
269
270 return 0;
271}
GLuint GLuint GLsizei count
Definition: gl.h:1545
int32_t INT
Definition: typedefs.h:58
int ret

Referenced by InitFunctionPtrs(), and SnmpUtilOctetsCmp().

◆ SnmpUtilOidAppend()

INT WINAPI SnmpUtilOidAppend ( AsnObjectIdentifier dst,
AsnObjectIdentifier src 
)

Definition at line 289 of file main.c.

290{
291 UINT *ids, i, size;
292
293 TRACE("(%p, %p)\n", dst, src);
294
295 if (!dst) return SNMPAPI_ERROR;
296 if (!src) return SNMPAPI_NOERROR;
297
298 size = (src->idLength + dst->idLength) * sizeof(UINT);
299 if (!(ids = HeapReAlloc(GetProcessHeap(), 0, dst->ids, size)))
300 {
301 if (!(ids = HeapAlloc(GetProcessHeap(), 0, size)))
302 {
304 return SNMPAPI_ERROR;
305 }
306 else memcpy(ids, dst->ids, dst->idLength * sizeof(UINT));
307 }
308
309 for (i = 0; i < src->idLength; i++) ids[i + dst->idLength] = src->ids[i];
310 dst->idLength = dst->idLength + src->idLength;
311 dst->ids = ids;
312
313 return SNMPAPI_NOERROR;
314}
#define SetLastError(x)
Definition: compat.h:752
#define SNMP_MEM_ALLOC_ERROR
Definition: snmp.h:191

Referenced by mib2UdpEntryQuery(), setOidWithItem(), setOidWithItemAndInteger(), setOidWithItemAndIpAddr(), and test_SnmpUtilOidAppend().

◆ SnmpUtilOidCmp()

INT WINAPI SnmpUtilOidCmp ( AsnObjectIdentifier oid1,
AsnObjectIdentifier oid2 
)

Definition at line 382 of file main.c.

383{
384 TRACE("(%p, %p)\n", oid1, oid2);
385
386 if (oid1->idLength < oid2->idLength) return -1;
387 if (oid1->idLength > oid2->idLength) return 1;
388
389 return SnmpUtilOidNCmp(oid1, oid2, oid1->idLength);
390}
INT WINAPI SnmpUtilOidNCmp(AsnObjectIdentifier *oid1, AsnObjectIdentifier *oid2, UINT count)
Definition: main.c:358
static char oid1[]
Definition: encode.c:7583

Referenced by test_SnmpUtilOidCmp(), and testQuery().

◆ SnmpUtilOidCpy()

INT WINAPI SnmpUtilOidCpy ( AsnObjectIdentifier dst,
AsnObjectIdentifier src 
)

Definition at line 319 of file main.c.

320{
321 TRACE("(%p, %p)\n", dst, src);
322
323 if (!dst) return SNMPAPI_ERROR;
324 if (!src)
325 {
326 dst->idLength = 0;
327 dst->ids = NULL;
328 return SNMPAPI_NOERROR;
329 }
330 if ((dst->ids = HeapAlloc(GetProcessHeap(), 0, src->idLength * sizeof(UINT))))
331 {
332 unsigned int i;
333
334 dst->idLength = src->idLength;
335 for (i = 0; i < dst->idLength; i++) dst->ids[i] = src->ids[i];
336 return SNMPAPI_NOERROR;
337 }
338 return SNMPAPI_ERROR;
339}

Referenced by mib2IfNumberQuery(), setOidWithItem(), SnmpExtensionInit(), SnmpExtensionQuery(), test_SnmpUtilOidCpyFree(), and testQuery().

◆ SnmpUtilOidFree()

VOID WINAPI SnmpUtilOidFree ( AsnObjectIdentifier oid)

Definition at line 344 of file main.c.

345{
346 TRACE("(%p)\n", oid);
347
348 if (!oid) return;
349
350 oid->idLength = 0;
351 HeapFree(GetProcessHeap(), 0, oid->ids);
352 oid->ids = NULL;
353}

Referenced by mib2IfNumberQuery(), setOidWithItem(), SnmpExtensionQuery(), test_SnmpUtilOidAppend(), test_SnmpUtilOidCpyFree(), and testInit().

◆ SnmpUtilOidNCmp()

INT WINAPI SnmpUtilOidNCmp ( AsnObjectIdentifier oid1,
AsnObjectIdentifier oid2,
UINT  count 
)

Definition at line 358 of file main.c.

359{
360 unsigned int i, len;
361
362 TRACE("(%p, %p, %d)\n", oid1, oid2, count);
363
364 if (!oid1 || !oid2) return 0;
365
366 len = min(count, oid1->idLength);
367 len = min(len, oid2->idLength);
368 for (i = 0; i < len; i++)
369 {
370 if (oid1->ids[i] > oid2->ids[i]) return 1;
371 if (oid1->ids[i] < oid2->ids[i]) return -1;
372 }
373 if (i == count) return 0;
374 if (oid1->idLength < oid2->idLength) return -1;
375 if (oid1->idLength > oid2->idLength) return 1;
376 return 0;
377}
#define min(a, b)
Definition: monoChain.cc:55

Referenced by findSupportedQuery(), getItemAndInstanceFromTable(), getItemAndIntegerInstanceFromOid(), getItemFromOid(), mib2IfNumberQuery(), SnmpExtensionQuery(), SnmpUtilOidCmp(), test_SnmpUtilOidNCmp(), and testQuery().

◆ SnmpUtilOidToA()

LPSTR WINAPI SnmpUtilOidToA ( AsnObjectIdentifier oid)

Definition at line 534 of file main.c.

535{
536 static char null_oid[] = "<null oid>";
537
538 TRACE("(%p)\n", oid);
539
540 if (oid)
541 return SnmpUtilIdsToA(oid->ids, oid->idLength);
542 else
543 return null_oid;
544}
LPSTR WINAPI SnmpUtilIdsToA(UINT *ids, UINT length)
Definition: main.c:497

Referenced by mib2IcmpQuery(), mib2IfEntryQuery(), mib2IfNumberQuery(), mib2IpAddrQuery(), mib2IpNetQuery(), mib2IpRouteQuery(), mib2IpStatsQuery(), mib2TcpQuery(), mib2UdpEntryQuery(), mib2UdpQuery(), SnmpExtensionQuery(), test_SnmpUtilOidToA(), testInit(), and testQuery().

◆ SnmpUtilPrintAsnAny()

VOID WINAPI SnmpUtilPrintAsnAny ( AsnAny any)

Definition at line 568 of file main.c.

569{
570 unsigned int i;
571
572 TRACE("(%p)\n", any);
573
574 switch (any->asnType)
575 {
576 case ASN_NULL: TRACE("Null value\n"); return;
577 case ASN_INTEGER32: TRACE("Integer32 %d\n", any->asnValue.number); return;
578 case ASN_UNSIGNED32: TRACE("Unsigned32 %u\n", any->asnValue.unsigned32); return;
579 case ASN_COUNTER32: TRACE("Counter32 %u\n", any->asnValue.counter); return;
580 case ASN_GAUGE32: TRACE("Gauge32 %u\n", any->asnValue.gauge); return;
581 case ASN_TIMETICKS: TRACE("Timeticks %u\n", any->asnValue.ticks); return;
582 case ASN_COUNTER64:
583 {
584 TRACE("Counter64 %x%08x\n", (DWORD)(any->asnValue.counter64.QuadPart>>32),(DWORD)any->asnValue.counter64.QuadPart);
585 return;
586 }
587 case ASN_OCTETSTRING:
588 {
589 TRACE("String ");
590 for (i = 0; i < any->asnValue.string.length; i++)
591 TRACE("%c", any->asnValue.string.stream[i]);
592 TRACE("\n");
593 return;
594 }
595 case ASN_IPADDRESS:
596 {
597 TRACE("IpAddress ");
598 if (any->asnValue.string.length < 4)
599 {
600 TRACE("Invalid\n");
601 return;
602 }
603 for (i = 0; i < 4; i++)
604 {
605 TRACE("%u", any->asnValue.string.stream[i]);
606 if (i < 3) TRACE(".");
607 }
608 TRACE("\n");
609 return;
610 }
611 case ASN_BITS:
612 {
613 TRACE("Bits ");
614 for (i = 0; i < any->asnValue.string.length; i++)
615 {
616 TRACE("0x%02x", any->asnValue.string.stream[i]);
617 if (i < any->asnValue.object.idLength - 1) TRACE(" ");
618 }
619 TRACE("\n");
620 return;
621 }
622 case ASN_OPAQUE:
623 {
624 TRACE("Opaque ");
625 for (i = 0; i < any->asnValue.string.length; i++)
626 {
627 TRACE("0x%02x", any->asnValue.string.stream[i]);
628 if (i < any->asnValue.object.idLength - 1) TRACE(" ");
629 }
630 TRACE("\n");
631 return;
632 }
634 {
635 TRACE("ObjectID ");
636 for (i = 0; i < any->asnValue.object.idLength; i++)
637 {
638 TRACE("%u", any->asnValue.object.ids[i]);
639 if (i < any->asnValue.object.idLength - 1) TRACE(".");
640 }
641 TRACE("\n");
642 return;
643 }
644 default:
645 {
646 TRACE("Invalid type %d\n", any->asnType);
647 return;
648 }
649 }
650}
unsigned long DWORD
Definition: ntddk_ex.h:95
AsnCounter64 counter64
Definition: snmp.h:59
AsnGauge32 gauge
Definition: snmp.h:66
AsnTimeticks ticks
Definition: snmp.h:67
AsnCounter32 counter
Definition: snmp.h:65
AsnInteger32 number
Definition: snmp.h:57
AsnUnsigned32 unsigned32
Definition: snmp.h:58
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185

◆ SnmpUtilPrintOid()

VOID WINAPI SnmpUtilPrintOid ( AsnObjectIdentifier oid)

Definition at line 549 of file main.c.

550{
551 unsigned int i;
552
553 TRACE("(%p)\n", oid);
554
555 if (!oid) return;
556
557 for (i = 0; i < oid->idLength; i++)
558 {
559 TRACE("%u", oid->ids[i]);
560 if (i < oid->idLength - 1) TRACE(".");
561 }
562 TRACE("\n");
563}

◆ SnmpUtilVarBindCpy()

INT WINAPI SnmpUtilVarBindCpy ( SnmpVarBind dst,
SnmpVarBind src 
)

Definition at line 395 of file main.c.

396{
397 unsigned int i, size;
398
399 TRACE("(%p, %p)\n", dst, src);
400
401 if (!dst) return SNMPAPI_ERROR;
402 if (!src)
403 {
404 dst->value.asnType = ASN_NULL;
405 return SNMPAPI_NOERROR;
406 }
407
408 size = src->name.idLength * sizeof(UINT);
409 if (!(dst->name.ids = HeapAlloc(GetProcessHeap(), 0, size))) return SNMPAPI_ERROR;
410
411 for (i = 0; i < src->name.idLength; i++) dst->name.ids[i] = src->name.ids[i];
412 dst->name.idLength = src->name.idLength;
413
414 if (!asn_any_copy(&dst->value, &src->value))
415 {
416 HeapFree(GetProcessHeap(), 0, dst->name.ids);
417 return SNMPAPI_ERROR;
418 }
419 return SNMPAPI_NOERROR;
420}
if(dx< 0)
Definition: linetemp.h:194
char * value
Definition: compiler.c:67
char * name
Definition: compiler.c:66

Referenced by SnmpUtilVarBindListCpy(), and test_SnmpUtilVarBindCpyFree().

◆ SnmpUtilVarBindFree()

VOID WINAPI SnmpUtilVarBindFree ( SnmpVarBind vb)

Definition at line 425 of file main.c.

426{
427 TRACE("(%p)\n", vb);
428
429 if (!vb) return;
430
431 asn_any_free(&vb->value);
432 HeapFree(GetProcessHeap(), 0, vb->name.ids);
433 vb->name.idLength = 0;
434 vb->name.ids = NULL;
435}
AsnObjectName name
Definition: snmp.h:76
AsnObjectSyntax value
Definition: snmp.h:77

Referenced by SnmpUtilVarBindListCpy(), SnmpUtilVarBindListFree(), test_SnmpUtilVarBindCpyFree(), and testQuery().

◆ SnmpUtilVarBindListCpy()

INT WINAPI SnmpUtilVarBindListCpy ( SnmpVarBindList dst,
SnmpVarBindList src 
)

Definition at line 440 of file main.c.

441{
442 unsigned int i, size;
443 SnmpVarBind *src_entry, *dst_entry;
444
445 TRACE("(%p, %p)\n", dst, src);
446
447 if (!src)
448 {
449 dst->list = NULL;
450 dst->len = 0;
451 return SNMPAPI_NOERROR;
452 }
453 size = src->len * sizeof(SnmpVarBind);
454 if (!(dst->list = HeapAlloc(GetProcessHeap(), 0, size)))
455 return SNMPAPI_ERROR;
456
457 src_entry = src->list;
458 dst_entry = dst->list;
459 for (i = 0; i < src->len; i++)
460 {
461 if (SnmpUtilVarBindCpy(dst_entry, src_entry))
462 {
463 src_entry++;
464 dst_entry++;
465 }
466 else
467 {
468 for (--i; i > 0; i--) SnmpUtilVarBindFree(--dst_entry);
469 HeapFree(GetProcessHeap(), 0, dst->list);
470 return SNMPAPI_ERROR;
471 }
472 }
473 dst->len = src->len;
474 return SNMPAPI_NOERROR;
475}
INT WINAPI SnmpUtilVarBindCpy(SnmpVarBind *dst, SnmpVarBind *src)
Definition: main.c:395
VOID WINAPI SnmpUtilVarBindFree(SnmpVarBind *vb)
Definition: main.c:425
Definition: tcpcore.h:1673

Referenced by test_SnmpUtilVarBindListCpyFree().

◆ SnmpUtilVarBindListFree()

VOID WINAPI SnmpUtilVarBindListFree ( SnmpVarBindList vb)

Definition at line 480 of file main.c.

481{
482 unsigned int i;
484
485 TRACE("(%p)\n", vb);
486
487 entry = vb->list;
488 for (i = 0; i < vb->len; i++) SnmpUtilVarBindFree(entry++);
489 HeapFree(GetProcessHeap(), 0, vb->list);
490 vb->list = NULL;
491 vb->len = 0;
492}
uint32_t entry
Definition: isohybrid.c:63
SnmpVarBind * list
Definition: snmp.h:81
UINT len
Definition: snmp.h:82

Referenced by test_SnmpUtilVarBindListCpyFree().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( snmpapi  )

Variable Documentation

◆ startTime