s3:srv_epmapper: make use of dcerpc_binding_*() functions in endpoints_match()
authorStefan Metzmacher <metze@samba.org>
Fri, 31 Jan 2014 22:26:43 +0000 (23:26 +0100)
committerGünther Deschner <gd@samba.org>
Thu, 13 Feb 2014 10:54:16 +0000 (11:54 +0100)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
source3/rpc_server/epmapper/srv_epmapper.c

index 55474c0da7ae6815c08ca117f7af479fd15eb4fe..32b8b1b577cb344265d40765b04dc8818b5625c4 100644 (file)
@@ -127,37 +127,52 @@ static struct dcesrv_iface_list *find_interface_list(const struct dcesrv_endpoin
 /*
  * Check if two endpoints match.
  */
-static bool endpoints_match(const struct dcerpc_binding *ep1,
-                           const struct dcerpc_binding *ep2)
+static bool endpoints_match(const struct dcerpc_binding *b1,
+                           const struct dcerpc_binding *b2)
 {
-       if (ep1->transport != ep2->transport) {
+       enum dcerpc_transport_t t1;
+       const char *ep1;
+       const char *h1;
+       enum dcerpc_transport_t t2;
+       const char *ep2;
+       const char *h2;
+
+       t1 = dcerpc_binding_get_transport(b1);
+       ep1 = dcerpc_binding_get_string_option(b1, "endpoint");
+       h1 = dcerpc_binding_get_string_option(b1, "host");
+
+       t2 = dcerpc_binding_get_transport(b2);
+       ep2 = dcerpc_binding_get_string_option(b2, "endpoint");
+       h2 = dcerpc_binding_get_string_option(b2, "host");
+
+       if (t1 != t2) {
                return false;
        }
 
-       if (!ep1->endpoint && ep2->endpoint) {
+       if (!ep1 && ep2) {
                return false;
        }
 
-       if (ep1->endpoint && !ep2->endpoint) {
+       if (ep1 && !ep2) {
                return false;
        }
 
-       if (ep1->endpoint && ep2->endpoint) {
-               if (!strequal(ep1->endpoint, ep2->endpoint)) {
+       if (ep1 && ep2) {
+               if (!strequal(ep1, ep2)) {
                        return false;
                }
        }
 
-       if (!ep1->host && ep2->host) {
+       if (!h1 && h2) {
                return false;
        }
 
-       if (ep1->host && !ep2->host) {
+       if (h1 && !h2) {
                return false;
        }
 
-       if (ep1->host && ep2->host) {
-               if (!strequal(ep1->host, ep2->host)) {
+       if (h1 && h2) {
+               if (!strequal(h1, h2)) {
                        return false;
                }
        }