📄 rpc.h
字号:
/*** Copyright 2002, Travis Geiselbrecht. All rights reserved.** Distributed under the terms of the NewOS License.*/#ifndef _RPC_H#define _RPC_H#include <kernel/kernel.h>#include <kernel/lock.h>#define RPC_PORT 111#define RPC_VERS 2typedef enum { RPC_CALL = 0, RPC_REPLY} rpc_msg_type;typedef enum { RPC_MSG_ACCEPTED = 0, RPC_MSG_DENIED} rpc_reply_stat;typedef enum { RPC_SUCCESS = 0, RPC_PROG_UNAVAIL, RPC_PROG_MISMATCH, RPC_PROC_UNAVAIL, RPC_GARBAGE_ARGS} rpc_accept_stat;typedef enum { RPC_MISMATCH = 0, RPC_AUTH_ERROR} rpc_reject_stat;typedef enum { RPC_AUTH_BADCRED = 0, RPC_AUTH_REJECTEDCRED, RPC_AUTH_BADVERF, RPC_AUTH_REJECTEDVERF, RPC_AUTH_TOOWEAK} rpc_auth_stat;typedef enum { RPC_AUTH_NULL = 0, RPC_AUTH_UNIX, RPC_AUTH_SHORT, RPC_AUTH_DES} rpc_auth_flavor;struct auth { rpc_auth_flavor auth_flavor; unsigned int auth_len; unsigned int data[0];};struct msg_header { unsigned int xid; rpc_msg_type msg_type;};struct call_body { unsigned int rpcvers; unsigned int prog; unsigned int vers; unsigned int proc; // insert auth here};#define RPC_BUF_LEN 8192typedef struct rpc_state { mutex lock; sockaddr server_addr; sock_id socket; unsigned int auth_cookie; unsigned char buf[RPC_BUF_LEN];} rpc_state;int rpc_init_state(rpc_state *state);int rpc_destroy_state(rpc_state *state);sock_id rpc_open_socket(rpc_state *state, netaddr *server_addr);int rpc_set_port(rpc_state *state, int port);int rpc_call(rpc_state *state, unsigned int prog, unsigned int vers, unsigned int proc, const void *out_data, int out_data_len, void *in_data, int in_data_len);#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -