Add a new header file for functions in lib/util/util.c.
[obnox/samba/samba-obnox.git] / libcli / nbt / libnbt.h
index 7d8ca49e9abd1f39f8ae910bafd2fe6eb822e660..fd0c7fea66d00f089167e722e62159d42d4636d8 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "librpc/gen_ndr/nbt.h"
 #include "librpc/ndr/libndr.h"
+#include "lib/util/xfile.h"
 
 /*
   possible states for pending requests
@@ -60,7 +61,7 @@ struct nbt_name_request {
        bool received_wack;
 
        /* the timeout event */
-       struct timed_event *te;
+       struct tevent_timer *te;
 
        /* the name transaction id */
        uint16_t name_trn_id;
@@ -94,14 +95,13 @@ struct nbt_name_request {
 */
 struct nbt_name_socket {
        struct socket_context *sock;
-       struct event_context *event_ctx;
-       struct smb_iconv_convenience *iconv_convenience;
+       struct tevent_context *event_ctx;
 
        /* a queue of requests pending to be sent */
        struct nbt_name_request *send_queue;
 
        /* the fd event */
-       struct fd_event *fde;
+       struct tevent_fd *fde;
 
        /* mapping from name_trn_id to pending event */
        struct idr_context *idr;
@@ -122,8 +122,6 @@ struct nbt_name_socket {
                                struct socket_address *);
                void *private_data;
        } unexpected;
-
-       uint32_t wack_timeout;
 };
 
 
@@ -277,8 +275,10 @@ struct nbt_name_release {
 };
 
 struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx,
-                                            struct event_context *event_ctx,
-                                            struct smb_iconv_convenience *iconv_convenience);
+                                            struct tevent_context *event_ctx);
+void nbt_name_socket_handle_response_packet(struct nbt_name_request *req,
+                                           struct nbt_name_packet *packet,
+                                           struct socket_address *src);
 struct nbt_name_request *nbt_name_query_send(struct nbt_name_socket *nbtsock,
                                             struct nbt_name_query *io);
 NTSTATUS nbt_name_query_recv(struct nbt_name_request *req,
@@ -293,7 +293,7 @@ NTSTATUS nbt_name_status(struct nbt_name_socket *nbtsock,
                        TALLOC_CTX *mem_ctx, struct nbt_name_status *io);
 
 NTSTATUS nbt_name_dup(TALLOC_CTX *mem_ctx, struct nbt_name *name, struct nbt_name *newname);
-NTSTATUS nbt_name_to_blob(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, DATA_BLOB *blob, struct nbt_name *name);
+NTSTATUS nbt_name_to_blob(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, struct nbt_name *name);
 NTSTATUS nbt_name_from_blob(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, struct nbt_name *name);
 void nbt_choose_called_name(TALLOC_CTX *mem_ctx, struct nbt_name *n, const char *name, int type);
 char *nbt_name_string(TALLOC_CTX *mem_ctx, const struct nbt_name *name);
@@ -326,28 +326,50 @@ NTSTATUS nbt_set_incoming_handler(struct nbt_name_socket *nbtsock,
                                  void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *,
                                                  struct socket_address *),
                                  void *private_data);
+NTSTATUS nbt_set_unexpected_handler(struct nbt_name_socket *nbtsock,
+                                   void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *,
+                                                   struct socket_address *),
+                                   void *private_data);
 NTSTATUS nbt_name_reply_send(struct nbt_name_socket *nbtsock,
                             struct socket_address *dest,
                             struct nbt_name_packet *request);
 
 
-NDR_SCALAR_PROTO(wrepl_nbt_name, const struct nbt_name *)
-NDR_SCALAR_PROTO(nbt_string, const char *)
+NDR_SCALAR_PTR_PROTO(wrepl_nbt_name, struct nbt_name)
 NDR_BUFFER_PROTO(nbt_name, struct nbt_name)
 NTSTATUS nbt_rcode_to_ntstatus(uint8_t rcode);
 
-struct composite_context;
-struct composite_context *nbt_name_register_bcast_send(struct nbt_name_socket *nbtsock,
-                                                      struct nbt_name_register_bcast *io);
-NTSTATUS nbt_name_register_bcast_recv(struct composite_context *c);
-struct composite_context *nbt_name_register_wins_send(struct nbt_name_socket *nbtsock,
-                                                     struct nbt_name_register_wins *io);
-NTSTATUS nbt_name_refresh_wins_recv(struct composite_context *c, TALLOC_CTX *mem_ctx,
-                                    struct nbt_name_refresh_wins *io);
-struct composite_context *nbt_name_refresh_wins_send(struct nbt_name_socket *nbtsock,
-                                                     struct nbt_name_refresh_wins *io);
-NTSTATUS nbt_name_register_wins_recv(struct composite_context *c, TALLOC_CTX *mem_ctx,
+struct tevent_context;
+struct tevent_req;
+struct tevent_req *nbt_name_register_bcast_send(TALLOC_CTX *mem_ctx,
+                                       struct tevent_context *ev,
+                                       struct nbt_name_socket *nbtsock,
+                                       struct nbt_name_register_bcast *io);
+NTSTATUS nbt_name_register_bcast_recv(struct tevent_req *req);
+struct tevent_req *nbt_name_register_wins_send(TALLOC_CTX *mem_ctx,
+                                              struct tevent_context *ev,
+                                              struct nbt_name_socket *nbtsock,
+                                              struct nbt_name_register_wins *io);
+NTSTATUS nbt_name_register_wins_recv(struct tevent_req *req,
+                                    TALLOC_CTX *mem_ctx,
                                     struct nbt_name_register_wins *io);
-
+struct tevent_req *nbt_name_refresh_wins_send(TALLOC_CTX *mem_ctx,
+                                             struct tevent_context *ev,
+                                             struct nbt_name_socket *nbtsock,
+                                             struct nbt_name_refresh_wins *io);
+NTSTATUS nbt_name_refresh_wins_recv(struct tevent_req *req,
+                                   TALLOC_CTX *mem_ctx,
+                                   struct nbt_name_refresh_wins *io);
+
+XFILE *startlmhosts(const char *fname);
+bool getlmhostsent(TALLOC_CTX *ctx, XFILE *fp, char **pp_name, int *name_type,
+               struct sockaddr_storage *pss);
+void endlmhosts(XFILE *fp);
+
+NTSTATUS resolve_lmhosts_file_as_sockaddr(const char *lmhosts_file, 
+                                         const char *name, int name_type,
+                                         TALLOC_CTX *mem_ctx, 
+                                         struct sockaddr_storage **return_iplist,
+                                         int *return_count);
 
 #endif /* __LIBNBT_H__ */