2 Unix SMB/CIFS implementation.
3 test for the addrchange functionality
4 Copyright (C) Volker Lendecke 2011
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 3 of the License, or
9 (at your option) any later version.
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.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "lib/addrchange.h"
22 #include "lib/util/tevent_ntstatus.h"
25 extern int torture_numops
;
27 bool run_addrchange(int dummy
)
29 struct addrchange_context
*ctx
;
30 struct tevent_context
*ev
;
34 ev
= samba_tevent_context_init(talloc_tos());
36 d_fprintf(stderr
, "tevent_context_init failed\n");
40 status
= addrchange_context_create(talloc_tos(), &ctx
);
41 if (!NT_STATUS_IS_OK(status
)) {
42 d_fprintf(stderr
, "addrchange_context_create failed: %s\n",
47 for (i
=0; i
<torture_numops
; i
++) {
48 enum addrchange_type type
;
49 struct sockaddr_storage addr
;
50 struct tevent_req
*req
;
52 char addrstr
[INET6_ADDRSTRLEN
];
54 req
= addrchange_send(talloc_tos(), ev
, ctx
);
56 d_fprintf(stderr
, "addrchange_send failed\n");
60 if (!tevent_req_poll_ntstatus(req
, ev
, &status
)) {
61 d_fprintf(stderr
, "tevent_req_poll_ntstatus failed: "
62 "%s\n", nt_errstr(status
));
67 status
= addrchange_recv(req
, &type
, &addr
);
69 if (!NT_STATUS_IS_OK(status
)) {
70 d_fprintf(stderr
, "addrchange_recv failed: %s\n",
83 typestr
= talloc_asprintf(talloc_tos(), "unknown %d",
88 printf("Got %s %s\n", typestr
,
89 print_sockaddr(addrstr
, sizeof(addrstr
), &addr
));