Skip to content

Commit

Permalink
Create data type to ensure uniform session handle data types.
Browse files Browse the repository at this point in the history
Resolves compiler warnings about converting size_t to other integer types;
size_t isn't really appropriate for session handles anyway.
  • Loading branch information
jvalenzuela authored and MartinMelikMerkumians committed Feb 23, 2024
1 parent 47fe3cf commit 51c3d96
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 52 deletions.
18 changes: 9 additions & 9 deletions source/src/cip/cipcommon.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ EipStatus NotifyClass(const CipClass *RESTRICT const cip_class,
CipMessageRouterRequest *const message_router_request,
CipMessageRouterResponse *const message_router_response,
const struct sockaddr *originator_address,
const int encapsulation_session) {
const CipSessionHandle encapsulation_session) {

/* find the instance: if instNr==0, the class is addressed, else find the instance */
CipInstanceNum instance_number =
Expand Down Expand Up @@ -528,7 +528,7 @@ EipStatus GetAttributeSingle(CipInstance *RESTRICT const instance,
CipMessageRouterRequest *const message_router_request,
CipMessageRouterResponse *const message_router_response,
const struct sockaddr *originator_address,
const int encapsulation_session) {
const CipSessionHandle encapsulation_session) {
/* Suppress unused parameter compiler warning. */
(void) originator_address;
(void) encapsulation_session;
Expand Down Expand Up @@ -782,7 +782,7 @@ EipStatus SetAttributeSingle(CipInstance *RESTRICT const instance,
CipMessageRouterRequest *const message_router_request,
CipMessageRouterResponse *const message_router_response,
const struct sockaddr *originator_address,
const int encapsulation_session) {
const CipSessionHandle encapsulation_session) {
/* Suppress unused parameter compiler warning. */
(void)originator_address;
(void)encapsulation_session;
Expand Down Expand Up @@ -1074,7 +1074,7 @@ EipStatus GetAttributeAll(CipInstance *instance,
CipMessageRouterRequest *message_router_request,
CipMessageRouterResponse *message_router_response,
const struct sockaddr *originator_address,
const int encapsulation_session) {
const CipSessionHandle encapsulation_session) {
/* Suppress unused parameter compiler warning. */
(void)originator_address;
(void)encapsulation_session;
Expand Down Expand Up @@ -1115,7 +1115,7 @@ EipStatus GetAttributeList(CipInstance *instance,
CipMessageRouterRequest *message_router_request,
CipMessageRouterResponse *message_router_response,
const struct sockaddr *originator_address,
const int encapsulation_session) {
const CipSessionHandle encapsulation_session) {
/* Suppress unused parameter compiler warning. */
(void)originator_address;
(void)encapsulation_session;
Expand Down Expand Up @@ -1221,7 +1221,7 @@ EipStatus SetAttributeList(CipInstance *instance,
CipMessageRouterRequest *message_router_request,
CipMessageRouterResponse *message_router_response,
const struct sockaddr *originator_address,
const int encapsulation_session) {
const CipSessionHandle encapsulation_session) {
/* Suppress unused parameter compiler warning. */
(void)originator_address;
(void)encapsulation_session;
Expand Down Expand Up @@ -1468,7 +1468,7 @@ EipStatus CipCreateService(CipInstance *RESTRICT const instance,
CipMessageRouterRequest *const message_router_request,
CipMessageRouterResponse *const message_router_response,
const struct sockaddr *originator_address,
const int encapsulation_session) {
const CipSessionHandle encapsulation_session) {
/* Suppress unused parameter compiler warning. */
(void)originator_address;
(void)encapsulation_session;
Expand Down Expand Up @@ -1510,7 +1510,7 @@ EipStatus CipDeleteService(CipInstance *RESTRICT const instance,
CipMessageRouterRequest *const message_router_request,
CipMessageRouterResponse *const message_router_response,
const struct sockaddr *originator_address,
const int encapsulation_session) {
const CipSessionHandle encapsulation_session) {
/* Suppress unused parameter compiler warning. */
(void)originator_address;
(void)encapsulation_session;
Expand Down Expand Up @@ -1573,7 +1573,7 @@ EipStatus CipResetService(CipInstance *RESTRICT const instance,
CipMessageRouterRequest *const message_router_request,
CipMessageRouterResponse *const message_router_response,
const struct sockaddr *originator_address,
const int encapsulation_session) {
const CipSessionHandle encapsulation_session) {
/* Suppress unused parameter compiler warning. */
(void)originator_address;
(void)encapsulation_session;
Expand Down
18 changes: 9 additions & 9 deletions source/src/cip/cipcommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ EipStatus NotifyClass(const CipClass *const RESTRICT cip_class,
CipMessageRouterRequest *const message_router_request,
CipMessageRouterResponse *const message_router_response,
const struct sockaddr *originator_address,
const int encapsulation_session);
const CipSessionHandle encapsulation_session);

/** @brief Get largest instance_number present in class instances
*
Expand Down Expand Up @@ -63,7 +63,7 @@ EipStatus GetAttributeSingle(
CipMessageRouterResponse *const
message_router_response,
const struct sockaddr *originator_address,
const int encapsulation_session);
const CipSessionHandle encapsulation_session);

void GenerateSetAttributeSingleHeader(
const CipMessageRouterRequest *const message_router_request,
Expand All @@ -89,7 +89,7 @@ EipStatus SetAttributeSingle(
CipMessageRouterResponse *const
message_router_response,
const struct sockaddr *originator_address,
const int encapsulation_session);
const CipSessionHandle encapsulation_session);

/** @brief Generic implementation of the GetAttributeAll CIP service
*
Expand All @@ -106,7 +106,7 @@ EipStatus GetAttributeAll(CipInstance *instance,
CipMessageRouterRequest *message_router_request,
CipMessageRouterResponse *message_router_response,
const struct sockaddr *originator_address,
const int encapsulation_session);
const CipSessionHandle encapsulation_session);

/** @brief Generic implementation of the GetAttributeList CIP service
*
Expand All @@ -124,7 +124,7 @@ EipStatus GetAttributeList(CipInstance *instance,
CipMessageRouterRequest *message_router_request,
CipMessageRouterResponse *message_router_response,
const struct sockaddr *originator_address,
const int encapsulation_session);
const CipSessionHandle encapsulation_session);

/** @brief Generic implementation of the SetAttributeList CIP service
*
Expand All @@ -142,7 +142,7 @@ EipStatus SetAttributeList(CipInstance *instance,
CipMessageRouterRequest *message_router_request,
CipMessageRouterResponse *message_router_response,
const struct sockaddr *originator_address,
const int encapsulation_session);
const CipSessionHandle encapsulation_session);

/** @brief Decodes padded EPath
* @param epath EPath object to the receiving element
Expand Down Expand Up @@ -171,7 +171,7 @@ EipStatus CipCreateService(
CipMessageRouterResponse *const
message_router_response,
const struct sockaddr *originator_address,
const int encapsulation_session);
const CipSessionHandle encapsulation_session);

/** @brief Generic implementation of the CIP Delete service
*
Expand All @@ -192,7 +192,7 @@ EipStatus CipDeleteService(CipInstance *RESTRICT const instance,
CipMessageRouterResponse *const
message_router_response,
const struct sockaddr *originator_address,
const int encapsulation_session);
const CipSessionHandle encapsulation_session);

/** @brief Generic implementation of the CIP Reset service
*
Expand All @@ -214,6 +214,6 @@ EipStatus CipResetService(CipInstance *RESTRICT const instance,
CipMessageRouterResponse *const
message_router_response,
const struct sockaddr *originator_address,
const int encapsulation_session);
const CipSessionHandle encapsulation_session);

#endif /* OPENER_CIPCOMMON_H_ */
20 changes: 10 additions & 10 deletions source/src/cip/cipconnectionmanager.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,25 @@ EipStatus ForwardOpen(CipInstance *instance,
CipMessageRouterRequest *message_router_request,
CipMessageRouterResponse *message_router_response,
const struct sockaddr *originator_address,
const int encapsulation_session);
const CipSessionHandle encapsulation_session);

EipStatus LargeForwardOpen(CipInstance *instance,
CipMessageRouterRequest *message_router_request,
CipMessageRouterResponse *message_router_response,
const struct sockaddr *originator_address,
const int encapsulation_session);
const CipSessionHandle encapsulation_session);

EipStatus ForwardClose(CipInstance *instance,
CipMessageRouterRequest *message_router_request,
CipMessageRouterResponse *message_router_response,
const struct sockaddr *originator_address,
const int encapsulation_session);
const CipSessionHandle encapsulation_session);

EipStatus GetConnectionOwner(CipInstance *instance,
CipMessageRouterRequest *message_router_request,
CipMessageRouterResponse *message_router_response,
const struct sockaddr *originator_address,
const int encapsulation_session);
const CipSessionHandle encapsulation_session);

EipStatus GetConnectionData(CipInstance *instance,
CipMessageRouterRequest *message_router_request,
Expand Down Expand Up @@ -526,7 +526,7 @@ EipStatus ForwardOpenRoutine(CipInstance *instance,
CipMessageRouterRequest *message_router_request,
CipMessageRouterResponse *message_router_response,
const struct sockaddr *originator_address,
const int encapsulation_session);
const CipSessionHandle encapsulation_session);

/** @brief Check if resources for new connection available, generate ForwardOpen Reply message.
*
Expand All @@ -536,7 +536,7 @@ EipStatus LargeForwardOpen(CipInstance *instance,
CipMessageRouterRequest *message_router_request,
CipMessageRouterResponse *message_router_response,
const struct sockaddr *originator_address,
const int encapsulation_session) {
const CipSessionHandle encapsulation_session) {
g_dummy_connection_object.is_large_forward_open = true;
return ForwardOpenRoutine(instance,
message_router_request,
Expand Down Expand Up @@ -570,7 +570,7 @@ EipStatus ForwardOpen(CipInstance *instance,
CipMessageRouterRequest *message_router_request,
CipMessageRouterResponse *message_router_response,
const struct sockaddr *originator_address,
const int encapsulation_session) {
const CipSessionHandle encapsulation_session) {
g_dummy_connection_object.is_large_forward_open = false;
return ForwardOpenRoutine(instance,
message_router_request,
Expand All @@ -582,7 +582,7 @@ EipStatus ForwardOpenRoutine(CipInstance *instance,
CipMessageRouterRequest *message_router_request,
CipMessageRouterResponse *message_router_response,
const struct sockaddr *originator_address,
const int encapsulation_session) {
const CipSessionHandle encapsulation_session) {
(void) instance; /*suppress compiler warning */

bool is_null_request = false; /* 1 = Null Request, 0 = Non-Null Request */
Expand Down Expand Up @@ -665,7 +665,7 @@ EipStatus ForwardClose(CipInstance *instance,
CipMessageRouterRequest *message_router_request,
CipMessageRouterResponse *message_router_response,
const struct sockaddr *originator_address,
const int encapsulation_session) {
const CipSessionHandle encapsulation_session) {
/*Suppress compiler warning*/
(void) instance;
(void) encapsulation_session;
Expand Down Expand Up @@ -739,7 +739,7 @@ EipStatus GetConnectionOwner(CipInstance *instance,
CipMessageRouterRequest *message_router_request,
CipMessageRouterResponse *message_router_response,
const struct sockaddr *originator_address,
const int encapsulation_session) {
const CipSessionHandle encapsulation_session) {
/* suppress compiler warnings */
(void) instance;
(void) message_router_request;
Expand Down
2 changes: 1 addition & 1 deletion source/src/cip/cipconnectionobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ struct cip_connection_object {
for scanning if the right packet is
arriving */

size_t associated_encapsulation_session; /* The session handle ID via which the forward open was sent */
CipSessionHandle associated_encapsulation_session; /* The session handle ID via which the forward open was sent */

/* pointers to connection handling functions */
CipConnectionStateHandler current_state_handler;
Expand Down
4 changes: 2 additions & 2 deletions source/src/cip/cipethernetlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ EipStatus GetAndClearEthernetLink(
CipMessageRouterRequest *const message_router_request,
CipMessageRouterResponse *const message_router_response,
const struct sockaddr *originator_address,
const int encapsulation_session);
const CipSessionHandle encapsulation_session);
#endif /* ... && 0 != OPENER_ETHLINK_CNTRS_ENABLE */

#if defined(OPENER_ETHLINK_IFACE_CTRL_ENABLE) && \
Expand Down Expand Up @@ -503,7 +503,7 @@ EipStatus GetAndClearEthernetLink(
CipMessageRouterRequest *const message_router_request,
CipMessageRouterResponse *const message_router_response,
const struct sockaddr *originator_address,
const int encapsulation_session) {
const CipSessionHandle encapsulation_session) {

CipAttributeStruct *attribute = GetCipAttribute(
instance, message_router_request->request_path.attribute_number);
Expand Down
2 changes: 1 addition & 1 deletion source/src/cip/cipmessagerouter.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ EipStatus NotifyMessageRouter(EipUint8 *data,
int data_length,
CipMessageRouterResponse *message_router_response,
const struct sockaddr *const originator_address,
const int encapsulation_session) {
const CipSessionHandle encapsulation_session) {
EipStatus eip_status = kEipStatusOkSend;
CipError status = kCipErrorSuccess;

Expand Down
2 changes: 1 addition & 1 deletion source/src/cip/cipmessagerouter.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ EipStatus NotifyMessageRouter(EipUint8 *data,
int data_length,
CipMessageRouterResponse *message_router_response,
const struct sockaddr *const originator_address,
const int encapsulation_session);
const CipSessionHandle encapsulation_session);

/*! Register a class at the message router.
* In order that the message router can deliver
Expand Down
4 changes: 2 additions & 2 deletions source/src/cip/ciptypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ typedef struct cip_class {
* @typedef EipStatus (*CipServiceFunction)(CipInstance *const instance,
* CipMessageRouterRequest *const message_router_request,
* CipMessageRouterResponse *const message_router_response,
* const struct sockaddr *originator_address, const int encapsulation_session)
* const struct sockaddr *originator_address, const CipSessionHandle encapsulation_session)
* @brief Signature definition for the implementation of CIP services.
*
* CIP services have to follow this signature in order to be handled correctly
Expand All @@ -438,7 +438,7 @@ typedef EipStatus (*CipServiceFunction)(CipInstance *const instance,
message_router_response,
const struct sockaddr *
originator_address,
const int encapsulation_session);
const CipSessionHandle encapsulation_session);

/** @brief Service descriptor. These are stored in an array */
typedef struct cip_service_struct {
Expand Down
Loading

0 comments on commit 51c3d96

Please sign in to comment.