ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Net-SNMP-XS/XS.xs
(Generate patch)

Comparing Net-SNMP-XS/XS.xs (file contents):
Revision 1.6 by root, Thu Apr 9 05:56:36 2009 UTC vs.
Revision 1.7 by root, Thu Apr 9 07:10:23 2009 UTC

1#include "EXTERN.h" 1#include "EXTERN.h"
2#include "perl.h" 2#include "perl.h"
3#include "XSUB.h" 3#include "XSUB.h"
4 4
5// C99 required 5// C99 required
6
7#define BENCHMARK
6 8
7#define ASN_BOOLEAN 0x01 9#define ASN_BOOLEAN 0x01
8#define ASN_INTEGER32 0x02 10#define ASN_INTEGER32 0x02
9#define ASN_OCTET_STRING 0x04 11#define ASN_OCTET_STRING 0x04
10#define ASN_NULL 0x05 12#define ASN_NULL 0x05
15#define ASN_UNSIGNED32 0x42 17#define ASN_UNSIGNED32 0x42
16#define ASN_TIMETICKS 0x43 18#define ASN_TIMETICKS 0x43
17#define ASN_OPAQUE 0x44 19#define ASN_OPAQUE 0x44
18#define ASN_COUNTER64 0x46 20#define ASN_COUNTER64 0x46
19 21
20//#define BENCHMARK
21
22#define MAX_OID_STRLEN 4096 22#define MAX_OID_STRLEN 4096
23 23
24static SV *msg; 24static SV *msg;
25static int errflag, leading_dot; 25static int errflag, leading_dot;
26static U8 *buf, *cur; 26static U8 *buf, *cur;
210 buf += sprintf (buf, "%u", (unsigned int)u); 210 buf += sprintf (buf, "%u", (unsigned int)u);
211 211
212 return buf; 212 return buf;
213} 213}
214 214
215static char * 215static SV *
216process_object_identifier (int *len) 216process_object_identifier_sv (void)
217{ 217{
218 U32 length = process_length (); 218 U32 length = process_length ();
219 219
220 if (length <= 0) 220 if (length <= 0)
221 { 221 {
240 w = getb (); 240 w = getb ();
241 *app++ = '.'; 241 *app++ = '.';
242 app = write_uv (app, w); 242 app = write_uv (app, w);
243 } 243 }
244 244
245 *len = app - oid;
246 return oid;
247}
248
249static SV *
250process_object_identifier_sv (void)
251{
252 int len;
253 char *oid = process_object_identifier (&len);
254
255 return newSVpvn (oid, len); 245 return newSVpvn (oid, app - oid);
256} 246}
257 247
258static AV *av_type; 248static AV *av_type;
259 249
260static SV * 250static SV *
490 process_length (); 480 process_length ();
491 481
492 if (get8 () != ASN_OBJECT_IDENTIFIER) 482 if (get8 () != ASN_OBJECT_IDENTIFIER)
493 error ("OBJECT IDENTIFIER expected at beginning of VarBind"); 483 error ("OBJECT IDENTIFIER expected at beginning of VarBind");
494 int type, oidlen; 484 int type, oidlen;
495 char *oid = process_object_identifier (&oidlen); 485 SV *oid = process_object_identifier_sv ();
496 SV *val = process_sv (&type); 486 SV *val = process_sv (&type);
497 487
498 hv_store (types, oid, oidlen, newSViv (type), 0); 488 hv_store_ent (types, oid, newSViv (type), 0);
499 hv_store (list , oid, oidlen, val, 0); 489 hv_store_ent (list , oid, val, 0);
500 av_push (names, newSVpvn (oid, oidlen)); 490 av_push (names, oid);
501 } 491 }
502 492
503 //return $this->_report_pdu_error if ($this->{_pdu_type} == REPORT); 493 //return $this->_report_pdu_error if ($this->{_pdu_type} == REPORT);
504 494
505 RETVAL = newRV_inc ((SV *)list); 495 RETVAL = newRV_inc ((SV *)list);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines