/* * * LECS main code * * $Id: lecs.c,v 1.2 2001/10/09 22:33:07 paulsch Exp $ * */ #if HAVE_CONFIG_H #include #endif /* Standard includes*/ #include #include #include #include #include #include #include #include #include #include /* ATM includes */ #include /* Local includes */ #include "lecs_load.h" #include "ldb.h" #include "mem_lecs.h" #include "lecs.h" #include "atm_lecs.h" /* Protos */ static void sig_reset(int foobar); static void sig_kill(int foobar); static void usage(const char *progname); int send_response(int fd, unsigned char *buffer, int len); /* Local data */ #define COMP_NAME "MAIN" #define MAX_FD 32 #define P_SIZE 1024 static int stay_alive = 1; static int reset = 0; #define DUMP_PACKETS 0 static void usage(const char *progname) { printf("Usage: %s [-f configuration_file][-l listen_address][-d]\n", progname); } static void sig_reset(int foobar) { reset = 1; } static void sig_kill(int foobar) { stay_alive = 0; } int send_response(int fd, unsigned char *buffer, int len) { LaneControl_t *dp; Elan_t *elan; unsigned short response; #ifdef DUMP_PACKETS int i; #endif if (len < sizeof(LaneControl_t)) return -1; dp = (LaneControl_t *)buffer; if (dp->marker != htons(LE_MARKER) || dp->protocol != LE_PROTOCOL || dp->version != LE_VERSION || dp->opcode != htons(LE_CONFIGURE_REQUEST)) { return -1; } dp->opcode = htons(LE_CONFIGURE_RESPONSE); elan = find_elan(dp->source_atm, dp->lan_type, dp->max_frame, (char*)dp->elan_name, dp->elan_name_size, &response); if (!elan) { dp->status = htons(response); } else { dp->status = htons(LE_STATUS_SUCCESS); dp->lan_type = elan->type; dp->max_frame = elan->max_frame; memcpy(dp->elan_name, elan->elan_name, elan->elan_name_size); dp->elan_name_size = elan->elan_name_size; memcpy(dp->target_atm, elan->les_addr, ATM_ESA_LEN); } #ifdef DUMP_PACKETS for(i=0;i