Motr  M0
node_stub.c
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2013-2020 Seagate Technology LLC and/or its Affiliates
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * For any questions about this software or licensing,
18  * please email opensource@seagate.com or cortx-questions@seagate.com.
19  *
20  */
21 
22 
23 #include "lib/misc.h" /* M0_SET0 */
24 #include "lib/time.h" /* m0_time_t */
25 
26 #include "net/test/node_stub.h"
27 
28 
38 static void *node_stub_init(struct m0_net_test_service *svc)
39 {
40  return svc;
41 }
42 
43 static void node_stub_fini(void *ctx_)
44 {
45 }
46 
47 static int node_stub_step(void *ctx_)
48 {
49  return 0;
50 }
51 
52 static int node_stub_cmd_init(void *ctx_,
53  const struct m0_net_test_cmd *cmd,
54  struct m0_net_test_cmd *reply)
55 {
56  reply->ntc_type = M0_NET_TEST_CMD_INIT_DONE;
57  reply->ntc_done.ntcd_errno = 0;
58  return 0;
59 }
60 
61 static int node_stub_cmd_start(void *ctx_,
62  const struct m0_net_test_cmd *cmd,
63  struct m0_net_test_cmd *reply)
64 {
66  reply->ntc_done.ntcd_errno = 0;
67  return 0;
68 }
69 
70 static int node_stub_cmd_stop(void *ctx_,
71  const struct m0_net_test_cmd *cmd,
72  struct m0_net_test_cmd *reply)
73 {
75  reply->ntc_type = M0_NET_TEST_CMD_STOP_DONE;
76  reply->ntc_done.ntcd_errno = 0;
77  return 0;
78 }
79 
80 static int node_stub_cmd_status(void *ctx_,
81  const struct m0_net_test_cmd *cmd,
82  struct m0_net_test_cmd *reply)
83 {
84  struct m0_net_test_cmd_status_data *sd;
85 
87  sd = &reply->ntc_status_data;
88  M0_SET0(sd);
89  sd->ntcsd_finished = true;
92  M0_MKTIME(0, 1));
93  return 0;
94 }
95 
97  {
99  .ntsch_handler = node_stub_cmd_init,
100  },
101  {
102  .ntsch_type = M0_NET_TEST_CMD_START,
103  .ntsch_handler = node_stub_cmd_start,
104  },
105  {
106  .ntsch_type = M0_NET_TEST_CMD_STOP,
107  .ntsch_handler = node_stub_cmd_stop,
108  },
109  {
110  .ntsch_type = M0_NET_TEST_CMD_STATUS,
111  .ntsch_handler = node_stub_cmd_status,
112  },
113 };
114 
117  .ntso_fini = node_stub_fini,
118  .ntso_step = node_stub_step,
119  .ntso_cmd_handler = node_stub_cmd_handler,
120  .ntso_cmd_handler_nr = ARRAY_SIZE(node_stub_cmd_handler),
121 };
122 
127 /*
128  * Local variables:
129  * c-indentation-style: "K&R"
130  * c-basic-offset: 8
131  * tab-width: 8
132  * fill-column: 79
133  * scroll-step: 1
134  * End:
135  */
enum m0_net_test_cmd_type ntsch_type
Definition: service.h:52
static int node_stub_step(void *ctx_)
Definition: node_stub.c:47
void m0_net_test_service_state_change(struct m0_net_test_service *svc, enum m0_net_test_service_state state)
Definition: service.c:147
#define M0_SET0(obj)
Definition: misc.h:64
static struct m0_net_test_service_cmd_handler node_stub_cmd_handler[]
Definition: node_stub.c:96
static int node_stub_cmd_start(void *ctx_, const struct m0_net_test_cmd *cmd, struct m0_net_test_cmd *reply)
Definition: node_stub.c:61
static int node_stub_cmd_stop(void *ctx_, const struct m0_net_test_cmd *cmd, struct m0_net_test_cmd *reply)
Definition: node_stub.c:70
m0_time_t m0_time_now(void)
Definition: time.c:134
static void * node_stub_init(struct m0_net_test_service *svc)
Definition: node_stub.c:38
static int node_stub_cmd_init(void *ctx_, const struct m0_net_test_cmd *cmd, struct m0_net_test_cmd *reply)
Definition: node_stub.c:52
static void node_stub_fini(void *ctx_)
Definition: node_stub.c:43
m0_time_t m0_time_add(const m0_time_t t1, const m0_time_t t2)
Definition: time.c:47
static struct m0_net_test_service svc
Definition: service.c:34
#define M0_MKTIME(secs, ns)
Definition: time.h:86
static int node_stub_cmd_status(void *ctx_, const struct m0_net_test_cmd *cmd, struct m0_net_test_cmd *reply)
Definition: node_stub.c:80
void *(* ntso_init)(struct m0_net_test_service *svc)
Definition: service.h:76
static struct m0_dtm_oper_descr reply
Definition: transmit.c:94
#define ARRAY_SIZE(a)
Definition: misc.h:45
struct m0_net_test_service_ops m0_net_test_node_stub_ops
Definition: node_stub.c:115