Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix data parameter for attribute decoding functions. #497

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions source/src/cip/cipassembly.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* @return length of taken bytes
* -1 .. error
*/
int DecodeCipAssemblyAttribute3(CipByteArray *const data,
int DecodeCipAssemblyAttribute3(void *const data,
CipMessageRouterRequest *const message_router_request,
CipMessageRouterResponse *const message_router_response);

Expand Down Expand Up @@ -152,7 +152,7 @@ EipStatus NotifyAssemblyConnectedDataReceived(CipInstance *const instance,
return AfterAssemblyDataReceived(instance);
}

int DecodeCipAssemblyAttribute3(CipByteArray *const data,
int DecodeCipAssemblyAttribute3(void *const data,
CipMessageRouterRequest *const message_router_request,
CipMessageRouterResponse *const message_router_response)
{
Expand All @@ -163,15 +163,15 @@ int DecodeCipAssemblyAttribute3(CipByteArray *const data,

int number_of_decoded_bytes = -1;
OPENER_TRACE_INFO(" -> set Assembly attribute byte array\r\n");
CipByteArray *cip_byte_array = data;
CipByteArray *cip_byte_array = (CipByteArray *)data;

if(message_router_request->request_data_size < data->length) {
if(message_router_request->request_data_size < cip_byte_array->length) {
OPENER_TRACE_INFO(
"DecodeCipByteArray: not enough data received.\n");
message_router_response->general_status = kCipErrorNotEnoughData;
return number_of_decoded_bytes;
}
if(message_router_request->request_data_size > data->length) {
if(message_router_request->request_data_size > cip_byte_array->length) {
OPENER_TRACE_INFO(
"DecodeCipByteArray: too much data received.\n");
message_router_response->general_status = kCipErrorTooMuchData;
Expand Down
4 changes: 2 additions & 2 deletions source/src/cip/cipqos.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ static CipQosDscpValues s_active_dscp = {
* @return length of taken bytes
* -1 .. error
*/
int DecodeCipQoSAttribute(CipUsint *const data,
int DecodeCipQoSAttribute(void *const data,
CipMessageRouterRequest *const message_router_request,
CipMessageRouterResponse *const message_router_response) {

Expand All @@ -81,7 +81,7 @@ int DecodeCipQoSAttribute(CipUsint *const data,
CipUsint attribute_value_received = GetUsintFromMessage(&cip_message);
if (attribute_value_received < 64U) {

*data = attribute_value_received; //write value to attribute
*(CipUsint *)data = attribute_value_received; //write value to attribute

message_router_response->general_status = kCipErrorSuccess;
number_of_decoded_bytes = 1;
Expand Down
8 changes: 4 additions & 4 deletions source/src/cip/ciptcpipinterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ void EncodeCipLastConflictDetected(const void *const data,


int DecodeTcpIpInterfaceConfigurationControl( /* Attribute 3 */
CipDword *const data,
void *const data,
CipMessageRouterRequest *const message_router_request,
CipMessageRouterResponse *const message_router_response) {

Expand All @@ -392,7 +392,7 @@ int DecodeTcpIpInterfaceConfigurationControl( /* Attribute 3 */
configuration_control_received &= (kTcpipCfgCtrlMethodMask
| kTcpipCfgCtrlDnsEnable);

*data = configuration_control_received;
*(CipDword *)data = configuration_control_received;
number_of_decoded_bytes = 4;
message_router_response->general_status = kCipErrorSuccess;
}
Expand Down Expand Up @@ -510,7 +510,7 @@ int DecodeCipTcpIpInterfaceHostName( /* Attribute 6 */
#endif /* defined (OPENER_TCPIP_IFACE_CFG_SETTABLE) && 0 != OPENER_TCPIP_IFACE_CFG_SETTABLE*/

int DecodeCipTcpIpInterfaceEncapsulationInactivityTimeout( /* Attribute 13 */
CipUint *const data,
void *const data,
CipMessageRouterRequest *const message_router_request,
CipMessageRouterResponse *const message_router_response) {

Expand All @@ -524,7 +524,7 @@ int DecodeCipTcpIpInterfaceEncapsulationInactivityTimeout( /* Attribute 13 */
kCipErrorInvalidAttributeValue;
} else {

*data = inactivity_timeout_received;
*(CipUint *)data = inactivity_timeout_received;
message_router_response->general_status = kCipErrorSuccess;
number_of_decoded_bytes = 2;

Expand Down
2 changes: 1 addition & 1 deletion source/src/cip/ciptypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ typedef void (*CipAttributeEncodeInMessage)(const void *const data,
ENIPMessage *const outgoing_message);

/** @brief self-describing data decoding for CIP types */
typedef int (*CipAttributeDecodeFromMessage)(const void *const data,
typedef int (*CipAttributeDecodeFromMessage)(void *const data,
CipMessageRouterRequest *
const message_router_request,
CipMessageRouterResponse *const
Expand Down
Loading