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"
24 extern int torture_numops;
26 bool run_addrchange(int dummy)
28 struct addrchange_context *ctx;
29 struct tevent_context *ev;
33 ev = tevent_context_init(talloc_tos());
35 d_fprintf(stderr, "tevent_context_init failed\n");
39 status = addrchange_context_create(talloc_tos(), &ctx);
40 if (!NT_STATUS_IS_OK(status)) {
41 d_fprintf(stderr, "addrchange_context_create failed: %s\n",
46 for (i=0; i<torture_numops; i++) {
47 enum addrchange_type type;
48 struct sockaddr_storage addr;
49 struct tevent_req *req;
51 char addrstr[INET6_ADDRSTRLEN];
53 req = addrchange_send(talloc_tos(), ev, ctx);
55 d_fprintf(stderr, "addrchange_send failed\n");
59 if (!tevent_req_poll_ntstatus(req, ev, &status)) {
60 d_fprintf(stderr, "tevent_req_poll_ntstatus failed: "
61 "%s\n", nt_errstr(status));
66 status = addrchange_recv(req, &type, &addr);
68 if (!NT_STATUS_IS_OK(status)) {
69 d_fprintf(stderr, "addrchange_recv failed: %s\n",
82 typestr = talloc_asprintf(talloc_tos(), "unknown %d",
87 printf("Got %s %s\n", typestr,
88 print_sockaddr(addrstr, sizeof(addrstr), &addr));