s3:smbd: s/SMBkeepalive/NBSSkeepalive
[ira/wip.git] / source3 / smbd / process.c
index 6cf793a77f743013154c5b33e1962cfa16238891..785486137c3ff79c0a3d08e3e31f8fdf8161ec9f 100644 (file)
@@ -844,86 +844,6 @@ bool push_deferred_open_message_smb(struct smb_request *req,
                                   private_data, priv_len);
 }
 
-struct idle_event {
-       struct timed_event *te;
-       struct timeval interval;
-       char *name;
-       bool (*handler)(const struct timeval *now, void *private_data);
-       void *private_data;
-};
-
-static void smbd_idle_event_handler(struct event_context *ctx,
-                                   struct timed_event *te,
-                                   struct timeval now,
-                                   void *private_data)
-{
-       struct idle_event *event =
-               talloc_get_type_abort(private_data, struct idle_event);
-
-       TALLOC_FREE(event->te);
-
-       DEBUG(10,("smbd_idle_event_handler: %s %p called\n",
-                 event->name, event->te));
-
-       if (!event->handler(&now, event->private_data)) {
-               DEBUG(10,("smbd_idle_event_handler: %s %p stopped\n",
-                         event->name, event->te));
-               /* Don't repeat, delete ourselves */
-               TALLOC_FREE(event);
-               return;
-       }
-
-       DEBUG(10,("smbd_idle_event_handler: %s %p rescheduled\n",
-                 event->name, event->te));
-
-       event->te = event_add_timed(ctx, event,
-                                   timeval_sum(&now, &event->interval),
-                                   smbd_idle_event_handler, event);
-
-       /* We can't do much but fail here. */
-       SMB_ASSERT(event->te != NULL);
-}
-
-struct idle_event *event_add_idle(struct event_context *event_ctx,
-                                 TALLOC_CTX *mem_ctx,
-                                 struct timeval interval,
-                                 const char *name,
-                                 bool (*handler)(const struct timeval *now,
-                                                 void *private_data),
-                                 void *private_data)
-{
-       struct idle_event *result;
-       struct timeval now = timeval_current();
-
-       result = talloc(mem_ctx, struct idle_event);
-       if (result == NULL) {
-               DEBUG(0, ("talloc failed\n"));
-               return NULL;
-       }
-
-       result->interval = interval;
-       result->handler = handler;
-       result->private_data = private_data;
-
-       if (!(result->name = talloc_asprintf(result, "idle_evt(%s)", name))) {
-               DEBUG(0, ("talloc failed\n"));
-               TALLOC_FREE(result);
-               return NULL;
-       }
-
-       result->te = event_add_timed(event_ctx, result,
-                                    timeval_sum(&now, &interval),
-                                    smbd_idle_event_handler, result);
-       if (result->te == NULL) {
-               DEBUG(0, ("event_add_timed failed\n"));
-               TALLOC_FREE(result);
-               return NULL;
-       }
-
-       DEBUG(10,("event_add_idle: %s %p\n", result->name, result->te));
-       return result;
-}
-
 static void smbd_sig_term_handler(struct tevent_context *ev,
                                  struct tevent_signal *se,
                                  int signum,
@@ -1672,7 +1592,7 @@ static void process_smb(struct smbd_server_connection *sconn,
        DEBUG(3, ("Transaction %d of length %d (%u toread)\n",
                  sconn->trans_num, (int)nread, (unsigned int)unread_bytes));
 
-       if (msg_type != 0) {
+       if (msg_type != NBSSmessage) {
                /*
                 * NetBIOS session request, keepalive, etc.
                 */
@@ -1701,7 +1621,7 @@ static void process_smb(struct smbd_server_connection *sconn,
        sconn->trans_num++;
 
 done:
-       sconn->smb1.num_requests++;
+       sconn->num_requests++;
 
        /* The timeout_processing function isn't run nearly
           often enough to implement 'max log size' without
@@ -1710,7 +1630,7 @@ done:
           level 10.  Checking every 50 SMBs is a nice
           tradeoff of performance vs log file size overrun. */
 
-       if ((sconn->smb1.num_requests % 50) == 0 &&
+       if ((sconn->num_requests % 50) == 0 &&
            need_to_check_log_size()) {
                change_to_root_user();
                check_log_size();
@@ -2581,7 +2501,7 @@ static bool smbd_echo_reply(uint8_t *inbuf, size_t inbuf_len,
        char *outbuf;
        bool ok;
 
-       if ((inbuf_len == 4) && (CVAL(inbuf, 0) == SMBkeepalive)) {
+       if ((inbuf_len == 4) && (CVAL(inbuf, 0) == NBSSkeepalive)) {
                DEBUG(10, ("Got netbios keepalive\n"));
                /*
                 * Just swallow it
@@ -2916,7 +2836,7 @@ void smbd_process(struct smbd_server_connection *sconn)
        char *rhost;
        int ret;
 
-       if (lp_maxprotocol() == PROTOCOL_SMB2) {
+       if (lp_maxprotocol() >= PROTOCOL_SMB2_02) {
                /*
                 * We're not making the decision here,
                 * we're just allowing the client
@@ -2975,7 +2895,9 @@ void smbd_process(struct smbd_server_connection *sconn)
                                sconn->remote_address,
                                talloc_tos());
                if (remaddr == NULL) {
-
+                       DEBUG(0,("%s: tsocket_address_inet_addr_string remote failed - %s\n",
+                                __location__, strerror(errno)));
+                       exit_server_cleanly("tsocket_address_inet_addr_string remote failed.\n");
                }
        } else {
                remaddr = "0.0.0.0";