Trusted Solaris 開発ガイド

サーバープログラム

サーバープログラムは、すべてのセキュリティ属性に割り当てられた領域を指すようにサーバーハンドルを設定します。

#include <stdio.h>
 #include <stdlib.h>
 #include <rpc/rpc.h>
 #include <tsix/t6attrs.h>
 #include "rpc_test.h"
 static void proc_1(struct svc_req *rqstp, SVCXPRT *transp);
 extern int
 main(int argc, char *argv[])
 {
 	SVCXPRT *handlep;
 	struct netconfig *netconfigp;
 	netconfigp = getnetconfigent("udp");
 	if (netconfigp == NULL) {
 			fprintf(stderr, "Cannot find netconfig entry for udp.¥n");
 			exit(1);
 	}

 	handlep = svc_tp_create(proc_1, RPC_TEST_PROG,
 			RPC_TEST_VERS, netconfigp);

 	if (handlep == NULL) {
 			fprintf(stderr, "Cannot create service.¥n");
 			exit(1);
 	}
 	freenetconfigent(netconfigp);
 	handlep->xp_tsol_incoming_attrsp = t6alloc_blk(T6M_ALL_ATTRS);
 	if (handlep->xp_tsol_incoming_attrsp == NULL) {
 			fprintf(stderr, "Can't create attr buffer¥n");
 			exit(1);
 	}
 	svc_run();
 	return (0);
 }