LCOV - code coverage report
Current view: top level - source4/torture/ndr - dcerpc.c (source / functions) Hit Total Coverage
Test: coverage report for support-claim-type-attributes 6b5c566e Lines: 35 37 94.6 %
Date: 2023-11-21 12:31:41 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /*
       2             :    Unix SMB/CIFS implementation.
       3             :    test suite for dcerpc ndr operations
       4             : 
       5             :    Copyright (C) Stefan Metzmacher 2023
       6             : 
       7             :    This program is free software; you can redistribute it and/or modify
       8             :    it under the terms of the GNU General Public License as published by
       9             :    the Free Software Foundation; either version 3 of the License, or
      10             :    (at your option) any later version.
      11             : 
      12             :    This program is distributed in the hope that it will be useful,
      13             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      14             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      15             :    GNU General Public License for more details.
      16             : 
      17             :    You should have received a copy of the GNU General Public License
      18             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      19             : */
      20             : 
      21             : #include "includes.h"
      22             : #include "torture/ndr/ndr.h"
      23             : #include "librpc/gen_ndr/ndr_dcerpc.h"
      24             : #include "torture/ndr/proto.h"
      25             : 
      26             : /*
      27             :  *  ncacn_packet: struct ncacn_packet
      28             :  *      rpc_vers                 : 0x05 (5)
      29             :  *      rpc_vers_minor           : 0x00 (0)
      30             :  *      ptype                    : DCERPC_PKT_CO_CANCEL (18)
      31             :  *      pfc_flags                : 0x06 (6)
      32             :  *             0: DCERPC_PFC_FLAG_FIRST
      33             :  *             1: DCERPC_PFC_FLAG_LAST
      34             :  *             1: DCERPC_PFC_FLAG_PENDING_CANCEL_OR_HDR_SIGNING
      35             :  *             0: DCERPC_PFC_FLAG_CONC_MPX
      36             :  *             0: DCERPC_PFC_FLAG_DID_NOT_EXECUTE
      37             :  *             0: DCERPC_PFC_FLAG_MAYBE
      38             :  *             0: DCERPC_PFC_FLAG_OBJECT_UUID
      39             :  *      drep: ARRAY(4)
      40             :  *          [0]                      : 0x10 (16)
      41             :  *          [1]                      : 0x00 (0)
      42             :  *          [2]                      : 0x00 (0)
      43             :  *          [3]                      : 0x00 (0)
      44             :  *      frag_length              : 0x0010 (16)
      45             :  *      auth_length              : 0x0000 (0)
      46             :  *      call_id                  : 0x00000001 (1)
      47             :  *      u                        : union dcerpc_payload(case 18)
      48             :  *      co_cancel: struct dcerpc_co_cancel
      49             :  *          auth_info                : DATA_BLOB length=0
      50             :  */
      51             : static const uint8_t ncacn_packet_co_cancel_data[] = {
      52             :         0x05, 0x00, 0x12, 0x06, 0x10, 0x00, 0x00, 0x00,
      53             :         0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
      54             : };
      55             : 
      56           2 : static bool ncacn_packet_co_cancel_check(struct torture_context *tctx,
      57             :                                          struct ncacn_packet *pkt)
      58             : {
      59           2 :         torture_assert_int_equal(tctx, pkt->rpc_vers, 5, "rpc_vers");
      60           2 :         torture_assert_int_equal(tctx, pkt->rpc_vers_minor, 0, "rpc_vers_minor");
      61           2 :         torture_assert_int_equal(tctx, pkt->ptype, DCERPC_PKT_CO_CANCEL, "ptype");
      62           2 :         torture_assert_int_equal(tctx, pkt->pfc_flags,
      63             :                                  DCERPC_PFC_FLAG_LAST |
      64             :                                  DCERPC_PFC_FLAG_PENDING_CANCEL_OR_HDR_SIGNING,
      65             :                                  "pfc_flags");
      66           2 :         torture_assert_int_equal(tctx, pkt->drep[0], DCERPC_DREP_LE, "drep[0]");
      67           2 :         torture_assert_int_equal(tctx, pkt->drep[1], 0, "drep[1]");
      68           2 :         torture_assert_int_equal(tctx, pkt->drep[2], 0, "drep[2]");
      69           2 :         torture_assert_int_equal(tctx, pkt->drep[3], 0, "drep[3]");
      70           2 :         torture_assert_int_equal(tctx, pkt->frag_length, 16, "frag_length");
      71           2 :         torture_assert_int_equal(tctx, pkt->auth_length, 0, "auth_length");
      72           2 :         torture_assert_int_equal(tctx, pkt->call_id, 1, "call_id");
      73           2 :         torture_assert_int_equal(tctx, pkt->u.co_cancel.auth_info.length, 0,
      74             :                                  "co_cancel.auth_info.length");
      75           0 :         return true;
      76             : }
      77             : 
      78             : /*
      79             :  *  ncacn_packet: struct ncacn_packet
      80             :  *      rpc_vers                 : 0x05 (5)
      81             :  *      rpc_vers_minor           : 0x00 (0)
      82             :  *      ptype                    : DCERPC_PKT_ORPHANED (19)
      83             :  *      pfc_flags                : 0x03 (3)
      84             :  *             1: DCERPC_PFC_FLAG_FIRST
      85             :  *             1: DCERPC_PFC_FLAG_LAST
      86             :  *             0: DCERPC_PFC_FLAG_PENDING_CANCEL_OR_HDR_SIGNING
      87             :  *             0: DCERPC_PFC_FLAG_CONC_MPX
      88             :  *             0: DCERPC_PFC_FLAG_DID_NOT_EXECUTE
      89             :  *             0: DCERPC_PFC_FLAG_MAYBE
      90             :  *             0: DCERPC_PFC_FLAG_OBJECT_UUID
      91             :  *      drep: ARRAY(4)
      92             :  *          [0]                      : 0x10 (16)
      93             :  *          [1]                      : 0x00 (0)
      94             :  *          [2]                      : 0x00 (0)
      95             :  *          [3]                      : 0x00 (0)
      96             :  *      frag_length              : 0x0010 (16)
      97             :  *      auth_length              : 0x0000 (0)
      98             :  *      call_id                  : 0x00000008 (8)
      99             :  *      u                        : union dcerpc_payload(case 19)
     100             :  *      orphaned: struct dcerpc_orphaned
     101             :  *          auth_info                : DATA_BLOB length=0
     102             :  */
     103             : static const uint8_t ncacn_packet_orphaned_data[] = {
     104             :         0x05, 0x00, 0x13, 0x03, 0x10, 0x00, 0x00, 0x00,
     105             :         0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
     106             : };
     107             : 
     108           2 : static bool ncacn_packet_orphaned_check(struct torture_context *tctx,
     109             :                                         struct ncacn_packet *pkt)
     110             : {
     111           2 :         torture_assert_int_equal(tctx, pkt->rpc_vers, 5, "rpc_vers");
     112           2 :         torture_assert_int_equal(tctx, pkt->rpc_vers_minor, 0, "rpc_vers_minor");
     113           2 :         torture_assert_int_equal(tctx, pkt->ptype, DCERPC_PKT_ORPHANED, "ptype");
     114           2 :         torture_assert_int_equal(tctx, pkt->pfc_flags,
     115             :                                  DCERPC_PFC_FLAG_FIRST|DCERPC_PFC_FLAG_LAST,
     116             :                                  "pfc_flags");
     117           2 :         torture_assert_int_equal(tctx, pkt->drep[0], DCERPC_DREP_LE, "drep[0]");
     118           2 :         torture_assert_int_equal(tctx, pkt->drep[1], 0, "drep[1]");
     119           2 :         torture_assert_int_equal(tctx, pkt->drep[2], 0, "drep[2]");
     120           2 :         torture_assert_int_equal(tctx, pkt->drep[3], 0, "drep[3]");
     121           2 :         torture_assert_int_equal(tctx, pkt->frag_length, 16, "frag_length");
     122           2 :         torture_assert_int_equal(tctx, pkt->auth_length, 0, "auth_length");
     123           2 :         torture_assert_int_equal(tctx, pkt->call_id, 8, "call_id");
     124           2 :         torture_assert_int_equal(tctx, pkt->u.orphaned.auth_info.length, 0,
     125             :                                  "orphaned.auth_info.length");
     126           0 :         return true;
     127             : }
     128             : 
     129        2358 : struct torture_suite *ndr_dcerpc_suite(TALLOC_CTX *ctx)
     130             : {
     131        2358 :         struct torture_suite *suite = torture_suite_create(ctx, "dcerpc");
     132        2358 :         struct torture_suite *co_cancel = torture_suite_create(ctx, "co_cancel");
     133        2358 :         struct torture_suite *orphaned = torture_suite_create(ctx, "orphaned");
     134             : 
     135        2358 :         torture_suite_add_suite(suite, co_cancel);
     136        2358 :         torture_suite_add_ndr_pull_validate_test(co_cancel,
     137             :                                         ncacn_packet,
     138             :                                         ncacn_packet_co_cancel_data,
     139             :                                         ncacn_packet_co_cancel_check);
     140             : 
     141        2358 :         torture_suite_add_suite(suite, orphaned);
     142        2358 :         torture_suite_add_ndr_pull_validate_test(orphaned,
     143             :                                         ncacn_packet,
     144             :                                         ncacn_packet_orphaned_data,
     145             :                                         ncacn_packet_orphaned_check);
     146             : 
     147        2358 :         return suite;
     148             : }

Generated by: LCOV version 1.14