X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Flib%2Fgscprts%2Frts_main.c;h=748f8a90be89b63d12072bcb1c3433886117f763;hb=07495effe193ca3f73c3bf0ce417068f9ac9dcdd;hp=5cbd092cb93d5f0f5cd0a45e0421c3e8f91d3fc9;hpb=834803ff24ff04d1f952ef2783838e964d961b87;p=com%2Fgs-lite.git diff --git a/src/lib/gscprts/rts_main.c b/src/lib/gscprts/rts_main.c index 5cbd092..748f8a9 100644 --- a/src/lib/gscprts/rts_main.c +++ b/src/lib/gscprts/rts_main.c @@ -1,198 +1,198 @@ -/* ------------------------------------------------ - Copyright 2014 AT&T Intellectual Property - 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 "gsconfig.h" -#include "gstypes.h" -#include "gshub.h" - -#include "lapp.h" -#include "fta.h" -#include "lfta/rts.h" - -#include "stdio.h" -#include "stdlib.h" -#include -#include - -#include -#include -#include -#include -#include - -gs_retval_t main_csv(gs_int32_t devicenum, gs_sp_t device, gs_int32_t mapcnt, gs_sp_t map[]); -gs_retval_t main_csv2(gs_int32_t devicenum, gs_sp_t device, gs_int32_t mapcnt, gs_sp_t map[]); -gs_retval_t main_gdat(gs_int32_t devicenum, gs_sp_t device, gs_int32_t mapcnt, gs_sp_t map[]); -gs_retval_t main_dproto(gs_int32_t devicenum, gs_sp_t device, gs_int32_t mapcnt, gs_sp_t map[]); - -int main (int argc, char* argv[]) { - gs_int32_t pid; - gs_int32_t x; - gs_int32_t y; - gs_sp_t* device; - gs_int32_t devcnt=0; - gs_sp_t* mappings; - gs_int32_t mapcnt=0; - gs_sp_t* lmap; - gs_int32_t lmapcnt=0; - FILE * cfg_file; - gs_int32_t tip1,tip2,tip3,tip4; - endpoint gshub; - gs_sp_t instance_name; - - - gsopenlog(argv[0]); - - if (setpgid(0,0)<0) { - gslog(LOG_EMERG,"Could not set process group id of rts"); - exit(1); - } - - if (argc<4) { - gslog(LOG_EMERG,"Wrong arguments at startup"); - exit(1); - } - - /* allocate more than enough for each array */ - if ((device=(gs_sp_t*)malloc(sizeof(gs_sp_t*) * argc))==0) { - gslog(LOG_EMERG,"malloc error"); - exit(1); - } - if ((mappings=(gs_sp_t*)malloc(sizeof(gs_sp_t*) * argc))==0) { - gslog(LOG_EMERG,"malloc error"); - exit(1); - } - if ((lmap=(gs_sp_t*)malloc(sizeof(gs_sp_t*) * argc))==0) { - gslog(LOG_EMERG,"malloc error"); - exit(1); - } - - /* parse the arguments */ - - if ((sscanf(argv[1],"%u.%u.%u.%u:%hu",&tip1,&tip2,&tip3,&tip4,&(gshub.port))!=5)) { - gslog(LOG_EMERG,"HUB IP NOT DEFINED"); - exit(1); - } - gshub.ip=htonl(tip1<<24|tip2<<16|tip3<<8|tip4); - gshub.port=htons(gshub.port); - instance_name=strdup(argv[2]); - if (set_hub(gshub)!=0) { - gslog(LOG_EMERG,"Could not set hub"); - exit(1); - } - if (set_instance_name(instance_name)!=0) { - gslog(LOG_EMERG,"Could not set instance name"); - exit(1); - } - - for(x=3;x +#include + +#include +#include +#include +#include +#include + +gs_retval_t main_csv(gs_int32_t devicenum, gs_sp_t device, gs_int32_t mapcnt, gs_sp_t map[]); +gs_retval_t main_csv2(gs_int32_t devicenum, gs_sp_t device, gs_int32_t mapcnt, gs_sp_t map[]); +gs_retval_t main_gdat(gs_int32_t devicenum, gs_sp_t device, gs_int32_t mapcnt, gs_sp_t map[]); +gs_retval_t main_dproto(gs_int32_t devicenum, gs_sp_t device, gs_int32_t mapcnt, gs_sp_t map[]); + +int main (int argc, char* argv[]) { + gs_int32_t pid; + gs_int32_t x; + gs_int32_t y; + gs_sp_t* device; + gs_int32_t devcnt=0; + gs_sp_t* mappings; + gs_int32_t mapcnt=0; + gs_sp_t* lmap; + gs_int32_t lmapcnt=0; + FILE * cfg_file; + gs_int32_t tip1,tip2,tip3,tip4; + endpoint gshub; + gs_sp_t instance_name; + + + gsopenlog(argv[0]); + + if (setpgid(0,0)<0) { + gslog(LOG_EMERG,"Could not set process group id of rts"); + exit(1); + } + + if (argc<4) { + gslog(LOG_EMERG,"Wrong arguments at startup"); + exit(1); + } + + /* allocate more than enough for each array */ + if ((device=(gs_sp_t*)malloc(sizeof(gs_sp_t*) * argc))==0) { + gslog(LOG_EMERG,"malloc error"); + exit(1); + } + if ((mappings=(gs_sp_t*)malloc(sizeof(gs_sp_t*) * argc))==0) { + gslog(LOG_EMERG,"malloc error"); + exit(1); + } + if ((lmap=(gs_sp_t*)malloc(sizeof(gs_sp_t*) * argc))==0) { + gslog(LOG_EMERG,"malloc error"); + exit(1); + } + + /* parse the arguments */ + + if ((sscanf(argv[1],"%u.%u.%u.%u:%hu",&tip1,&tip2,&tip3,&tip4,&(gshub.port))!=5)) { + gslog(LOG_EMERG,"HUB IP NOT DEFINED"); + exit(1); + } + gshub.ip=htonl(tip1<<24|tip2<<16|tip3<<8|tip4); + gshub.port=htons(gshub.port); + instance_name=strdup(argv[2]); + if (set_hub(gshub)!=0) { + gslog(LOG_EMERG,"Could not set hub"); + exit(1); + } + if (set_instance_name(instance_name)!=0) { + gslog(LOG_EMERG,"Could not set instance name"); + exit(1); + } + + for(x=3;x