MCPcopy Create free account
hub / github.com/EIPStackGroup/OpENer / NotifyMessageRouter

Function NotifyMessageRouter

source/src/cip/cipmessagerouter.c:173–243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

171}
172
173EipStatus NotifyMessageRouter(EipUint8 *data,
174 int data_length,
175 const struct sockaddr *const originator_address,
176 const int encapsulation_session) {
177 EipStatus eip_status = kEipStatusOkSend;
178 EipByte status = kCipErrorSuccess;
179
180 g_message_router_response.data = g_message_data_reply_buffer; /* set reply buffer, using a fixed buffer (about 100 bytes) */
181
182 OPENER_TRACE_INFO("NotifyMessageRouter: routing unconnected message\n");
183 if ( kCipErrorSuccess
184 != ( status = CreateMessageRouterRequestStructure(
185 data, data_length, &g_message_router_request) ) ) { /* error from create MR structure*/
186 OPENER_TRACE_ERR(
187 "NotifyMessageRouter: error from createMRRequeststructure\n");
188 g_message_router_response.general_status = status;
189 g_message_router_response.size_of_additional_status = 0;
190 g_message_router_response.reserved = 0;
191 g_message_router_response.data_length = 0;
192 g_message_router_response.reply_service = (0x80
193 | g_message_router_request.
194 service);
195 } else {
196 /* forward request to appropriate Object if it is registered*/
197 CipMessageRouterObject *registered_object = GetRegisteredObject(
198 g_message_router_request.request_path.class_id);
199 if (registered_object == 0) {
200 OPENER_TRACE_ERR(
201 "NotifyMessageRouter: sending CIP_ERROR_OBJECT_DOES_NOT_EXIST reply, class id 0x%x is not registered\n",
202 (unsigned ) g_message_router_request.request_path.class_id);
203 g_message_router_response.general_status =
204 kCipErrorPathDestinationUnknown; /*according to the test tool this should be the correct error flag instead of CIP_ERROR_OBJECT_DOES_NOT_EXIST;*/
205 g_message_router_response.size_of_additional_status = 0;
206 g_message_router_response.reserved = 0;
207 g_message_router_response.data_length = 0;
208 g_message_router_response.reply_service = (0x80
209 | g_message_router_request.
210 service);
211 } else {
212 /* call notify function from Object with ClassID (gMRRequest.RequestPath.ClassID)
213 object will or will not make an reply into gMRResponse*/
214 g_message_router_response.reserved = 0;
215 OPENER_ASSERT(NULL != registered_object->cip_class)
216 OPENER_TRACE_INFO(
217 "NotifyMessageRouter: calling notify function of class '%s'\n",
218 registered_object->cip_class->class_name);
219 eip_status = NotifyClass(registered_object->cip_class,
220 &g_message_router_request,
221 &g_message_router_response,
222 originator_address,
223 encapsulation_session);
224
225#ifdef OPENER_TRACE_ENABLED
226 if (eip_status == kEipStatusError) {
227 OPENER_TRACE_ERR(
228 "notifyMR: notify function of class '%s' returned an error\n",
229 registered_object->cip_class->class_name);
230 } else if (eip_status == kEipStatusOk) {

Callers 2

NotifyCommonPacketFormatFunction · 0.85

Calls 3

GetRegisteredObjectFunction · 0.85
NotifyClassFunction · 0.85

Tested by

no test coverage detected