0dca57926d69e8b8b5d193ed7a2339b3a87ff139
[jra/samba/.git] / source4 / libnet / libnet.c
1 /* 
2    Unix SMB/CIFS implementation.
3    
4    Copyright (C) Stefan Metzmacher      2004
5    
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10    
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15    
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21 #include "includes.h"
22 #include "libnet/libnet.h"
23 #include "lib/events/events.h"
24
25 struct libnet_context *libnet_context_init(struct event_context *ev)
26 {
27         struct libnet_context *ctx;
28
29         /* create brand new libnet context */ 
30         ctx = talloc(NULL, struct libnet_context);
31         if (!ctx) {
32                 return NULL;
33         }
34
35         /* events */
36         if (ev == NULL) {
37                 ev = event_context_find(ctx);
38                 if (ev == NULL) {
39                         talloc_free(ctx);
40                         return NULL;
41                 }
42         }
43         ctx->event_ctx = ev;
44
45         /* name resolution methods */
46         ctx->name_res_methods = str_list_copy(ctx, lp_name_resolve_order());
47
48         /* connected domain params */
49         ZERO_STRUCT(ctx->domain);
50
51         /* currently opened user */
52         ZERO_STRUCT(ctx->user_handle);
53
54         /* init pipe pointers */
55         ctx->samr_pipe = NULL;
56         ctx->lsa_pipe  = NULL;
57         ctx->pipe      = NULL;
58         
59         return ctx;
60 }