From a7c0497b4f5dc84d39519f78429ec15ce5e7a693 Mon Sep 17 00:00:00 2001
From: Adam Wujek <adam.wujek@cern.ch>
Date: Thu, 7 Jul 2016 17:03:46 +0200
Subject: [PATCH] userspace/snmpd: (no tech change) rename fields in the
 wrsPortStatusTable_s

Rename fields in the struct wrsPortStatusTable_s to reflect SNMP objects'
names.

link_up -> wrsPortStatusLink
port_mode -> wrsPortStatusConfiguredMode
port_locked -> wrsPortStatusLocked
sfp_vn[16] -> wrsPortStatusSfpVN[16]
sfp_pn[16] -> wrsPortStatusSfpPN[16]
sfp_vs[16] -> wrsPortStatusSfpVS[16]
sfp_in_db -> wrsPortStatusSfpInDB
sfp_GbE -> wrsPortStatusSfpGbE
sfp_error -> wrsPortStatusSfpError
ptp_tx_count -> wrsPortStatusPtpTxFrames
ptp_rx_count -> wrsPortStatusPtpRxFrames

Signed-off-by: Adam Wujek <adam.wujek@cern.ch>
---
 userspace/snmpd/wrsNetworkingStatusGroup.c |  8 +--
 userspace/snmpd/wrsPortStatusTable.c       | 80 +++++++++++-----------
 userspace/snmpd/wrsPortStatusTable.h       | 26 +++----
 userspace/snmpd/wrsTimingStatusGroup.c     | 32 ++++-----
 4 files changed, 73 insertions(+), 73 deletions(-)

diff --git a/userspace/snmpd/wrsNetworkingStatusGroup.c b/userspace/snmpd/wrsNetworkingStatusGroup.c
index 144f0457a..c920d6f0c 100644
--- a/userspace/snmpd/wrsNetworkingStatusGroup.c
+++ b/userspace/snmpd/wrsNetworkingStatusGroup.c
@@ -225,16 +225,16 @@ time_t wrsNetworkingStatus_data_fill(void)
 	port_status_n_na = 0;
 	/* count number of ports of each status */
 	for (i = 0; i < port_status_nrows; i++) {
-		if (p_a[i].sfp_error == WRS_PORT_STATUS_SFP_ERROR_SFP_OK) {
+		if (p_a[i].wrsPortStatusSfpError == WRS_PORT_STATUS_SFP_ERROR_SFP_OK) {
 			port_status_n_ok++;
 		}
-		if (p_a[i].sfp_error == WRS_PORT_STATUS_SFP_ERROR_SFP_ERROR) {
+		if (p_a[i].wrsPortStatusSfpError == WRS_PORT_STATUS_SFP_ERROR_SFP_ERROR) {
 			port_status_n_error++;
 		}
-		if (p_a[i].sfp_error == WRS_PORT_STATUS_SFP_ERROR_PORT_DOWN) {
+		if (p_a[i].wrsPortStatusSfpError == WRS_PORT_STATUS_SFP_ERROR_PORT_DOWN) {
 			port_status_n_down++;
 		}
-		if (p_a[i].sfp_error == 0) {
+		if (p_a[i].wrsPortStatusSfpError == 0) {
 			port_status_n_na++;
 		}
 	}
diff --git a/userspace/snmpd/wrsPortStatusTable.c b/userspace/snmpd/wrsPortStatusTable.c
index bed990095..a4ce48d18 100644
--- a/userspace/snmpd/wrsPortStatusTable.c
+++ b/userspace/snmpd/wrsPortStatusTable.c
@@ -7,19 +7,19 @@ struct wrsPortStatusTable_s wrsPortStatusTable_array[WRS_N_PORTS];
 
 static struct pickinfo wrsPortStatusTable_pickinfo[] = {
 	FIELD(wrsPortStatusTable_s, ASN_UNSIGNED, index), /* not reported */
-	FIELD(wrsPortStatusTable_s, ASN_OCTET_STR, port_name),
-	FIELD(wrsPortStatusTable_s, ASN_INTEGER, link_up),
-	FIELD(wrsPortStatusTable_s, ASN_INTEGER, port_mode),
-	FIELD(wrsPortStatusTable_s, ASN_INTEGER, port_locked),
-	FIELD(wrsPortStatusTable_s, ASN_OCTET_STR, peer_id),
-	FIELD(wrsPortStatusTable_s, ASN_OCTET_STR, sfp_vn),
-	FIELD(wrsPortStatusTable_s, ASN_OCTET_STR, sfp_pn),
-	FIELD(wrsPortStatusTable_s, ASN_OCTET_STR, sfp_vs),
-	FIELD(wrsPortStatusTable_s, ASN_INTEGER, sfp_in_db),
-	FIELD(wrsPortStatusTable_s, ASN_INTEGER, sfp_GbE),
-	FIELD(wrsPortStatusTable_s, ASN_INTEGER, sfp_error),
-	FIELD(wrsPortStatusTable_s, ASN_COUNTER, ptp_tx_count),
-	FIELD(wrsPortStatusTable_s, ASN_COUNTER, ptp_rx_count),
+	FIELD(wrsPortStatusTable_s, ASN_OCTET_STR, wrsPortStatusPortName),
+	FIELD(wrsPortStatusTable_s, ASN_INTEGER, wrsPortStatusLink),
+	FIELD(wrsPortStatusTable_s, ASN_INTEGER, wrsPortStatusConfiguredMode),
+	FIELD(wrsPortStatusTable_s, ASN_INTEGER, wrsPortStatusLocked),
+	FIELD(wrsPortStatusTable_s, ASN_OCTET_STR, wrsPortStatusPeer),
+	FIELD(wrsPortStatusTable_s, ASN_OCTET_STR, wrsPortStatusSfpVN),
+	FIELD(wrsPortStatusTable_s, ASN_OCTET_STR, wrsPortStatusSfpPN),
+	FIELD(wrsPortStatusTable_s, ASN_OCTET_STR, wrsPortStatusSfpVS),
+	FIELD(wrsPortStatusTable_s, ASN_INTEGER, wrsPortStatusSfpInDB),
+	FIELD(wrsPortStatusTable_s, ASN_INTEGER, wrsPortStatusSfpGbE),
+	FIELD(wrsPortStatusTable_s, ASN_INTEGER, wrsPortStatusSfpError),
+	FIELD(wrsPortStatusTable_s, ASN_COUNTER, wrsPortStatusPtpTxFrames),
+	FIELD(wrsPortStatusTable_s, ASN_COUNTER, wrsPortStatusPtpRxFrames),
 };
 
 
@@ -66,11 +66,11 @@ time_t wrsPortStatusTable_data_fill(unsigned int *n_rows)
 		for (i = 0; i < hal_nports_local; ++i) {
 			/* Assume that number of ports does not change between
 			 * reads */
-			snprintf(wrsPortStatusTable_array[i].port_name, 10,
+			snprintf(wrsPortStatusTable_array[i].wrsPortStatusPortName, 10,
 				 "wri%d", i + 1);
 			port_state = hal_lookup_port(hal_ports,
 					hal_nports_local,
-					wrsPortStatusTable_array[i].port_name);
+					wrsPortStatusTable_array[i].wrsPortStatusPortName);
 			if(!port_state) {
 				/* It looks like we're in strange situation
 				 * that HAL is up but hal_ports is not filled
@@ -82,38 +82,38 @@ time_t wrsPortStatusTable_data_fill(unsigned int *n_rows)
 			 * Keep value 0 for Not available
 			 * values defined as WRS_PORT_STATUS_LINK_*
 			*/
-			wrsPortStatusTable_array[i].link_up =
+			wrsPortStatusTable_array[i].wrsPortStatusLink =
 					1 + state_up(port_state->state);
 			 /* values defined as
 			  * WRS_PORT_STATUS_CONFIGURED_MODE_* */
-			wrsPortStatusTable_array[i].port_mode =
+			wrsPortStatusTable_array[i].wrsPortStatusConfiguredMode =
 							port_state->mode;
 			if (port_state->state == HAL_PORT_STATE_DISABLED) {
-				wrsPortStatusTable_array[i].sfp_error =
+				wrsPortStatusTable_array[i].wrsPortStatusSfpError =
 					  WRS_PORT_STATUS_SFP_ERROR_PORT_DOWN;
 				/* if port is disabled don't fill
 				 * other fields */
 				continue;
 			}
 			/* Keep value 0 for Not available */
-			wrsPortStatusTable_array[i].port_locked =
+			wrsPortStatusTable_array[i].wrsPortStatusLocked =
 							1 + port_state->locked;
 			/* FIXME: get real peer_id */
-			memset(&wrsPortStatusTable_array[i].peer_id, 0xff,
+			memset(&wrsPortStatusTable_array[i].wrsPortStatusPeer, 0xff,
 			       sizeof(ClockIdentity));
-			wrsPortStatusTable_array[i].sfp_in_db =
+			wrsPortStatusTable_array[i].wrsPortStatusSfpInDB =
 			  port_state->calib.sfp.flags & SFP_FLAG_IN_DB ? 2 : 1;
-			wrsPortStatusTable_array[i].sfp_GbE =
+			wrsPortStatusTable_array[i].wrsPortStatusSfpGbE =
 			  port_state->calib.sfp.flags & SFP_FLAG_1GbE ? 2 : 1;
-			strncpy(wrsPortStatusTable_array[i].sfp_vn,
+			strncpy(wrsPortStatusTable_array[i].wrsPortStatusSfpVN,
 				port_state->calib.sfp.vendor_name,
-				sizeof(wrsPortStatusTable_array[i].sfp_vn));
-			strncpy(wrsPortStatusTable_array[i].sfp_pn,
+				sizeof(wrsPortStatusTable_array[i].wrsPortStatusSfpVN));
+			strncpy(wrsPortStatusTable_array[i].wrsPortStatusSfpPN,
 				port_state->calib.sfp.part_num,
-				sizeof(wrsPortStatusTable_array[i].sfp_pn));
-			strncpy(wrsPortStatusTable_array[i].sfp_vs,
+				sizeof(wrsPortStatusTable_array[i].wrsPortStatusSfpPN));
+			strncpy(wrsPortStatusTable_array[i].wrsPortStatusSfpVS,
 				port_state->calib.sfp.vendor_serial,
-				sizeof(wrsPortStatusTable_array[i].sfp_vs));
+				sizeof(wrsPortStatusTable_array[i].wrsPortStatusSfpVS));
 			/* sfp error when SFP is not 1 GbE or
 			 * (port is not wr-non mode and sfp not in data base)
 			 * Keep value 0 for Not available 
@@ -121,16 +121,16 @@ time_t wrsPortStatusTable_data_fill(unsigned int *n_rows)
 			 * sfp error is 2 WRS_PORT_STATUS_SFP_ERROR_SFP_ERROR
 			 * port down, set above, is 3
 			 * (WRS_PORT_STATUS_SFP_ERROR_PORT_DOWN) */
-			wrsPortStatusTable_array[i].sfp_error = 1 +
-				((wrsPortStatusTable_array[i].sfp_GbE == 1) ||
+			wrsPortStatusTable_array[i].wrsPortStatusSfpError = 1 +
+				((wrsPortStatusTable_array[i].wrsPortStatusSfpGbE == 1) ||
 				((port_state->mode != HEXP_PORT_MODE_NON_WR) &&
-				(wrsPortStatusTable_array[i].sfp_in_db == 1)));
+				(wrsPortStatusTable_array[i].wrsPortStatusSfpInDB == 1)));
 
 			snmp_log(LOG_DEBUG, "reading ports name %s link %d, "
 				"mode %d, locked %d\n", port_state->name,
-				wrsPortStatusTable_array[i].link_up,
-				wrsPortStatusTable_array[i].port_mode,
-				wrsPortStatusTable_array[i].port_locked);
+				wrsPortStatusTable_array[i].wrsPortStatusLink,
+				wrsPortStatusTable_array[i].wrsPortStatusConfiguredMode,
+				wrsPortStatusTable_array[i].wrsPortStatusLocked);
 		}
 
 		retries++;
@@ -153,15 +153,15 @@ time_t wrsPortStatusTable_data_fill(unsigned int *n_rows)
 		return time_cur;
 	}
 
-	/* fill ptp_tx_count and ptp_tx_count
-	 * ptp_tx_count and ptp_tx_count statistics in PPSI are collected per
+	/* fill wrsPortStatusPtpTxFrames and wrsPortStatusPtpRxFrames
+	 * ptp_tx_count and ptp_rx_count statistics in PPSI are collected per
 	 * ppi instance. Since there can be more than one instance per physical
 	 * port, proper counters has to be added. */
 	while (1) {
 		ii = wrs_shm_seqbegin(ppsi_head);
 		/* Match port name with interface name of ppsi instance.
 		 * More than one ppsi_iface_name can match to
-		 * wrsPortStatusTable_array[i].port_name, but only one can
+		 * wrsPortStatusTable_array[i].wrsPortStatusPortName, but only one can
 		 * match way round */
 		for (ppi_i = 0; ppi_i < *ppsi_ppi_nlinks; ppi_i++) {
 			/* (ppsi_ppi + ppi_i)->iface_name is a pointer in
@@ -172,11 +172,11 @@ time_t wrsPortStatusTable_data_fill(unsigned int *n_rows)
 			ppsi_iface_name = (char *) wrs_shm_follow(ppsi_head,
 					       (ppsi_ppi + ppi_i)->iface_name);
 			for (i = 0; i < hal_nports_local; ++i) {
-				if (!strncmp(wrsPortStatusTable_array[i].port_name,
+				if (!strncmp(wrsPortStatusTable_array[i].wrsPortStatusPortName,
 					     ppsi_iface_name, 12)) {
-					wrsPortStatusTable_array[i].ptp_tx_count +=
+					wrsPortStatusTable_array[i].wrsPortStatusPtpTxFrames +=
 					      (ppsi_ppi + ppi_i)->ptp_tx_count;
-					wrsPortStatusTable_array[i].ptp_rx_count +=
+					wrsPortStatusTable_array[i].wrsPortStatusPtpRxFrames +=
 					      (ppsi_ppi + ppi_i)->ptp_rx_count;
 					/* speed up a little, break here */
 					break;
diff --git a/userspace/snmpd/wrsPortStatusTable.h b/userspace/snmpd/wrsPortStatusTable.h
index da0580dba..8d90bbd02 100644
--- a/userspace/snmpd/wrsPortStatusTable.h
+++ b/userspace/snmpd/wrsPortStatusTable.h
@@ -20,20 +20,20 @@
 struct wrsPortStatusTable_s {
 	uint32_t index;		/* not reported, index fields has to be marked
 				 * as not-accessible in MIB */
-	char port_name[12];	/* port name */
-	ClockIdentity peer_id;
+	char wrsPortStatusPortName[12];	/* port name */
+	ClockIdentity wrsPortStatusPeer;
 	/* These can't be "unsigned char" because we scanf a %i in there */
-	unsigned link_up;
-	unsigned port_mode;
-	unsigned port_locked;
-	char sfp_vn[16];	/* vendor name */
-	char sfp_pn[16];	/* part name */
-	char sfp_vs[16];	/* vendor serial */
-	int sfp_in_db;
-	int sfp_GbE;
-	int sfp_error;
-	unsigned long ptp_tx_count;
-	unsigned long ptp_rx_count;
+	unsigned wrsPortStatusLink;
+	unsigned wrsPortStatusConfiguredMode;
+	unsigned wrsPortStatusLocked;
+	char wrsPortStatusSfpVN[16];	/* vendor name */
+	char wrsPortStatusSfpPN[16];	/* part name */
+	char wrsPortStatusSfpVS[16];	/* vendor serial */
+	int wrsPortStatusSfpInDB;
+	int wrsPortStatusSfpGbE;
+	int wrsPortStatusSfpError;
+	unsigned long wrsPortStatusPtpTxFrames;
+	unsigned long wrsPortStatusPtpRxFrames;
 };
 
 
diff --git a/userspace/snmpd/wrsTimingStatusGroup.c b/userspace/snmpd/wrsTimingStatusGroup.c
index 9116afd68..f5a9d0d38 100644
--- a/userspace/snmpd/wrsTimingStatusGroup.c
+++ b/userspace/snmpd/wrsTimingStatusGroup.c
@@ -230,16 +230,16 @@ static void get_wrsSlaveLinksStatus(unsigned int port_status_nrows)
 		for (i = 0; i < port_status_nrows; i++) {
 			/* warning N/A */
 			if (/*hal_shmem->s->wrsSpllMode == 0
-			    || */p_a[i].port_mode == 0
-			    || p_a[i].link_up == 0){
+			    || */p_a[i].wrsPortStatusConfiguredMode == 0
+			    || p_a[i].wrsPortStatusLink == 0){
 				wrsTimingStatus_s.wrsSlaveLinksStatus =
 						WRS_SLAVE_LINK_STATUS_WARNING_NA;
 			}
 			/* error when slave port is down when switch is in slave mode
 			  */
 			if (hal_shmem->hal_mode == HAL_TIMING_MODE_BC
-			    && (p_a[i].port_mode == WRS_PORT_STATUS_CONFIGURED_MODE_SLAVE)
-			    && (p_a[i].link_up == WRS_PORT_STATUS_LINK_DOWN)) {
+			    && (p_a[i].wrsPortStatusConfiguredMode == WRS_PORT_STATUS_CONFIGURED_MODE_SLAVE)
+			    && (p_a[i].wrsPortStatusLink == WRS_PORT_STATUS_LINK_DOWN)) {
 				wrsTimingStatus_s.wrsSlaveLinksStatus =
 							WRS_SLAVE_LINK_STATUS_ERROR;
 				snmp_log(LOG_ERR, "SNMP: wrsSlaveLinksStatus (slave) "
@@ -249,8 +249,8 @@ static void get_wrsSlaveLinksStatus(unsigned int port_status_nrows)
 			/* error when slave port is up when switch is in master or
 			* grandmaster mode */
 			if (((hal_shmem->hal_mode == HAL_TIMING_MODE_GRAND_MASTER) || (hal_shmem->hal_mode == HAL_TIMING_MODE_FREE_MASTER))
-			    && (p_a[i].port_mode == WRS_PORT_STATUS_CONFIGURED_MODE_SLAVE)
-			    && (p_a[i].link_up == WRS_PORT_STATUS_LINK_UP)) {
+			    && (p_a[i].wrsPortStatusConfiguredMode == WRS_PORT_STATUS_CONFIGURED_MODE_SLAVE)
+			    && (p_a[i].wrsPortStatusLink == WRS_PORT_STATUS_LINK_UP)) {
 				wrsTimingStatus_s.wrsSlaveLinksStatus =
 							WRS_SLAVE_LINK_STATUS_ERROR;
 				snmp_log(LOG_ERR, "SNMP: wrsSlaveLinksStatus (master) "
@@ -268,8 +268,8 @@ static void get_wrsPTPFramesFlowing(unsigned int port_status_nrows)
 	static int first_run = 1;
 
 	/* store old values of TX and RX PTP counters to calculate delta */
-	static unsigned long ptp_tx_count_prev[WRS_N_PORTS];
-	static unsigned long ptp_rx_count_prev[WRS_N_PORTS];
+	static unsigned long wrsPortStatusPtpTxFrames_prev[WRS_N_PORTS];
+	static unsigned long wrsPortStatusPtpRxFrames_prev[WRS_N_PORTS];
 
 	/*********************************************************************\
 	|************************ wrsPTPFramesFlowing ************************|
@@ -290,10 +290,10 @@ static void get_wrsPTPFramesFlowing(unsigned int port_status_nrows)
 
 		/* Error when there is no increase in TX/RX PTP counters.
 		   Check only when port is non-wr and port is down */
-		} else if ((p_a[i].port_mode != WRS_PORT_STATUS_CONFIGURED_MODE_NON_WR)
-		    && (p_a[i].link_up == WRS_PORT_STATUS_LINK_UP)
-		    && ((ptp_tx_count_prev[i] == p_a[i].ptp_tx_count)
-			|| (ptp_rx_count_prev[i] == p_a[i].ptp_rx_count))) {
+		} else if ((p_a[i].wrsPortStatusConfiguredMode != WRS_PORT_STATUS_CONFIGURED_MODE_NON_WR)
+		    && (p_a[i].wrsPortStatusLink == WRS_PORT_STATUS_LINK_UP)
+		    && ((wrsPortStatusPtpTxFrames_prev[i] == p_a[i].wrsPortStatusPtpTxFrames)
+			|| (wrsPortStatusPtpRxFrames_prev[i] == p_a[i].wrsPortStatusPtpRxFrames))) {
 			wrsTimingStatus_s.wrsPTPFramesFlowing =
 						WRS_PTP_FRAMES_FLOWING_ERROR;
 			snmp_log(LOG_ERR, "SNMP: wrsPTPFramesFlowing "
@@ -303,8 +303,8 @@ static void get_wrsPTPFramesFlowing(unsigned int port_status_nrows)
 			break;
 
 		/* warning N/A */
-		} else if (p_a[i].port_mode == 0
-		    || p_a[i].link_up == 0){
+		} else if (p_a[i].wrsPortStatusConfiguredMode == 0
+		    || p_a[i].wrsPortStatusLink == 0){
 			wrsTimingStatus_s.wrsPTPFramesFlowing =
 					WRS_PTP_FRAMES_FLOWING_WARNING_NA;
 			/* continue with other ports, somewhere may be an
@@ -314,8 +314,8 @@ static void get_wrsPTPFramesFlowing(unsigned int port_status_nrows)
 
 	for (i = 0; i < port_status_nrows; i++) {
 		/* save current values */
-		ptp_tx_count_prev[i] = p_a[i].ptp_tx_count;
-		ptp_rx_count_prev[i] = p_a[i].ptp_rx_count;
+		wrsPortStatusPtpTxFrames_prev[i] = p_a[i].wrsPortStatusPtpTxFrames;
+		wrsPortStatusPtpRxFrames_prev[i] = p_a[i].wrsPortStatusPtpRxFrames;
 	}
 
 	first_run = 0;
-- 
GitLab