*/
#include "includes.h"
+#include "events.h"
+#include "rpc_server/dcerpc_server.h"
struct dcesrv_socket_context {
const struct dcesrv_endpoint *endpoint;
struct socket_context *sock = private;
size_t sendlen;
- status = socket_send(sock, sock, out, &sendlen, 0);
- if (!NT_STATUS_IS_OK(status)) {
+ status = socket_send(sock, out, &sendlen, 0);
+ if (NT_STATUS_IS_ERR(status)) {
return -1;
}
char *full_path;
if (!e->ep_description.endpoint) {
- /* No identifier specified: generate one */
- e->ep_description.endpoint = generate_random_str(dce_ctx, 10);
+ /* No identifier specified: use DEFAULT.
+ * DO NOT hardcode this value anywhere else. Rather, specify
+ * no endpoint and let the epmapper worry about it. */
+ e->ep_description.endpoint = talloc_strdup(dce_ctx, "DEFAULT");
}
full_path = talloc_asprintf(dce_ctx, "%s/%s", lp_ncalrpc_dir(), e->ep_description.endpoint);
add a socket address to the list of events, one event per dcerpc endpoint
*/
static void add_socket_rpc_tcp_iface(struct server_service *service,
- const struct model_ops *model_ops,
- struct dcesrv_context *dce_ctx,
- struct dcesrv_endpoint *e,
- struct in_addr *ifip)
+ const struct model_ops *model_ops,
+ struct dcesrv_context *dce_ctx,
+ struct dcesrv_endpoint *e,
+ struct ipv4_addr *ifip)
{
struct server_socket *sock;
struct dcesrv_socket_context *dcesrv_sock;
uint16_t port = 0;
- const char *ip_str = talloc_strdup(service, inet_ntoa(*ifip));
+ char *ip_str = talloc_strdup(service, sys_inet_ntoa(*ifip));
if (e->ep_description.endpoint)
port = atoi(e->ep_description.endpoint);
int num_interfaces = iface_count();
int i;
for(i = 0; i < num_interfaces; i++) {
- struct in_addr *ifip = iface_n_ip(i);
+ struct ipv4_addr *ifip = iface_n_ip(i);
if (ifip == NULL) {
continue;
}
add_socket_rpc_tcp_iface(service, model_ops, dce_ctx, e, ifip);
}
} else {
- struct in_addr *ifip;
- ifip = interpret_addr2(dce_ctx, lp_socket_address());
- add_socket_rpc_tcp_iface(service, model_ops, dce_ctx, e, ifip);
- talloc_free(ifip);
+ struct ipv4_addr ifip;
+ ifip = interpret_addr2(lp_socket_address());
+ add_socket_rpc_tcp_iface(service, model_ops, dce_ctx, e, &ifip);
}
return;
/* Make sure the directory for NCALRPC exists */
if (!directory_exist(lp_ncalrpc_dir(), NULL)) {
- mkdir(lp_ncalrpc_dir(), 700);
+ mkdir(lp_ncalrpc_dir(), S_IWUSR | S_IRUSR | S_IXUSR);
}
for (e=dce_ctx->endpoint_list;e;e=e->next) {
return;
}
-void dcesrv_sock_recv(struct server_connection *conn, time_t t, uint16_t flags)
+void dcesrv_sock_recv(struct server_connection *conn, struct timeval t, uint16_t flags)
{
NTSTATUS status;
struct dcesrv_connection *dce_conn = conn->private_data;
DATA_BLOB tmp_blob;
+ size_t nread;
- DEBUG(10,("dcesrv_sock_recv\n"));
+ tmp_blob = data_blob_talloc(conn->socket, NULL, 0x1000);
+ if (tmp_blob.data == NULL) {
+ dcesrv_terminate_connection(dce_conn, "out of memory");
+ return;
+ }
- status = socket_recv(conn->socket, conn->socket, &tmp_blob, 0x4000, 0);
- if (!NT_STATUS_IS_OK(status)) {
- if (NT_STATUS_IS_ERR(status)) {
- dcesrv_terminate_connection(dce_conn, "eof on socket");
- return;
- }
+ status = socket_recv(conn->socket, tmp_blob.data, tmp_blob.length, &nread, 0);
+ if (NT_STATUS_IS_ERR(status)) {
+ dcesrv_terminate_connection(dce_conn, nt_errstr(status));
+ return;
+ }
+ if (nread == 0) {
+ talloc_free(tmp_blob.data);
return;
}
+ tmp_blob.length = nread;
+
status = dcesrv_input(dce_conn, &tmp_blob);
talloc_free(tmp_blob.data);
+
if (!NT_STATUS_IS_OK(status)) {
- dcesrv_terminate_connection(dce_conn, "eof on socket");
+ dcesrv_terminate_connection(dce_conn, nt_errstr(status));
return;
}
return;
}
-void dcesrv_sock_send(struct server_connection *conn, time_t t, uint16_t flags)
+void dcesrv_sock_send(struct server_connection *conn, struct timeval t, uint16_t flags)
{
struct dcesrv_connection *dce_conn = conn->private_data;
NTSTATUS status;
return;
}
-void dcesrv_sock_idle(struct server_connection *conn, time_t t)
-{
- DEBUG(10,("dcesrv_sock_idle\n"));
- conn->event.idle->next_event = t + 5;
-
- return;
-}
-
void dcesrv_sock_close(struct server_connection *conn, const char *reason)
{
struct dcesrv_connection *dce_conn = conn->private_data;