Skip to content

Commit

Permalink
Add support for PMAP2 SET operation to the portmapper client
Browse files Browse the repository at this point in the history
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
  • Loading branch information
sahlberg committed Dec 17, 2016
1 parent 6d39702 commit 34926e9
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions examples/portmap-client.c
Expand Up @@ -128,6 +128,26 @@ void pmap3_getaddr_cb(struct rpc_context *rpc, int status, void *data, void *pri
client->is_finished = 1;
}

void pmap2_set_cb(struct rpc_context *rpc, int status, void *data, void *private_data)
{
struct client *client = private_data;
uint32_t res = *(uint32_t *)data;

if (status == RPC_STATUS_ERROR) {
printf("PORTMAP2/SET call failed with \"%s\"\n", (char *)data);
exit(10);
}
if (status != RPC_STATUS_SUCCESS) {
printf("PORTMAP2/SET call failed, status:%d\n", status);
exit(10);
}

printf("PORTMAP2/SET:\n");
printf(" Res:%d\n", res);

client->is_finished = 1;
}

void pmap3_set_cb(struct rpc_context *rpc, int status, void *data, void *private_data)
{
struct client *client = private_data;
Expand Down Expand Up @@ -329,6 +349,7 @@ int main(int argc _U_, char *argv[] _U_)
int null2 = 0;
int dump2 = 0;
int null3 = 0;
int set2 = 0;
int set3 = 0;
int unset3 = 0;
int getaddr3 = 0;
Expand All @@ -337,6 +358,7 @@ int main(int argc _U_, char *argv[] _U_)
int u2t3 = 0;
int command_found = 0;

int set2prog, set2vers, set2prot, set2port;
int set3prog, set3vers;
char *set3netid, *set3addr, *set3owner;
int unset3prog, unset3vers;
Expand Down Expand Up @@ -365,6 +387,13 @@ int main(int argc _U_, char *argv[] _U_)
} else if (!strcmp(argv[i], "null2")) {
null2 = 1;
command_found++;
} else if (!strcmp(argv[i], "set2")) {
set2 = 1;
set2prog = atoi(argv[++i]);
set2vers = atoi(argv[++i]);
set2prot = atoi(argv[++i]);
set2port = atoi(argv[++i]);
command_found++;
} else if (!strcmp(argv[i], "dump3")) {
dump3 = 1;
command_found++;
Expand Down Expand Up @@ -465,6 +494,13 @@ int main(int argc _U_, char *argv[] _U_)
}
wait_until_finished(rpc, &client);
}
if (set2) {
if (rpc_pmap2_set_async(rpc, set2prog, set2vers, set2prot, set2port, pmap2_set_cb, &client) != 0) {
printf("Failed to send SET2 request\n");
exit(10);
}
wait_until_finished(rpc, &client);
}
if (set3) {
struct pmap3_mapping map;

Expand Down

0 comments on commit 34926e9

Please sign in to comment.