Skip to content

Commit

Permalink
snmpstats: clang-format for coherent indentation and coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxmaniac committed May 18, 2023
1 parent 8776676 commit f2cca4f
Show file tree
Hide file tree
Showing 15 changed files with 385 additions and 366 deletions.
35 changes: 21 additions & 14 deletions src/modules/snmpstats/kamailioNet.c
Expand Up @@ -315,8 +315,9 @@ int handle_kamailioNetTcpConnEstablished(netsnmp_mib_handler *handler,

default:
/* we should never get here, so this is a really bad error */
snmp_log(LOG_ERR, "unknown mode (%d) in "
"handle_kamailioNetTcpConnEstablished\n",
snmp_log(LOG_ERR,
"unknown mode (%d) in "
"handle_kamailioNetTcpConnEstablished\n",
reqinfo->mode);
return SNMP_ERR_GENERR;
}
Expand Down Expand Up @@ -436,8 +437,9 @@ int handle_kamailioNetTcpConnPassiveOpen(netsnmp_mib_handler *handler,

default:
/* we should never get here, so this is a really bad error */
snmp_log(LOG_ERR, "unknown mode (%d) in "
"handle_kamailioNetTcpConnPassiveOpen\n",
snmp_log(LOG_ERR,
"unknown mode (%d) in "
"handle_kamailioNetTcpConnPassiveOpen\n",
reqinfo->mode);
return SNMP_ERR_GENERR;
}
Expand Down Expand Up @@ -756,8 +758,9 @@ int handle_kamailioNetTcpAsyncConnWqMax(netsnmp_mib_handler *handler,

default:
/* we should never get here, so this is a really bad error */
snmp_log(LOG_ERR, "unknown mode (%d) in "
"handle_kamailioNetTcpAsyncConnWqMax\n",
snmp_log(LOG_ERR,
"unknown mode (%d) in "
"handle_kamailioNetTcpAsyncConnWqMax\n",
reqinfo->mode);
return SNMP_ERR_GENERR;
}
Expand Down Expand Up @@ -1228,8 +1231,9 @@ int handle_kamailioNetWsConnsClosedLocal(netsnmp_mib_handler *handler,

default:
/* we should never get here, so this is a really bad error */
snmp_log(LOG_ERR, "unknown mode (%d) in "
"handle_kamailioNetWsConnsClosedLocal\n",
snmp_log(LOG_ERR,
"unknown mode (%d) in "
"handle_kamailioNetWsConnsClosedLocal\n",
reqinfo->mode);
return SNMP_ERR_GENERR;
}
Expand All @@ -1252,8 +1256,9 @@ int handle_kamailioNetWsConnsClosedRemote(netsnmp_mib_handler *handler,

default:
/* we should never get here, so this is a really bad error */
snmp_log(LOG_ERR, "unknown mode (%d) in "
"handle_kamailioNetWsConnsClosedRemote\n",
snmp_log(LOG_ERR,
"unknown mode (%d) in "
"handle_kamailioNetWsConnsClosedRemote\n",
reqinfo->mode);
return SNMP_ERR_GENERR;
}
Expand Down Expand Up @@ -1324,8 +1329,9 @@ int handle_kamailioNetWsHandshakeSuccess(netsnmp_mib_handler *handler,

default:
/* we should never get here, so this is a really bad error */
snmp_log(LOG_ERR, "unknown mode (%d) in "
"handle_kamailioNetWsHandshakeSuccess\n",
snmp_log(LOG_ERR,
"unknown mode (%d) in "
"handle_kamailioNetWsHandshakeSuccess\n",
reqinfo->mode);
return SNMP_ERR_GENERR;
}
Expand All @@ -1348,8 +1354,9 @@ int handle_kamailioNetWsHandshakeFailed(netsnmp_mib_handler *handler,

default:
/* we should never get here, so this is a really bad error */
snmp_log(LOG_ERR, "unknown mode (%d) in "
"handle_kamailioNetWsHandshakeFailed\n",
snmp_log(LOG_ERR,
"unknown mode (%d) in "
"handle_kamailioNetWsHandshakeFailed\n",
reqinfo->mode);
return SNMP_ERR_GENERR;
}
Expand Down
25 changes: 15 additions & 10 deletions src/modules/snmpstats/kamailioNetConfig.c
Expand Up @@ -178,8 +178,9 @@ int handle_kamailioNetConfUdpDtlsTransport(netsnmp_mib_handler *handler,

default:
/* we should never get here, so this is a really bad error */
snmp_log(LOG_ERR, "unknown mode (%d) in "
"handle_kamailioNetConfUdpDtlsTransport\n",
snmp_log(LOG_ERR,
"unknown mode (%d) in "
"handle_kamailioNetConfUdpDtlsTransport\n",
reqinfo->mode);
return SNMP_ERR_GENERR;
}
Expand Down Expand Up @@ -243,8 +244,9 @@ int handle_kamailioNetConfTcpTlsTransport(netsnmp_mib_handler *handler,

default:
/* we should never get here, so this is a really bad error */
snmp_log(LOG_ERR, "unknown mode (%d) in "
"handle_kamailioNetConfTcpTlsTransport\n",
snmp_log(LOG_ERR,
"unknown mode (%d) in "
"handle_kamailioNetConfTcpTlsTransport\n",
reqinfo->mode);
return SNMP_ERR_GENERR;
}
Expand All @@ -271,8 +273,9 @@ int handle_kamailioNetConfSctpTransport(netsnmp_mib_handler *handler,

default:
/* we should never get here, so this is a really bad error */
snmp_log(LOG_ERR, "unknown mode (%d) in "
"handle_kamailioNetConfSctpTransport\n",
snmp_log(LOG_ERR,
"unknown mode (%d) in "
"handle_kamailioNetConfSctpTransport\n",
reqinfo->mode);
return SNMP_ERR_GENERR;
}
Expand All @@ -295,8 +298,9 @@ int handle_kamailioNetConfSctpTlsTransport(netsnmp_mib_handler *handler,

default:
/* we should never get here, so this is a really bad error */
snmp_log(LOG_ERR, "unknown mode (%d) in "
"handle_kamailioNetConfSctpTlsTransport\n",
snmp_log(LOG_ERR,
"unknown mode (%d) in "
"handle_kamailioNetConfSctpTlsTransport\n",
reqinfo->mode);
return SNMP_ERR_GENERR;
}
Expand Down Expand Up @@ -354,8 +358,9 @@ int handle_kamailioNetConfWsTlsTransport(netsnmp_mib_handler *handler,

default:
/* we should never get here, so this is a really bad error */
snmp_log(LOG_ERR, "unknown mode (%d) in "
"handle_kamailioNetConfWsTlsTransport\n",
snmp_log(LOG_ERR,
"unknown mode (%d) in "
"handle_kamailioNetConfWsTlsTransport\n",
reqinfo->mode);
return SNMP_ERR_GENERR;
}
Expand Down
6 changes: 3 additions & 3 deletions src/modules/snmpstats/snmpSIPContactTable.c
Expand Up @@ -202,8 +202,8 @@ int createContactRow(int userIndex, int contactIndex, char *contactName,
theRow->kamailioSIPContactIndex = contactIndex;

/* Fill in the rest of the rows columns */
theRow->kamailioSIPContactURI =
(unsigned char *)pkg_malloc((stringLength + 1) * sizeof(unsigned char));
theRow->kamailioSIPContactURI = (unsigned char *)pkg_malloc(
(stringLength + 1) * sizeof(unsigned char));
if(theRow->kamailioSIPContactURI == NULL) {
pkg_free(OIDIndex);
free(theRow);
Expand Down Expand Up @@ -290,7 +290,7 @@ void initialize_table_kamailioSIPContactTable(void)

/** create the table structure itself */
table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info);
if(table_info==NULL) {
if(table_info == NULL) {
snmp_log(LOG_ERR, "failed to allocate table_info\n");
return;
}
Expand Down
87 changes: 44 additions & 43 deletions src/modules/snmpstats/snmpSIPContactTable.h
Expand Up @@ -58,7 +58,8 @@
#define KAMAILIOSIPCONTACTTABLE_H

#ifdef __cplusplus
extern "C" {
extern "C"
{
#endif


Expand All @@ -71,108 +72,108 @@ extern "C" {
#include "../usrloc/ucontact.h"
#include "../../core/config.h"

/* This strucutre is actually quite different from what was generated by mib2c.
/* This strucutre is actually quite different from what was generated by mib2c.
* Specifically, the scalars kamailioSIPContactURI, kamailioSIPContactExpiry, and
* kamailioSIPContactPreference have been removed from the rows definition. This
* was done because the values change over time. Therefore we retrieve the data
* only when it is requested for, instead of storing stale data.
*/
typedef struct kamailioSIPContactTable_context_s
{
netsnmp_index index; /** THIS MUST BE FIRST!!! */
typedef struct kamailioSIPContactTable_context_s
{
netsnmp_index index; /** THIS MUST BE FIRST!!! */

unsigned long kamailioSIPContactIndex;
unsigned long kamailioSIPContactIndex;

unsigned char *kamailioSIPContactURI;
long kamailioSIPContactURI_len;
unsigned char *kamailioSIPContactURI;
long kamailioSIPContactURI_len;

/* A pointer to the rest of the contact structure, giving us access to
/* A pointer to the rest of the contact structure, giving us access to
* kamailioSIPContactURI, kamailioSIPContactExpirty, and
* kamailioSIPContactPreference. */
ucontact_t *contactInfo;
ucontact_t *contactInfo;

void *data;
void *data;

} kamailioSIPContactTable_context;
} kamailioSIPContactTable_context;

/******************************/
/* Customized SNMP Prototypes */
/******************************/
/******************************/
/* Customized SNMP Prototypes */
/******************************/

/*
/*
* Creates an SNMP row and inserts it into the contact table. This function
* should only be called when the interprocess buffer is being consumed.
*
* Returns: 1 on success, and 0 otherwise.
*/
int createContactRow(int userIndex, int contactIndex, char *contactName,
ucontact_t *contactInfo);
int createContactRow(int userIndex, int contactIndex, char *contactName,
ucontact_t *contactInfo);

/*
/*
* Removes the row indexed by userIndex and contactIndex, and free's up the
* memory allocated to it. If the row could not be found, then nothing is done.
*/
void deleteContactRow(int userIndex, int contactIndex);
void deleteContactRow(int userIndex, int contactIndex);


/*
/*
* This function adds a new contactToIndexStruct_t record to the front of
* 'contactRecord'.
*
* The structure is used to map a contact name to the SNMPStats modules integer
* indexing scheme. It will be used later when a delete command comes in, and
* we need to find out which SNMP row the information is stored under.
*/
int insertContactRecord(
contactToIndexStruct_t **contactRecord, int index, char *name);
int insertContactRecord(
contactToIndexStruct_t **contactRecord, int index, char *name);

/*
/*
* This function will remove the contactToIndexStruct_T record matching
* 'contactName' from the users contactToIndexStruct_t linked-list, and return
* the records index. In the event that the record could not be found, 0 will
* be returned.
*/
int deleteContactRecord(
contactToIndexStruct_t **contactRecord, char *contactName);
int deleteContactRecord(
contactToIndexStruct_t **contactRecord, char *contactName);


/********************************/
/* Normal SNMP Table Prototypes */
/********************************/
/********************************/
/* Normal SNMP Table Prototypes */
/********************************/

/*
/*
* Initializes the kamailioSIPContactTable module. This involves:
*
* 1) Registering the tables OID with the master agent
*
* 2) Creating a default row, so that there is a row to query to trigger the
* consumption of the interprocess buffer.
*/
void init_kamailioSIPContactTable(void);
void init_kamailioSIPContactTable(void);


/*
/*
* Initialize the kamailioSIPContactTable table by defining its contents and how
* it's structured.
*
* This function is mostly auto-generated.
*/
void initialize_table_kamailioSIPContactTable(void);
void initialize_table_kamailioSIPContactTable(void);

const kamailioSIPContactTable_context *kamailioSIPContactTable_get_by_idx(
netsnmp_index *);
const kamailioSIPContactTable_context *kamailioSIPContactTable_get_by_idx(
netsnmp_index *);

const kamailioSIPContactTable_context *kamailioSIPContactTable_get_by_idx_rs(
netsnmp_index *, int row_status);
const kamailioSIPContactTable_context *
kamailioSIPContactTable_get_by_idx_rs(netsnmp_index *, int row_status);

/* This routine is called to process get requests for elements of the table. */
int kamailioSIPContactTable_get_value(
netsnmp_request_info *, netsnmp_index *, netsnmp_table_request_info *);
/* This routine is called to process get requests for elements of the table. */
int kamailioSIPContactTable_get_value(netsnmp_request_info *,
netsnmp_index *, netsnmp_table_request_info *);


/* oid declarations */
extern oid kamailioSIPContactTable_oid[];
extern size_t kamailioSIPContactTable_oid_len;
/* oid declarations */
extern oid kamailioSIPContactTable_oid[];
extern size_t kamailioSIPContactTable_oid_len;

#define kamailioSIPContactTable_TABLE_OID KAMAILIO_OID, 3, 1, 2, 1, 5, 7

Expand Down
2 changes: 1 addition & 1 deletion src/modules/snmpstats/snmpSIPMethodSupportedTable.c
Expand Up @@ -176,7 +176,7 @@ void initialize_table_kamailioSIPMethodSupportedTable(void)

/** create the table structure itself */
table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info);
if(table_info==NULL) {
if(table_info == NULL) {
snmp_log(LOG_ERR, "failed to allocate table_info\n");
return;
}
Expand Down

0 comments on commit f2cca4f

Please sign in to comment.