From 812274918a9a67c0011341de17609a32ee2f582c Mon Sep 17 00:00:00 2001 From: Graeme Lunt Date: Mon, 28 Jun 2010 09:30:15 +0000 Subject: Introduce an Object Identifier field macro, together with an appropriate field check routine. Also, a field type which is an enumerated string value. svn path=/trunk/; revision=33343 --- epan/uat.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'epan/uat.c') diff --git a/epan/uat.c b/epan/uat.c index e93ed311d3..e6d72a3247 100644 --- a/epan/uat.c +++ b/epan/uat.c @@ -398,6 +398,31 @@ gboolean uat_fld_chk_str(void* u1 _U_, const char* strptr, unsigned len _U_, con return TRUE; } +gboolean uat_fld_chk_oid(void* u1 _U_, const char* strptr, unsigned len, const void* u2 _U_, const void* u3 _U_, const char** err) { + unsigned int i; + *err = NULL; + + if (strptr == NULL) { + *err = "NULL pointer"; + } + + for(i = 0; i < len; i++) + if(!(isdigit(strptr[i]) || strptr[i] == '.')) { + *err = "Only digits [0-9] and \".\" allowed in an OID"; + break; + } + + if(strptr[len-1] == '.') + *err = "OIDs must not be terminated with a \".\""; + + if(!((*strptr == '0' || *strptr == '1' || *strptr =='2') && (len > 1 && strptr[1] == '.'))) + *err = "OIDs must start with \"0.\" (ITU-T assigned), \"1.\" (ISO assigned) or \"2.\" (joint ISO/ITU-T assigned)"; + + /* should also check that the second arc is in the range 0-39 */ + + return *err == NULL; +} + gboolean uat_fld_chk_proto(void* u1 _U_, const char* strptr, unsigned len, const void* u2 _U_, const void* u3 _U_, const char** err) { if (len) { char* name = ep_strndup(strptr,len); -- cgit v1.2.3