]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
Expose transfer and abstract syntax.
authorJelmer Vernooij <jelmer@samba.org>
Sun, 25 May 2008 02:54:38 +0000 (04:54 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Sun, 25 May 2008 02:54:38 +0000 (04:54 +0200)
source/librpc/rpc/pyrpc.c
source/scripting/python/samba/tests/dcerpc/bare.py
source/scripting/python/samba/tests/dcerpc/rpcecho.py

index a24c659a5508264075a69c0e7f4f764a5d7122b5..26242e8235a6be9ca82c110cbbced754d6ae66ad 100644 (file)
@@ -68,8 +68,6 @@ static bool ndr_syntax_from_py_object(PyObject *object, struct ndr_syntax_id *sy
        return false;
 }      
 
-
-
 static PyObject *py_iface_server_name(PyObject *obj, void *closure)
 {
        const char *server_name;
@@ -82,9 +80,43 @@ static PyObject *py_iface_server_name(PyObject *obj, void *closure)
        return PyString_FromString(server_name);
 }
 
+static PyObject *py_ndr_syntax_id(struct ndr_syntax_id *syntax_id)
+{
+       PyObject *ret;
+       char *uuid_str;
+
+       uuid_str = GUID_string(NULL, &syntax_id->uuid);
+       if (uuid_str == NULL)
+               return NULL;
+
+       ret = Py_BuildValue("(s,i)", uuid_str, syntax_id->if_version);
+
+       talloc_free(uuid_str);
+
+       return ret;
+}
+
+static PyObject *py_iface_abstract_syntax(PyObject *obj, void *closure)
+{
+       dcerpc_InterfaceObject *iface = (dcerpc_InterfaceObject *)obj;
+
+       return py_ndr_syntax_id(&iface->pipe->syntax);
+}
+
+static PyObject *py_iface_transfer_syntax(PyObject *obj, void *closure)
+{
+       dcerpc_InterfaceObject *iface = (dcerpc_InterfaceObject *)obj;
+
+       return py_ndr_syntax_id(&iface->pipe->transfer_syntax);
+}
+
 static PyGetSetDef dcerpc_interface_getsetters[] = {
        { discard_const_p(char, "server_name"), py_iface_server_name, NULL,
          discard_const_p(char, "name of the server, if connected over SMB") },
+       { discard_const_p(char, "abstract_syntax"), py_iface_abstract_syntax, NULL, 
+         discard_const_p(char, "syntax id of the abstract syntax") },
+       { discard_const_p(char, "transfer_syntax"), py_iface_transfer_syntax, NULL, 
+         discard_const_p(char, "syntax id of the transfersyntax") },
        { NULL }
 };
 
index eea6744e42d545f3c4008dd0ff862b312bfc7070..d75ffc381ee82bcbcd1bbf6ff8d326473276ed57 100644 (file)
@@ -28,11 +28,14 @@ class BareTestCase(TestCase):
                 ("60a15ec5-4de8-11d7-a637-005056a20182", 1))
         self.assertEquals("\x01\x00\x00\x00", x.request(0, chr(0) * 4))
 
-    #def test_alter_context(self):
-    #    x = ClientConnection("ncalrpc:localhost[DEFAULT]", 
-    #            ("12345778-1234-abcd-ef00-0123456789ac", 1))
-    #    x.alter_context(("60a15ec5-4de8-11d7-a637-005056a20182", 1))
-    #    self.assertEquals("\x01\x00\x00\x00", x.request(0, chr(0) * 4))
+    def test_alter_context(self):
+        x = ClientConnection("ncalrpc:localhost[DEFAULT]", 
+                ("12345778-1234-abcd-ef00-0123456789ac", 1))
+        y = ClientConnection("ncalrpc:localhost", 
+                ("60a15ec5-4de8-11d7-a637-005056a20182", 1),
+                basis_connection=x)
+        x.alter_context(("60a15ec5-4de8-11d7-a637-005056a20182", 1))
+        # FIXME: self.assertEquals("\x01\x00\x00\x00", x.request(0, chr(0) * 4))
 
     def test_two_connections(self):
         x = ClientConnection("ncalrpc:localhost[DEFAULT]", 
index 7fd1bcc5b8e27c1d72ac13f1ee42d0aa3f6dd1a2..68b7a42d523679dfae4a945ffdf07ab37e6b72dd 100644 (file)
@@ -30,6 +30,10 @@ class RpcEchoTests(RpcInterfaceTestCase):
         self.conn2 = echo.rpcecho("ncalrpc", basis_connection=self.conn)
         self.assertEquals(3, self.conn2.AddOne(2))
 
+    def test_abstract_syntax(self):
+        self.assertEquals(("60a15ec5-4de8-11d7-a637-005056a20182", 1), 
+                          self.conn.abstract_syntax)
+
     def test_addone(self):
         self.assertEquals(2, self.conn.AddOne(1))