client->is_finished = 1;
}
+void pmap3_getaddr_cb(struct rpc_context *rpc, int status, void *data, void *private_data)
+{
+ struct client *client = private_data;
+ struct pmap3_getaddr_result *gar = data;
+
+ if (status == RPC_STATUS_ERROR) {
+ printf("PORTMAP3/GETADDR call failed with \"%s\"\n", (char *)data);
+ exit(10);
+ }
+ if (status != RPC_STATUS_SUCCESS) {
+ printf("PORTMAP3/GETADDR call failed, status:%d\n", status);
+ exit(10);
+ }
+
+ printf("PORTMAP3/GETADDR:\n");
+ printf(" Addr:%s\n", gar->addr);
+
+ client->is_finished = 1;
+}
+
void pmap2_null_cb(struct rpc_context *rpc, int status, void *data, void *private_data)
{
struct client *client = private_data;
int null2 = 0;
int dump2 = 0;
int null3 = 0;
+ int getaddr3 = 0;
int dump3 = 0;
int command_found = 0;
+ int getaddr3prog, getaddr3vers;
+ char *getaddr3netid;
+
rpc = rpc_init_context();
if (rpc == NULL) {
printf("failed to init context\n");
} else if (!strcmp(argv[i], "dump3")) {
dump3 = 1;
command_found++;
+ } else if (!strcmp(argv[i], "getaddr3")) {
+ getaddr3 = 1;
+ getaddr3prog = atoi(argv[++i]);
+ getaddr3vers = atoi(argv[++i]);
+ getaddr3netid = argv[++i];
+ command_found++;
} else if (!strcmp(argv[i], "null3")) {
null3 = 1;
command_found++;
}
wait_until_finished(rpc, &client);
}
+ if (getaddr3) {
+ struct pmap3_mapping map;
+
+ map.prog=getaddr3prog;
+ map.vers=getaddr3vers;
+ map.netid=getaddr3netid;
+ map.addr="";
+ map.owner="";
+ if (rpc_pmap3_getaddr_async(rpc, &map, pmap3_getaddr_cb, &client) != 0) {
+ printf("Failed to send GETADDR3 request\n");
+ exit(10);
+ }
+ wait_until_finished(rpc, &client);
+ }
rpc_destroy_context(rpc);
*/
EXTERN int rpc_pmap3_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
+/*
+ * Call PORTMAPPER3/GETADDR.
+ * Function returns
+ * 0 : The connection was initiated. Once the connection establish finishes, the callback will be invoked.
+ * <0 : An error occured when trying to set up the connection. The callback will not be invoked.
+ *
+ * When the callback is invoked, status indicates the result:
+ * RPC_STATUS_SUCCESS : We got a successful response from the portmapper daemon.
+ * data is struct pmap3_getaddr_result.
+ * RPC_STATUS_ERROR : An error occured when trying to contact the portmapper.
+ * data is the error string.
+ * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
+ * data is NULL.
+ */
+struct pmap3_mapping;
+EXTERN int rpc_pmap3_getaddr_async(struct rpc_context *rpc, struct pmap3_mapping *map, rpc_cb cb, void *private_data);
+
/*
* Call PORTMAPPER3/DUMP.
* Function returns
rpc_pmap2_unset_async
rpc_pmap2_dump_async
rpc_pmap2_callit_async
+rpc_pmap3_null_async
+rpc_pmap3_getaddr_async
+rpc_pmap3_dump_async
rpc_mount_null_async
rpc_mount_mnt_async
rpc_mount_dump_async
return TRUE;
}
+bool_t
+zdr_pmap3_getaddr_result (ZDR *zdrs, pmap3_getaddr_result *objp)
+{
+ register int32_t *buf;
+ buf = NULL;
+
+ if (!zdr_string (zdrs, &objp->addr, ~0))
+ return FALSE;
+ return TRUE;
+}
+
bool_t
zdr_pmap3_mapping (ZDR *zdrs, pmap3_mapping *objp)
{
};
typedef struct pmap2_dump_result pmap2_dump_result;
+struct pmap3_getaddr_result {
+ char *addr;
+};
+typedef struct pmap3_getaddr_result pmap3_getaddr_result;
+
struct pmap3_mapping {
u_int prog;
u_int vers;
#define PMAP3_NULL 0
extern void * pmap3_null_3(void *, CLIENT *);
extern void * pmap3_null_3_svc(void *, struct svc_req *);
+#define PMAP3_GETADDR 3
+extern pmap3_getaddr_result * pmap3_getaddr_3(pmap3_mapping *, CLIENT *);
+extern pmap3_getaddr_result * pmap3_getaddr_3_svc(pmap3_mapping *, struct svc_req *);
#define PMAP3_DUMP 4
extern pmap3_dump_result * pmap3_dump_3(void *, CLIENT *);
extern pmap3_dump_result * pmap3_dump_3_svc(void *, struct svc_req *);
#define PMAP3_NULL 0
extern void * pmap3_null_3();
extern void * pmap3_null_3_svc();
+#define PMAP3_GETADDR 3
+extern pmap3_getaddr_result * pmap3_getaddr_3();
+extern pmap3_getaddr_result * pmap3_getaddr_3_svc();
#define PMAP3_DUMP 4
extern pmap3_dump_result * pmap3_dump_3();
extern pmap3_dump_result * pmap3_dump_3_svc();
extern bool_t zdr_pmap2_call_result (ZDR *, pmap2_call_result*);
extern bool_t zdr_pmap2_mapping_list (ZDR *, pmap2_mapping_list*);
extern bool_t zdr_pmap2_dump_result (ZDR *, pmap2_dump_result*);
+extern bool_t zdr_pmap3_getaddr_result (ZDR *, pmap3_getaddr_result*);
extern bool_t zdr_pmap3_mapping (ZDR *, pmap3_mapping*);
extern bool_t zdr_pmap3_mapping_list (ZDR *, pmap3_mapping_list*);
extern bool_t zdr_pmap3_dump_result (ZDR *, pmap3_dump_result*);
extern bool_t zdr_pmap2_call_result ();
extern bool_t zdr_pmap2_mapping_list ();
extern bool_t zdr_pmap2_dump_result ();
+extern bool_t zdr_pmap3_getaddr_result ();
extern bool_t zdr_pmap3_mapping ();
extern bool_t zdr_pmap3_mapping_list ();
extern bool_t zdr_pmap3_dump_result ();
return 0;
}
+int rpc_pmap3_getaddr_async(struct rpc_context *rpc, struct pmap3_mapping *map, rpc_cb cb, void *private_data)
+{
+ struct rpc_pdu *pdu;
+
+ pdu = rpc_allocate_pdu(rpc, PMAP_PROGRAM, PMAP_V3, PMAP3_GETADDR, cb, private_data, (zdrproc_t)zdr_pmap3_getaddr_result, sizeof(pmap3_getaddr_result));
+ if (pdu == NULL) {
+ rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for PORTMAP3/GETADDR call");
+ return -1;
+ }
+
+ if (zdr_pmap3_mapping(&pdu->zdr, map) == 0) {
+ rpc_set_error(rpc, "ZDR error: Failed to encode data for PORTMAP3/GETADDR call");
+ rpc_free_pdu(rpc, pdu);
+ return -1;
+ }
+
+ if (rpc_queue_pdu(rpc, pdu) != 0) {
+ rpc_set_error(rpc, "Failed to queue PORTMAP3/GETADDR pdu");
+ rpc_free_pdu(rpc, pdu);
+ return -1;
+ }
+
+ return 0;
+}
+
int rpc_pmap3_dump_async(struct rpc_context *rpc, rpc_cb cb, void *private_data)
{
struct rpc_pdu *pdu;
struct pmap2_mapping_list *list;
};
+struct pmap3_getaddr_result {
+ string addr<>;
+};
+
struct pmap3_mapping {
unsigned int prog;
unsigned int vers;
PMAP2_GETPORT(pmap2_mapping) = 3;
pmap2_dump_result
- PMAP2_DUMP(void) = 4;
+ PMAP2_DUMP(void) = 4;
pmap2_call_result
PMAP2_CALLIT(pmap2_call_args) = 5;
void
PMAP3_NULL(void) = 0;
+ pmap3_getaddr_result
+ PMAP3_GETADDR(pmap3_mapping) = 3;
+
pmap3_dump_result
PMAP3_DUMP(void) = 4;
-
} = 3;
} = 100000;