client->is_finished = 1;
}
+void pmap3_uaddr2taddr_cb(struct rpc_context *rpc, int status, void *data, void *private_data)
+{
+ struct client *client = private_data;
+ struct pmap3_netbuf *nb = data;
+ int i;
+
+ if (status == RPC_STATUS_ERROR) {
+ printf("PORTMAP3/UADDR2TADDR call failed with \"%s\"\n", (char *)data);
+ exit(10);
+ }
+ if (status != RPC_STATUS_SUCCESS) {
+ printf("PORTMAP3/UADDR2TADDR call failed, status:%d\n", status);
+ exit(10);
+ }
+
+ printf("PORTMAP3/UADDR2TADDR:\n");
+ printf(" MaxLen:%d\n", nb->maxlen);
+ printf(" ");
+ for (i = 0; i < nb->maxlen; i++) {
+ printf("%02x ", nb->buf.buf_val[i]);
+ if (i %16 == 15) {
+ printf("\n ");
+ }
+ }
+ printf("\n");
+ 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 getaddr3 = 0;
int dump3 = 0;
int gettime3 = 0;
+ int u2t3 = 0;
int command_found = 0;
int getaddr3prog, getaddr3vers;
char *getaddr3netid;
+ char *u2t3string;
rpc = rpc_init_context();
if (rpc == NULL) {
} else if (!strcmp(argv[i], "gettime3")) {
gettime3 = 1;
command_found++;
+ } else if (!strcmp(argv[i], "u2t3")) {
+ u2t3 = 1;
+ u2t3string = argv[++i];
+ command_found++;
} else if (!strcmp(argv[i], "getaddr3")) {
getaddr3 = 1;
getaddr3prog = atoi(argv[++i]);
}
wait_until_finished(rpc, &client);
}
+ if (u2t3) {
+ if (rpc_pmap3_uaddr2taddr_async(rpc, u2t3string, pmap3_uaddr2taddr_cb, &client) != 0) {
+ printf("Failed to send UADDR2TADDR3 request\n");
+ exit(10);
+ }
+ wait_until_finished(rpc, &client);
+ }
if (getaddr3) {
struct pmap3_mapping map;
*/
EXTERN int rpc_pmap3_gettime_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
+/*
+ * Call PORTMAPPER3/UADDR2TADDR.
+ * 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 a struct pmap3_netbuf *.
+ * 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.
+ */
+EXTERN int rpc_pmap3_uaddr2taddr_async(struct rpc_context *rpc, char *uaddr, rpc_cb cb, void *private_data);
+
/*
* MOUNT v3 FUNCTIONS
*/
rpc_pmap3_dump_async
rpc_pmap3_callit_async
rpc_pmap3_gettime_async
+rpc_pmap3_uaddr2taddr_async
rpc_mount_null_async
rpc_mount_mnt_async
rpc_mount_dump_async
return FALSE;
return TRUE;
}
+
+bool_t
+zdr_pmap3_netbuf (ZDR *zdrs, pmap3_netbuf *objp)
+{
+ register int32_t *buf;
+ buf = NULL;
+
+ if (!zdr_u_int (zdrs, &objp->maxlen))
+ return FALSE;
+ if (!zdr_bytes (zdrs, (char **)&objp->buf.buf_val, (u_int *) &objp->buf.buf_len, ~0))
+ return FALSE;
+ return TRUE;
+}
};
typedef struct pmap3_call_result pmap3_call_result;
+struct pmap3_netbuf {
+ u_int maxlen;
+ struct {
+ u_int buf_len;
+ char *buf_val;
+ } buf;
+};
+typedef struct pmap3_netbuf pmap3_netbuf;
+
#define PMAP_PROGRAM 100000
#define PMAP_V2 2
#define PMAP3_GETTIME 6
extern u_int * pmap3_gettime_3(void *, CLIENT *);
extern u_int * pmap3_gettime_3_svc(void *, struct svc_req *);
+#define PMAP3_UADDR2TADDR 7
+extern pmap3_netbuf * pmap3_uaddr2taddr_3(char **, CLIENT *);
+extern pmap3_netbuf * pmap3_uaddr2taddr_3_svc(char **, struct svc_req *);
extern int pmap_program_3_freeresult (SVCXPRT *, zdrproc_t, caddr_t);
#else /* K&R C */
#define PMAP3_GETTIME 6
extern u_int * pmap3_gettime_3();
extern u_int * pmap3_gettime_3_svc();
+#define PMAP3_UADDR2TADDR 7
+extern pmap3_netbuf * pmap3_uaddr2taddr_3();
+extern pmap3_netbuf * pmap3_uaddr2taddr_3_svc();
extern int pmap_program_3_freeresult ();
#endif /* K&R C */
extern bool_t zdr_pmap3_dump_result (ZDR *, pmap3_dump_result*);
extern bool_t zdr_pmap3_call_args (ZDR *, pmap3_call_args*);
extern bool_t zdr_pmap3_call_result (ZDR *, pmap3_call_result*);
+extern bool_t zdr_pmap3_netbuf (ZDR *, pmap3_netbuf*);
#else /* K&R C */
extern bool_t zdr_pmap2_mapping ();
extern bool_t zdr_pmap3_dump_result ();
extern bool_t zdr_pmap3_call_args ();
extern bool_t zdr_pmap3_call_result ();
+extern bool_t zdr_pmap3_netbuf ();
#endif /* K&R C */
return 0;
}
+
+int rpc_pmap3_uaddr2taddr_async(struct rpc_context *rpc, char *uaddr, rpc_cb cb, void *private_data)
+{
+ struct rpc_pdu *pdu;
+
+ pdu = rpc_allocate_pdu(rpc, PMAP_PROGRAM, PMAP_V3, PMAP3_UADDR2TADDR, cb, private_data, (zdrproc_t)zdr_pmap3_netbuf, sizeof(pmap3_netbuf));
+ if (pdu == NULL) {
+ rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for PORTMAP3/UADDR2TADDR call");
+ return -1;
+ }
+
+ if (zdr_string(&pdu->zdr, &uaddr, 255) == 0) {
+ rpc_set_error(rpc, "ZDR error: Failed to encode data for PORTMAP3/UADDR2TADDR call");
+ rpc_free_pdu(rpc, pdu);
+ return -1;
+ }
+
+ if (rpc_queue_pdu(rpc, pdu) != 0) {
+ rpc_set_error(rpc, "Failed to queue PORTMAP3/UADDR2TADDR pdu: %s", rpc_get_error(rpc));
+ return -1;
+ }
+
+ return 0;
+}
opaque res<>;
};
+struct pmap3_netbuf {
+ unsigned int maxlen;
+ opaque buf<>;
+};
+
program PMAP_PROGRAM {
version PMAP_V2 {
void
unsigned int
PMAP3_GETTIME(void) = 6;
+
+ pmap3_netbuf
+ PMAP3_UADDR2TADDR(string) = 7;
} = 3;
} = 100000;