/* *------------------------------------------------------------------ * Copyright (c) 2005-2016 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "cpel.h" #include "g2.h" typedef struct bound_event_ { u32 event_code; u8 *event_str; u8 *datum_str; } bound_event_t; bound_event_t *bound_events; int widest_track_format=8; typedef struct bound_track_ { u32 track; u8 *track_str; } bound_track_t; bound_track_t *bound_tracks; uword *the_strtab_hash; /* (name, base-VA) hash of all string tables */ uword *the_evtdef_hash; /* (event-id, event-definition) hash */ uword *the_trackdef_hash; /* (track-id, track-definition) hash */ u8 *event_strtab; /* event string-table */ void fatal(char *s) { fprintf(stderr, "%s", s); exit(1); } typedef enum { PASS1=1, PASS2=2, } pass_t; typedef struct { int (*pass1)(cpel_section_header_t *, int, FILE *); int (*pass2)(cpel_section_header_t *, int, FILE *); } section_processor_t; int bad_section(cpel_section_header_t *sh, int verbose, FILE *ofp) { fprintf(ofp, "Bad (type 0) section, skipped...\n"); return(0); } int noop_pass(cpel_section_header_t *sh, int verbose, FILE *ofp) { return(0); } int strtab_pass1(cpel_section_header_t *sh, int verbose, FILE *ofp) { uword *p; u8 *strtab_data_area = (u8 *)(sh+1); /* Multiple string tables with the same name are Bad... */ p = hash_get_mem(the_strtab_hash, strtab_data_area); if (p) { fprintf(ofp, "Duplicate string table name %s", strtab_data_area); } /* * Looks funny, but we really do want key = first string in the * table, value = address(first string in the table) */ hash_set_mem(the_strtab_hash, strtab_data_area, strtab_data_area); if (verbose) { fprintf(ofp, "String Table %s\n", strtab_data_area); } return(0); } int evtdef_pass1(cpel_section_header_t *sh, int verbose, FILE *ofp) { int i, nevents; event_definition_section_header_t *edh; event_definition_t *ep; u8 *this_strtab; u32 event_code; uword *p; bound_event_t *bp; edh = (event_definition_section_header_t *)(sh+1); nevents = ntohl(edh->number_of_event_definitions); if (verbose) { fprintf(ofp, "Event Definition Section: %d definitions\n", nevents); } p = hash_get_mem(the_strtab_hash, edh->string_table_name); if (!p) { fprintf(ofp, "Fatal: couldn't find string table\n"); return(1); } this_strtab = (u8 *)p[0]; initialize_events(); ep = (event_definition_t *)(edh+1); for (i = 0; i < nevents; i++) { event_code = ntohl(ep->event); p = hash_get(the_evtdef_hash, event_code); if (p) { fprintf(ofp, "Event %d redefined, retain first definition\n", event_code); continue; } vec_add2(bound_events, bp, 1); bp->event_code = event_code; bp->event_str = this_strtab + ntohl(ep->event_format); bp->datum_str = this_strtab + ntohl(ep->datum_format); hash_set(the_evtdef_hash, event_code, bp - bound_events); add_event_from_cpel_file(event_code, (char *) bp->event_str, (char *)bp->datum_str); ep++; } finalize_events(); return (0); } int trackdef_pass1(cpel_section_header_t *sh, int verbose, FILE *ofp) { int i, nevents; track_definition_section_header_t *tdh; track_definition_t *tp; u8 *this_strtab; u32 track_code; uword *p; bound_track_t *btp; int track_strlen; tdh = (track_definition_section_header_t *)(sh+1); nevents = ntohl(tdh->number_of_track_definitions); if (verbose) { fprintf(ofp, "Track Definition Section: %d definitions\n", nevents); } p = hash_get_mem(the_strtab_hash, tdh->string_table_name); if (!p) { fprintf(ofp, "Fatal: couldn't find string table\n"); return(1); } this_strtab = (u8 *)p[0]; tp = (track_definition_t *)(tdh+1); for (i = 0; i < nevents; i++) { track_code = ntohl(tp->track); p = hash_get(the_trackdef_hash, track_code); if (p) { fprintf(ofp, "track %d redefined, retain first definition\n", track_code); continue; } vec_add2(bound_tracks, btp, 1); btp->track = track_code; btp->track_str = this_strtab + ntohl(tp->track_format); hash_set(the_trackdef_hash, track_code, btp - bound_tracks); track_strlen = strlen((char *)btp->track_str); if (track_strlen > widest_track_format) widest_track_format = track_strlen; tp++; } return (0); } int unsupported_pass (cpel_section_header_t *sh, int verbose, FILE *ofp) { if (verbose) { f
# Copyright (c) <current-year> <your-organization>
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

add_vpp_plugin(http_static
  SOURCES
  http_static.c
  static_server.c
  http_static.h

  API_FILES
  http_static.api

  API_TEST_SOURCES
  http_static_test.c
)