+ struct wbsrv_connection *wbsrv_conn = tevent_req_callback_data(subreq,
+ struct wbsrv_connection);
+ struct wbsrv_samba3_call *call;
+ NTSTATUS status;
+
+ call = talloc_zero(wbsrv_conn, struct wbsrv_samba3_call);
+ if (call == NULL) {
+ wbsrv_terminate_connection(wbsrv_conn, "wbsrv_call_loop: "
+ "no memory for wbsrv_samba3_call");
+ return;
+ }
+ call->wbconn = wbsrv_conn;
+
+ status = tstream_read_pdu_blob_recv(subreq,
+ call,
+ &call->in);
+ TALLOC_FREE(subreq);
+ if (!NT_STATUS_IS_OK(status)) {
+ const char *reason;
+
+ reason = talloc_asprintf(call, "wbsrv_call_loop: "
+ "tstream_read_pdu_blob_recv() - %s",
+ nt_errstr(status));
+ if (!reason) {
+ reason = nt_errstr(status);
+ }
+
+ wbsrv_terminate_connection(wbsrv_conn, reason);
+ return;
+ }
+
+ DEBUG(10,("Received winbind TCP packet of length %lu from %s\n",
+ (long) call->in.length,
+ tsocket_address_string(wbsrv_conn->conn->remote_address, call)));
+
+ status = wbsrv_samba3_process(call);
+ if (!NT_STATUS_IS_OK(status)) {
+ const char *reason;
+
+ reason = talloc_asprintf(call, "wbsrv_call_loop: "
+ "tstream_read_pdu_blob_recv() - %s",
+ nt_errstr(status));
+ if (!reason) {
+ reason = nt_errstr(status);
+ }
+
+ wbsrv_terminate_connection(wbsrv_conn, reason);
+ return;
+ }
+
+ /*
+ * The winbind pdu's has the length as 4 byte (initial_read_size),
+ * wbsrv_samba3_packet_full_request provides the pdu length then.
+ */
+ subreq = tstream_read_pdu_blob_send(wbsrv_conn,
+ wbsrv_conn->conn->event.ctx,
+ wbsrv_conn->tstream,
+ 4, /* initial_read_size */
+ wbsrv_samba3_packet_full_request,
+ wbsrv_conn);
+ if (subreq == NULL) {
+ wbsrv_terminate_connection(wbsrv_conn, "wbsrv_call_loop: "
+ "no memory for tstream_read_pdu_blob_send");
+ return;
+ }
+ tevent_req_set_callback(subreq, wbsrv_call_loop, wbsrv_conn);