STEP01x: dcerpc_server_connection_loop allow_incoming
authorStefan Metzmacher <metze@samba.org>
Wed, 19 Mar 2014 11:22:17 +0000 (12:22 +0100)
committerStefan Metzmacher <metze@samba.org>
Tue, 4 Jun 2019 10:58:04 +0000 (12:58 +0200)
librpc/rpc/dcerpc_connection.c

index cbdf0d6ca509b1076a77c3ce55614a45ee6ba302..29f3048910c7dec9d76623685b853241fdf74155 100644 (file)
@@ -2816,6 +2816,8 @@ struct dcerpc_server_connection_loop_state {
 
        uint32_t last_call_id;
 
+       bool allow_incoming;
+
        size_t num_secs;
        struct db_context *secs;
 
@@ -2863,6 +2865,7 @@ struct tevent_req *dcerpc_server_connection_loop_send(TALLOC_CTX *mem_ctx,
        tevent_req_defer_callback(req, ev);
        tevent_req_set_cleanup_fn(req, dcerpc_server_connection_loop_cleanup);
 
+       state->allow_incoming = true;
        //TODO different dcerpc_connection_dead() behavior as server?
 
        return req;
@@ -2875,6 +2878,8 @@ static void dcerpc_server_connection_loop_cleanup(struct tevent_req *req,
                tevent_req_data(req,
                struct dcerpc_server_connection_loop_state);
 
+       state->allow_incoming = false;
+
        if (state->conn != NULL) {
                TALLOC_FREE(state->conn->calls.new_call);
                state->conn = NULL;
@@ -2889,27 +2894,53 @@ static NTSTATUS dcerpc_server_connection_loop_handle_in_frag(struct tevent_req *
                tevent_req_data(req,
                struct dcerpc_server_connection_loop_state);
 
+       if (!state->allow_incoming) {
+               DEBUG(0, ("Unexpected packet type %u received from %s!\n",
+                         (unsigned int)pkt->ptype,
+                        "TODO"));
+               return NT_STATUS_RPC_PROTOCOL_ERROR;
+       }
+
        /* Ensure we have the correct type. */
        switch (pkt->ptype) {
        case DCERPC_PKT_BIND:
                if (state->conn->features.bind_done) {
                        return NT_STATUS_RPC_PROTOCOL_ERROR;
                }
+               state->allow_incoming = false;
+               // TODO...
+
                state->conn->features.bind_done = true;
+               state->allow_incoming = true;
+               break;
+
+       case DCERPC_PKT_AUTH3:
+               if (!state->conn->features.bind_done) {
+                       return NT_STATUS_RPC_PROTOCOL_ERROR;
+               }
+               // TODO...
+
                break;
 
        case DCERPC_PKT_ALTER:
                if (!state->conn->features.bind_done) {
                        return NT_STATUS_RPC_PROTOCOL_ERROR;
                }
+               // TODO...
+
                break;
 
        case DCERPC_PKT_REQUEST:
                if (!state->conn->features.bind_done) {
                        return NT_STATUS_RPC_PROTOCOL_ERROR;
                }
+               // TODO...
+
                break;
 
+       case DCERPC_PKT_CO_CANCEL:
+       case DCERPC_PKT_ORPHANED:
+               // TODO...
        default:
                DEBUG(0, ("Unknown packet type %u received from %s!\n",
                          (unsigned int)pkt->ptype,