aboutsummaryrefslogtreecommitdiffstats
path: root/epan/uat.c
diff options
context:
space:
mode:
authorGraeme Lunt <graeme.lunt@smhs.co.uk>2010-06-28 09:30:15 +0000
committerGraeme Lunt <graeme.lunt@smhs.co.uk>2010-06-28 09:30:15 +0000
commit812274918a9a67c0011341de17609a32ee2f582c (patch)
tree9fec573c43152f2b78f71734553377d6328be51a /epan/uat.c
parent0d9ad5016e2321574904dea7166cc98bc54ceb8b (diff)
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
Diffstat (limited to 'epan/uat.c')
-rw-r--r--epan/uat.c25
1 files changed, 25 insertions, 0 deletions
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);