static void smb_direct_daemon_stopped(struct tevent_req *req);
+static void smb_direct_daemon_accept_done(struct tevent_req *subreq)
+{
+ struct tevent_context *ev = tevent_req_callback_data(subreq,
+ struct tevent_context);
+ struct smb_direct_connection *c = NULL;
+ int fd = -1;
+ struct sockaddr_storage laddr;
+ struct sockaddr_storage raddr;
+ NTSTATUS status;
+
+ ZERO_STRUCT(laddr);
+ ZERO_STRUCT(raddr);
+
+DEBUG(0,("%s:%s: here...\n", __location__, __func__));
+ status = smb_direct_listener_accept_recv(subreq, ev,
+ &c, &fd, &laddr, &raddr);
+ /* no TALLOC_FREE(subreq)! we want to get more connections */
+ if (!NT_STATUS_IS_OK(status)) {
+ //TODO...
+ return;
+ }
+ subreq = NULL;
+
+DEBUG(0,("%s:%s: here...\n", __location__, __func__));
+ status = smb_direct_connection_setup_events(c, ev);
+ if (!NT_STATUS_IS_OK(status)) {
+ TALLOC_FREE(c);
+ close(fd);
+ //TODO...
+ return;
+ }
+
+ //TODO: pass the caller
+ TALLOC_FREE(c);
+ close(fd);
+DEBUG(0,("%s:%s: here...\n", __location__, __func__));
+}
+
static bool smb_direct_daemon_init(struct tevent_context *ev,
struct messaging_context *msg,
bool interactive,
if (interactive) {
- req = smb_direct_daemon_send(ev, ev);
+ struct smb_direct_listener *l = NULL;
+ struct tevent_req *subreq = NULL;
+ struct sockaddr_storage bind_addr;
+ struct in_addr ip;
+
+ DBG_ERR("setup listen ...\n");
+
+ ZERO_STRUCT(ip);
+ in_addr_to_sockaddr_storage(&bind_addr, ip);
+
+ status = smbd_direct_listener_setup(ev, &bind_addr, &l);
+ if (!NT_STATUS_IS_OK(status)) {
+ DBG_ERR("smbd_direct_listener_setup() => %s\n",
+ nt_errstr(status));
+ return false;
+ }
+
+ // TODO: create an socketpair() with shutdown(SHUT_RD) or a pipe()
+ // and pass it allong, we'll to sendmsg() from our side
+ // and pass the metadata and the connection fd to the calling
+ // process. If the other end closes we need to free the
+ // listener.
+
+ subreq = smb_direct_listener_accept_send(ev, ev, l);
+ if (subreq == NULL) {
+ TALLOC_FREE(l);
+ status = NT_STATUS_NO_MEMORY;
+ DBG_ERR("smbd_direct_listener_setup() => %s\n",
+ nt_errstr(status));
+ return false;
+ }
+ tevent_req_set_callback(subreq,
+ smb_direct_daemon_accept_done,
+ ev);
+
+ req = tevent_wakeup_send(ev, ev, timeval_current_ofs(999999,0));
*ppid = getpid();
return (req != NULL);
}
int result;
bool ok;
+ if (0) {
parent->smbd_ctr_socket = smb_direct_socket(parent);
if (parent->smbd_ctr_socket == NULL) {
DBG_ERR("smb_direct_socket failed\n");
}
DBG_ERR("smb_direct_ping got [%" PRIx32 "]\n", ping_data);
-
- s = talloc(parent, struct smbd_open_socket);
+ }
+ s = talloc_zero(parent, struct smbd_open_socket);
if (s == NULL) {
return false;
}
-
+if (0) {
result = smb_direct_bind(parent->smbd_ctr_socket, NULL);
if (result != 0) {
DBG_ERR("smb_direct_bind failed\n");
}
tevent_fd_set_close_fn(s->fde, smbd_open_socket_close_fn);
-
+}
DLIST_ADD_END(parent->sockets, s);
return true;
smbd_setup_sig_chld_handler(parent);
ports = lp_smb_ports();
-
+if (0) {
/* use a reasonable default set of ports - listing on 445 and 139 */
if (smb_ports) {
char **l;
}
}
}
-
- if (lp_parm_bool(-1, "smbdirect", "enable", false)) {
+}
+ if (lp_parm_bool(-1, "smbdirect", "enable", true)) {
bool ok;
ok = smb_direct_client_start(parent);