Re: [ovs-dev] [PATCH 2/5 v1] datapath-windows: add OvsComareString() to compare strings
On Sep 17, 2014, at 9:13 AM, Eitan Eliahu wrote: > > How about using RtlEqualString() ? > > >Str1.MaximumLength = 16; >Str1.Buffer = &AnsiString; > >if (!RtlEqualString( &str1, &str2, TRUE ){ > > } Eitan, I considered using RtlEqualString(), but backed off since it used STRING objects. Looks like there's a convenient RtlInitString(). I'll update the patch to use these functions. Sam, As much as possible I want to stick to using Rtl* functions for memory/string manipulation. Hence I am not using strncmp(). thanks, Nithin ___ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev
Re: [ovs-dev] [PATCH 2/5 v1] datapath-windows: add OvsComareString() to compare strings
How about using RtlEqualString() ? Str1.MaximumLength = 16; Str1.Buffer = &AnsiString; if (!RtlEqualString( &str1, &str2, TRUE ){ } -Original Message- From: Nithin Raju Sent: Wednesday, September 17, 2014 8:34 AM To: Samuel Ghinet Cc: dev@openvswitch.org; Eitan Eliahu; Ankur Sharma; Alin Serdean Subject: Re: [PATCH 2/5 v1] datapath-windows: add OvsComareString() to compare strings On Sep 17, 2014, at 6:16 AM, Samuel Ghinet wrote: > I don't think there's a need to implement such a function. > You can use memcmp, which behaves quite like strncmp. hi Samuel, Thanks for the pointer. I was trying to use Rtl* functions, but if memcmp() works, that is great. I have a couple of questions though that are not clear to me from the documentation: 1. how does memcmp() when the lengths are different? what is the length argument that we need to pass? 2. If the lengths are different, we should be passing the larger length, does memcmp() terminate when it sees the NUL ('\0') character? Obviously passing the smaller length would be wrong. If memcmp() has the same limitations as RtlCompareMemory() then we need this function. Thanks, -- Nithin ___ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev
Re: [ovs-dev] [PATCH 2/5 v1] datapath-windows: add OvsComareString() to compare strings
On Sep 17, 2014, at 6:16 AM, Samuel Ghinet wrote: > I don't think there's a need to implement such a function. > You can use memcmp, which behaves quite like strncmp. hi Samuel, Thanks for the pointer. I was trying to use Rtl* functions, but if memcmp() works, that is great. I have a couple of questions though that are not clear to me from the documentation: 1. how does memcmp() when the lengths are different? what is the length argument that we need to pass? 2. If the lengths are different, we should be passing the larger length, does memcmp() terminate when it sees the NUL ('\0') character? Obviously passing the smaller length would be wrong. If memcmp() has the same limitations as RtlCompareMemory() then we need this function. Thanks, -- Nithin ___ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev
Re: [ovs-dev] [PATCH 2/5 v1] datapath-windows: add OvsComareString() to compare strings
Nithin, I don't think there's a need to implement such a function. You can use memcmp, which behaves quite like strncmp. Regards, Sam From: Nithin Raju [nit...@vmware.com] Sent: Wednesday, September 17, 2014 5:06 AM To: dev@openvswitch.org; Samuel Ghinet; elia...@vmware.com; ankursha...@vmware.com Cc: Nithin Raju Subject: [PATCH 2/5 v1] datapath-windows: add OvsComareString() to compare strings Turns out that there's no convenient equivalent of strncmp() in the Windows kernel. RtlEqualString() works on STRING * pointers which are different from the CHAR * pointers. In this patch, we add support for such a function for comparing strings. Signed-off-by: Nithin Raju --- datapath-windows/ovsext/Util.c | 12 datapath-windows/ovsext/Util.h |3 +++ 2 files changed, 15 insertions(+), 0 deletions(-) diff --git a/datapath-windows/ovsext/Util.c b/datapath-windows/ovsext/Util.c index 51360a8..be2b829 100644 --- a/datapath-windows/ovsext/Util.c +++ b/datapath-windows/ovsext/Util.c @@ -87,3 +87,15 @@ OvsAppendList(PLIST_ENTRY dst, PLIST_ENTRY src) src->Flink = src; src->Blink = src; } + +BOOLEAN +OvsCompareString(PVOID string1, UINT32 size1, + PVOID string2, UINT32 size2) +{ +if (size1 == size2 && +RtlCompareMemory(string1, string2, size1) == size1) { +return TRUE; +} + +return FALSE; +} diff --git a/datapath-windows/ovsext/Util.h b/datapath-windows/ovsext/Util.h index c45d488..3e21af6 100644 --- a/datapath-windows/ovsext/Util.h +++ b/datapath-windows/ovsext/Util.h @@ -75,4 +75,7 @@ VOID OvsAppendList(PLIST_ENTRY dst, PLIST_ENTRY src); #define BIT16(_x) ((UINT16)0x1 << (_x)) #define BIT32(_x) ((UINT32)0x1 << (_x)) +BOOLEAN OvsCompareString(PVOID string1, UINT32 size1, + PVOID string2, UINT32 size2); + #endif /* __UTIL_H_ */ -- 1.7.4.1 ___ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev