Permalink
Browse files

Extend the C parser to handle new SDH-related events

  • Loading branch information...
matthiasl committed Jan 28, 2013
1 parent d9d415e commit 4fe0a380be658ad3ece5648b63306ee56d78154b
Showing with 24 additions and 8 deletions.
  1. +13 −0 c/gth_client_xml_parse.c
  2. +11 −8 c/gth_client_xml_parse.h
View
@@ -485,6 +485,7 @@ static enum Token_type name_to_token_type(const char* name)
if (!strcmp(name, "alert")) return GTH_RESP_ALERT;
if (!strcmp(name, "atm_message")) return GTH_RESP_ATM_MESSAGE;
if (!strcmp(name, "attribute")) return GTH_RESP_ATTRIBUTE;
if (!strcmp(name, "backup")) return GTH_RESP_BACKUP;
if (!strcmp(name, "controller")) return GTH_RESP_CONTROLLER;
if (!strcmp(name, "ebs")) return GTH_RESP_EBS;
if (!strcmp(name, "error")) return GTH_RESP_ERROR;
@@ -503,6 +504,8 @@ static enum Token_type name_to_token_type(const char* name)
if (!strcmp(name, "mtp2_message")) return GTH_RESP_MTP2_MESSAGE;
if (!strcmp(name, "ok")) return GTH_RESP_OK;
if (!strcmp(name, "resource")) return GTH_RESP_RESOURCE;
if (!strcmp(name, "sdh_message")) return GTH_RESP_SDH_MESSAGE;
if (!strcmp(name, "sfp_message")) return GTH_RESP_SFP_MESSAGE;
if (!strcmp(name, "slip")) return GTH_RESP_SLIP;
if (!strcmp(name, "sync_message")) return GTH_RESP_SYNC_MESSAGE;
if (!strcmp(name, "tone")) return GTH_RESP_TONE;
@@ -681,6 +684,16 @@ void gth_print_tree(GTH_resp *resp) {
fprintf(stderr, "\n");
break;
case GTH_RESP_SDH_MESSAGE:
fprintf(stderr, " sdh_message: ");
print_attributes(resp);
break;
case GTH_RESP_SFP_MESSAGE:
fprintf(stderr, " sfp_message: ");
print_attributes(resp);
break;
case GTH_RESP_SLIP:
fprintf(stderr, " slip: ");
print_attributes(resp);
View
@@ -5,7 +5,7 @@
// Scanner and parser for the responses generated by a Corelatus GTH,
// which are documented in http://www.corelatus.com/gth/api/
//
// This scanner/parser is complete, i.e. it can parse all possible
// This scanner/parser is complete, i.e. it can parse all possible
// XML responses from a GTH.
//
// Typical use:
@@ -38,7 +38,7 @@
// * Neither the name of Corelatus nor the
// names of its contributors may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
//
// THIS SOFTWARE IS PROVIDED BY Corelatus ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -56,28 +56,31 @@ typedef enum {
GTH_RESP_ALERT,
GTH_RESP_ATM_MESSAGE,
GTH_RESP_ATTRIBUTE,
GTH_RESP_CONTROLLER,
GTH_RESP_BACKUP,
GTH_RESP_CONTROLLER,
GTH_RESP_EBS,
GTH_RESP_ERROR,
GTH_RESP_EVENT,
GTH_RESP_FATALITY,
GTH_RESP_FAULT,
GTH_RESP_FAULT,
GTH_RESP_F_RELAY_MESSAGE,
GTH_RESP_INFO,
GTH_RESP_JOB,
GTH_RESP_L1_MESSAGE,
GTH_RESP_L2_ALARM,
GTH_RESP_L2_ALARM,
GTH_RESP_L2_SOCKET_ALERT,
GTH_RESP_LAPD_MESSAGE,
GTH_RESP_LEVEL,
GTH_RESP_MESSAGE_ENDED,
GTH_RESP_MTP2_MESSAGE,
GTH_RESP_MTP2_MESSAGE,
GTH_RESP_OK,
GTH_RESP_RESOURCE,
GTH_RESP_RESOURCE,
GTH_RESP_SDH_MESSAGE,
GTH_RESP_SFP_MESSAGE,
GTH_RESP_SLIP,
GTH_RESP_STATE,
GTH_RESP_SYNC_MESSAGE,
@@ -108,7 +111,7 @@ struct GTH_resp_struct {
typedef struct GTH_resp_struct GTH_resp;
// Scan a string. Return a pointer-to-resp tree.
// Scan a string. Return a pointer-to-resp tree.
// Caller must free the tree when done, using gth_free_resp()
GTH_resp *gth_parse(const char *string);

0 comments on commit 4fe0a38

Please sign in to comment.