[openib-general] [PATCH] osmtest/osmtest.c: Start enabling link records
Hal Rosenstock
halr at voltaire.com
Fri Jun 16 07:12:10 PDT 2006
osmtest/osmtest.c: Start enabling link records
Enable the obtaining of SA LinkRecords, writing to database, and
parsing, and ignoring them for the time being.
Signed-off-by: Hal Rosenstock <halr at voltaire.com>
Index: osmtest/osmtest.c
===================================================================
--- osmtest/osmtest.c (revision 8064)
+++ osmtest/osmtest.c (working copy)
@@ -138,6 +138,10 @@ typedef enum _osmtest_token_val
OSMTEST_TOKEN_RESP_TIME_VAL,
OSMTEST_TOKEN_ERR_THRESHOLD,
OSMTEST_TOKEN_MTU,
+ OSMTEST_TOKEN_FROMLID,
+ OSMTEST_TOKEN_FROMPORTNUM,
+ OSMTEST_TOKEN_TOPORTNUM,
+ OSMTEST_TOKEN_TOLID,
OSMTEST_TOKEN_UNKNOWN
} osmtest_token_val_t;
@@ -213,6 +217,10 @@ const osmtest_token_t token_array[] = {
{OSMTEST_TOKEN_RESP_TIME_VAL, 15, "resp_time_value"},
{OSMTEST_TOKEN_ERR_THRESHOLD, 15, "error_threshold"},
{OSMTEST_TOKEN_MTU, 3, "MTU"}, /* must be after the other mtu... tokens. */
+ {OSMTEST_TOKEN_FROMLID, 8, "from_lid"},
+ {OSMTEST_TOKEN_FROMPORTNUM, 13, "from_port_num"},
+ {OSMTEST_TOKEN_TOPORTNUM, 11, "to_port_num"},
+ {OSMTEST_TOKEN_TOLID, 6, "to_lid"},
{OSMTEST_TOKEN_UNKNOWN, 0, ""} /* must be last entry */
};
@@ -1962,9 +1970,6 @@ osmtest_write_node_info( IN osmtest_t *
return ( status );
}
-#if 0
-/* HACK: we do not support link records for now. */
-
/**********************************************************************
**********************************************************************/
static ib_api_status_t
@@ -2076,7 +2081,6 @@ osmtest_write_all_link_recs( IN osmtest_
OSM_LOG_EXIT( &p_osmt->log );
return ( status );
}
-#endif
/**********************************************************************
**********************************************************************/
@@ -2727,11 +2731,9 @@ osmtest_create_inventory_file( IN osmtes
goto Exit;
}
-#if 0
status = osmtest_write_all_link_recs( p_osmt, fh );
if( status != IB_SUCCESS )
goto Exit;
-#endif
fclose( fh );
@@ -6114,6 +6116,94 @@ osmtest_parse_path( IN osmtest_t * const
/**********************************************************************
**********************************************************************/
static ib_api_status_t
+osmtest_parse_link( IN osmtest_t * const p_osmt,
+ IN FILE * const fh,
+ IN OUT uint32_t * const p_line_num )
+{
+ ib_api_status_t status = IB_SUCCESS;
+ uint32_t offset;
+ char line[OSMTEST_MAX_LINE_LEN];
+ boolean_t done = FALSE;
+ const osmtest_token_t *p_tok;
+
+ OSM_LOG_ENTER( &p_osmt->log, osmtest_parse_link);
+
+ /*
+ * Parse the inventory file and create the database.
+ */
+ while( !done )
+ {
+ if( fgets( line, OSMTEST_MAX_LINE_LEN, fh ) == NULL )
+ {
+ /*
+ * End of file in the middle of a definition.
+ */
+ osm_log( &p_osmt->log, OSM_LOG_ERROR,
+ "osmtest_parse_link: ERR 012A: "
+ "Unexpected end of file\n" );
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ ++*p_line_num;
+
+ /*
+ * Skip whitespace
+ */
+ offset = 0;
+ if( !str_skip_white( line, &offset ) )
+ continue; /* whole line was whitespace */
+
+ p_tok = str_get_token( &line[offset] );
+ if( p_tok == NULL )
+ {
+ osm_log( &p_osmt->log, OSM_LOG_ERROR,
+ "osmtest_parse_link: ERR 012B: "
+ "Ignoring line %u with unknown token: %s\n",
+ *p_line_num, &line[offset] );
+ continue;
+ }
+
+ if( osm_log_is_active( &p_osmt->log, OSM_LOG_DEBUG ) )
+ {
+ osm_log( &p_osmt->log, OSM_LOG_DEBUG,
+ "osmtest_parse_link: "
+ "Found '%s' (line %u)\n", p_tok->str, *p_line_num );
+ }
+
+ str_skip_token( line, &offset );
+
+ switch ( p_tok->val )
+ {
+ case OSMTEST_TOKEN_FROMLID:
+ case OSMTEST_TOKEN_FROMPORTNUM:
+ case OSMTEST_TOKEN_TOPORTNUM:
+ case OSMTEST_TOKEN_TOLID:
+ /* For now */
+ break;
+
+ case OSMTEST_TOKEN_END:
+ done = TRUE;
+ break;
+
+ default:
+ osm_log( &p_osmt->log, OSM_LOG_ERROR,
+ "osmtest_parse_link: ERR 012C: "
+ "Ignoring line %u with unknown token: %s\n",
+ *p_line_num, &line[offset] );
+
+ break;
+ }
+ }
+
+ Exit:
+ OSM_LOG_EXIT( &p_osmt->log );
+ return ( status );
+}
+
+/**********************************************************************
+ **********************************************************************/
+static ib_api_status_t
osmtest_create_db( IN osmtest_t * const p_osmt )
{
FILE *fh;
@@ -6182,6 +6272,10 @@ osmtest_create_db( IN osmtest_t * const
status = osmtest_parse_path( p_osmt, fh, &line_num );
break;
+ case OSMTEST_TOKEN_DEFINE_LINK:
+ status = osmtest_parse_link( p_osmt, fh, &line_num );
+ break;
+
default:
osm_log( &p_osmt->log, OSM_LOG_ERROR,
"osmtest_create_db: ERR 0132: "
More information about the general
mailing list