1 / 21

Module 10 – Protocol Compiling & Lower-level RPC Programming

Module 10 – Protocol Compiling & Lower-level RPC Programming. Objectives. rpcgen 에 대해 이해한다 . rpcgen 을 이용하여 간단한 프로그램을 작성한다 . RPCL 언어에 대해 이해하고 사용 방법을 기술한다 . low-level RPC 인터페이스에 대해 이해한다 . 간단한 low-level 응용 프로그램을 작성한다 . RPC Library Interface 에 대해 이해 한다. RPCGEN 을 이용한 응용 개발.

camila
Download Presentation

Module 10 – Protocol Compiling & Lower-level RPC Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Module 10 – Protocol Compiling & Lower-level RPC Programming

  2. Objectives • rpcgen에 대해 이해한다. • rpcgen을 이용하여 간단한 프로그램을 작성한다. • RPCL 언어에 대해 이해하고 사용 방법을 기술한다. • low-level RPC 인터페이스에 대해 이해한다. • 간단한 low-level 응용 프로그램을 작성한다. • RPC Library Interface 에 대해 이해 한다.

  3. RPCGEN을이용한응용개발 user developed RPC Specification rpcgen shared filters & header file client stub server stub compile and link compile and link client functions server functions RPC and data representation libraries client executable server executable

  4. Example - rpcgen • sqrt.x program SQRT_PROG { version SQRT_VERS { int getsqrt(int) = 1; } = 1; } = 0x20000088; • rpcgen에 의해 생성되는 파일 • sqrt.h • sqrt_clnt.c • sqrt_svc.c • sqrt_xdr.c

  5. Protocol Definition Language (RPCL) • XDR definition language의 확장된 형태 • 프로토콜을 정의할 때 사용 • C syntax와 유사 • 확장자로 .x를 사용 • RPCGEN으로 컴파일(C source & header file) • RPCL의 구성 요소 • Definitions (6 types) • Declarations (4 types) • Special cases (4 types)

  6. RPCL's definitions

  7. RPCL's definitions(cont')

  8. RPCL's declarations

  9. Low-level RPC 응용 프로그램 • 프로토콜정의프로그램(application.x) • RPCGEN으로프로토콜정의프로그램compile • XDR routine 생성(application_xdr.c) • 프로토콜정의에대한include file 생성(application.h) • client stub 생성(application_clnt.c) • server stub 생성(application_svc.c) • 서버서비스프로그램(application_svc_proc.c) • server stub의dispatch 루틴에의해서호출될함수 • 클라이언트프로그램(application.c)

  10. Client Side Function • clnt_create() #include <rpc/rpc.h> CLIENT clnt_create(host, prognum, versnum, protocol) • char *host; • u_long prognum, versnum; • char *protocol; • clnt_destroy() #include <rpc/rpc.h> void clnt_destroy(clnt) • CLIENT *clnt; • void svc_run() #include <rpc/rpc.h> bool_t clnt_control(clnt, request, info) • CLIENT *clnt; • int request; • char *info;

  11. Client Side Function • clnt_call() enum clnt_stat clnt_call(clnt, procnum, inproc, in, outproc, out, time out) • CLIENT *clnt; • u_long prognum; • xdrproc_t inproc, outproc; • char *in, *out; • struct timeval timeout; struct timeval { • long tv_sec; /* seconds */ • long tv_usec; /* and microseconds */ • }

  12. Server Side Function • svctcp_create() #include <rpc/rpc.h> SVCXPRT svctcp_create(sock, sendsz, recvsz) • int sock; • u_int sendz, recvsz; • svcudp_create() #include <rpc/rpc.h> SVCXPRT svcudp_create(sock) • int sock;

  13. Example Program Client your code, includes main() rls.c readdir_1() client stub generated by compiler rls_clnt.c XDR Filters generated by compiler Network RPC protocol rls_xdr.c Server XDR Filters generated by compiler server stub generated by compiler rls_svc.c readdir_1() your code service procedures rls_svc_proc.c

  14. rls.x • const MAXNAMELEN = 255; • typedef string nametype<MAXNAMELEN>; /* a directory entry */ • typedef struct namenode *namelist; /* a link in the listing */ • Struct namenode { • nametype name; /* name of directory entry */ • namelist pNext; /* next entry */ • }; • union readdir_res switch (int errno) { • case 0: • namelist list; /* no error: return directory listing */ • default: • void; /* error occurred: nothing else to return */ • }; • program DIRPROG { • version DIRVERS { • readdir_res READDIR(nametype) = 1; • } = 1; • } = 0x20000001;

More Related