Version 2 of YP uses TS-RPC and supports only IPv4 addresses. I am updating version 2 to use TI-RPC and adding support for IPv4/IPv6 in version 3.
Compile
- cd /usr/src/include/rpcsvc/ && make all install // Header
- cd /usr/src/lib/libc/ && make all install // Linker, met error
yp_xdr.c:277:2: error: must use 'struct' tag to refer to type 'netbuf' 277 | netbuf **pp = &objp->ypbind_svcaddr; | ^ | struct 1 error generated. *** Error code 1 Stop. make: stopped in /usr/src/lib/libc
- cd /usr/src/usr.sbin/ypbind/ && make all install // ypbind (RPC client)
TI-RPC Changes
- I replaced svcudp_create and svctcp_create with getnetconfig, svc_tp_create, and svc_reg within a while loop. This change binds version 3 of ypbind on every netconfig and binds version 2 of ypbind specifically on IPv4 over UDP/TCP.
- I use rpcb_unset nstead of pmap_unset to unset any program before registering in the main and terminate functions. pmap_unset uses portmap to unset, while rpcb_unset uses rpcbind to unset the mapper.
- Replaced clntudp_bufcreate with clnt_dg_create. Added a timeout using clnt_control because clnt_dg_create lacks a timeout parameter.
- Replaced clntudp_create with clnt_create.
- Replaced clnt_broadcast with rpc_broadcast. clnt_broadcast only broadcasts to portmap, whereas rpc_broadcast broadcasts to both portmap and rpcbind.
Version 3 ypbind
- I have included some version 3 data structures in "yp.x".
- Use new _dom_binding. It is very similar to the old one, except for the address. Version 3 uses a new data structure, ypbind_binding_3, to represent addresses.
- Use ypbind_setdom_3 to replace ypbind_setdom. The difference is that version 3 uses the new ypbind_binding_3 structure.
- Use ypbind_resp_3 to replace ypbind_resp, with the main difference still being ypbind_binding_3.
- I have added version 3 functions like ypbindprog_3, ypbindproc_domain_3_yp, and ypbindproc_setdom_3_yp, following Sun's implementation. In their code, version 2 structures are converted to version 3 structures before calling version 3 functions.
- I also revised the "yp_ping.c" function to support struct sockaddr *.
I couldn't fully test it as my test environment does not have a YP server.