| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270 |
- /*
- * Copyright (c) 2002-2004 MontaVista Software, Inc.
- *
- * All rights reserved.
- *
- * Author: Steven Dake (sdake@mvista.com)
- *
- * This software licensed under BSD license, the text of which follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * - Neither the name of the MontaVista Software, Inc. 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
- #include <sys/poll.h>
- #include <sys/types.h>
- #include <sys/socket.h>
- #include <sys/un.h>
- #include <sys/sysinfo.h>
- #include <netinet/in.h>
- #include <linux/if.h>
- #include <linux/sockios.h>
- #include <unistd.h>
- #include <fcntl.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <errno.h>
- #include <signal.h>
- #include "../include/ais_types.h"
- #include "../include/ais_msg.h"
- #include "../include/list.h"
- #include "../include/queue.h"
- #include "gmi.h"
- #include "poll.h"
- #include "mempool.h"
- #include "parse.h"
- #include "main.h"
- #include "print.h"
- #include "handlers.h"
- struct invocation {
- struct conn_info *conn_info;
- int interface;
- int active;
- };
- struct invocation *invocation_entries = 0;
- int invocation_entries_size = 0;
- #ifdef INPARSEDOTH
- enum amfOperationalState {
- AMF_OPER_DISABLED,
- AMF_OPER_ENABLED
- };
- enum amfAdministrativeState {
- AMF_ADMIN_UNLOCKED,
- AMF_ADMIN_LOCKED,
- AMF_ADMIN_STOPPING
- };
- enum amfOperationalAdministrativeState {
- AMF_ENABLED_UNLOCKED,
- AMF_DISABLED_UNLOCKED,
- AMF_DISABLED_LOCKED,
- AMF_ENABLED_STOPPING
- };
- /*
- * State machines for states in AMF
- */
- enum amfEnabledUnlockedState {
- AMF_ENABLED_UNLOCKED_INITIAL,
- AMF_ENABLED_UNLOCKED_IN_SERVICE_REQUESTED,
- AMF_ENABLED_UNLOCKED_IN_SERVICE_COMPLETED,
- AMF_ENABLED_UNLOCKED_ACTIVE_REQUESTED,
- AMF_ENABLED_UNLOCKED_ACTIVE_COMPLETED,
- AMF_ENABLED_UNLOCKED_STANDBY_REQUESTED,
- AMF_ENABLED_UNLOCKED_STANDBY_COMPLETED,
- };
- enum amfDisabledUnlockedState {
- AMF_DISABLED_UNLOCKED_INITIAL,
- AMF_DISABLED_UNLOCKED_QUIESCED_REQUESTED,
- AMF_DISABLED_UNLOCKED_QUIESCED_COMPLETED,
- AMF_DISABLED_UNLOCKED_OUT_OF_SERVICE_REQUESTED,
- AMF_DISABLED_UNLOCKED_OUT_OF_SERVICE_COMPLETED
- };
-
- enum amfDisabledLockedState {
- AMF_DISABLED_LOCKED_INITIAL,
- AMF_DISABLED_LOCKED_QUIESCED_REQUESTED,
- AMF_DISABLED_LOCKED_QUIESCED_COMPLETED,
- AMF_DISABLED_LOCKED_OUT_OF_SERVICE_REQUESTED
- AMF_DISABLED_LOCKED_OUT_OF_SERVICE_COMPLETED,
- };
- enum amfEnabledStoppingState {
- AMF_ENABLED_STOPPING_INITIAL,
- AMF_ENABLED_STOPPING_STOPPING_REQUESTED,
- AMF_ENABLED_STOPPING_STOPPING_COMPLETED,
- };
- /*
- * Internal Functions
- */
- static void componentOutOfServiceSetNoApi (
- struct saAmfComponent *component);
- #endif
- static void grow_amf_track_table (
- struct conn_info *conn_info,
- int growby);
- static void sendProtectionGroupNotification (
- struct conn_info *conn_info,
- SaAmfProtectionGroupNotificationT *notificationBufferAddress,
- struct saAmfProtectionGroup *amfProtectionGroup,
- struct saAmfComponent *changedComponent,
- SaAmfProtectionGroupChangesT changeToComponent,
- SaUint8T trackFlags);
- static int activeServiceUnitsCount (
- struct saAmfGroup *saAmfGroup);
- #ifdef COMPILE_OUT
- static void enumerateComponents (
- void (*function)(struct saAmfComponent *, void *data),
- void *data);
- static void CSIRemove (
- struct conn_info *conn_info);
- static void haStateSetClusterInit (
- struct conn_info *conn_info,
- struct saAmfComponent *saAmfComponent);
- #endif
- static void haStateSetCluster (
- struct saAmfComponent *saAmfComponent,
- SaAmfHAStateT haState);
- static void readinessStateSetApi (
- struct saAmfComponent *component,
- SaAmfReadinessStateT readinessState);
- #ifdef COMPILE_OUT
- static void readinessStateSetClusterInit (
- struct conn_info *conn_info,
- struct saAmfComponent *saAmfComponent);
- #endif
- static void readinessStateSetCluster (
- struct saAmfComponent *saAmfComponent,
- SaAmfReadinessStateT readinessState);
- #ifdef COMPILE_OUT
- static void enumerateComponentsClusterInit (
- struct saAmfComponent *component,
- void *data);
- #endif
- static void dsm (
- struct saAmfComponent *saAmfComponent);
- #if 0 /* NOT IMPLEMENTED */
- static void componentTerminate (
- struct conn_info *conn_info);
- #endif
- static void timer_function_libamf_healthcheck (
- void *data);
- static struct saAmfProtectionGroup *findProtectionGroup (
- SaNameT *csiName);
- static struct saAmfComponent *findComponentInProtectionGroup (
- SaNameT *csiName,
- SaNameT *compName);
- static void sendProtectionGroupNotifications (
- struct saAmfComponent *changedComponent,
- SaAmfProtectionGroupChangesT changeToComponent);
- static void sendProtectionGroupNotification (
- struct conn_info *conn_info,
- SaAmfProtectionGroupNotificationT *notificationBufferAddress,
- struct saAmfProtectionGroup *amfProtectionGroup,
- struct saAmfComponent *changedComponent,
- SaAmfProtectionGroupChangesT changeToComponent,
- SaUint8T trackFlags);
- static void response_handler_readinessstatesetcallback (
- struct conn_info *conn_info,
- struct req_amf_response *req_amf_response);
- static void response_handler_csisetcallback (
- struct conn_info *conn_info,
- struct req_amf_response *req_amf_response);
- static int amf_exit_fn (struct conn_info *conn_info);
- static int amfExecutiveInitialize (void);
- static int message_handler_req_exec_amf_componentregister (void *message);
- static int message_handler_req_exec_amf_componentunregister (void *message);
- static int message_handler_req_exec_amf_errorreport (void *message);
- static int message_handler_req_exec_amf_errorcancelall (void *message);
- static int message_handler_req_exec_amf_readinessstateset (void *message);
- static int message_handler_req_exec_amf_hastateset (void *message);
- static int message_handler_req_amf_init (int conn_info, void *message);
- static int message_handler_req_lib_activatepoll (int conn_info, void *message);
- static int message_handler_req_amf_componentregister (int conn_info, void *message);
- static int message_handler_req_amf_componentunregister (int conn_info, void *message);
- static int message_handler_req_amf_readinessstateget (int conn_info, void *message);
- static int message_handler_req_amf_hastateget (int conn_info, void *message);
- static int message_handler_req_amf_protectiongrouptrackstart (int conn_info, void *message);
- static int message_handler_req_amf_protectiongrouptrackstop (int conn_info, void *message);
- static int message_handler_req_amf_errorreport (int conn_info, void *message);
- static int message_handler_req_amf_errorcancelall (int conn_info, void *message);
- static int message_handler_req_amf_stoppingcomplete (int conn_info, void *message);
- static int message_handler_req_amf_response (int conn_info, void *message);
- static int message_handler_req_amf_componentcapabilitymodelget (int conn_info, void *message);
- int (*amf_libais_handler_fns[]) (int conn_info, void *) = {
- message_handler_req_lib_activatepoll,
- message_handler_req_amf_componentregister,
- message_handler_req_amf_componentunregister,
- message_handler_req_amf_readinessstateget,
- message_handler_req_amf_hastateget,
- message_handler_req_amf_protectiongrouptrackstart,
- message_handler_req_amf_protectiongrouptrackstop,
- message_handler_req_amf_errorreport,
- message_handler_req_amf_errorcancelall,
- message_handler_req_amf_stoppingcomplete,
- message_handler_req_amf_response,
- message_handler_req_amf_componentcapabilitymodelget
- };
- int (*amf_aisexec_handler_fns[]) (void *) = {
- message_handler_req_exec_amf_componentregister,
- message_handler_req_exec_amf_componentunregister,
- message_handler_req_exec_amf_errorreport,
- message_handler_req_exec_amf_errorcancelall,
- message_handler_req_exec_amf_readinessstateset,
- message_handler_req_exec_amf_hastateset,
- };
- /*
- * Exports the interface for the service
- */
- struct service_handler amf_service_handler = {
- libais_handler_fns: amf_libais_handler_fns,
- libais_handler_fns_count: sizeof (amf_libais_handler_fns) / sizeof (int (*)),
- aisexec_handler_fns: amf_aisexec_handler_fns,
- aisexec_handler_fns_count: sizeof (amf_aisexec_handler_fns) / sizeof (int (*)),
- confchg_fn: 0,
- libais_init_fn: message_handler_req_amf_init,
- libais_exit_fn: amf_exit_fn,
- aisexec_init_fn: amfExecutiveInitialize
- };
- static void grow_amf_track_table (struct conn_info *conn_info, int growby)
- {
- struct libamf_ci_trackentry *tracks;
- int newsize;
- int currsize = conn_info->ais_ci.u.libamf_ci.trackEntries;
-
- newsize = growby + currsize;
- if (newsize > currsize) {
- tracks = (struct libamf_ci_trackentry *)mempool_realloc (conn_info->ais_ci.u.libamf_ci.tracks,
- (newsize) * sizeof (struct libamf_ci_trackentry));
- if (tracks == 0) {
- #ifdef DEBUG
- printf ("grow_amf_track_table: out of memory, woops\n");
- #endif
- // TODO
- exit (1);
- }
- memset (&tracks[currsize], 0, growby * sizeof (struct libamf_ci_trackentry));
- conn_info->ais_ci.u.libamf_ci.trackEntries = newsize;
- conn_info->ais_ci.u.libamf_ci.tracks = tracks;
- }
- }
- int req_amf_invocation_create (int interface,
- struct conn_info *conn_info)
- {
- struct invocation *invocation_addr = 0;
- struct invocation *invocation_temp;
- int i;
- int loc;
- for (i = 0; i < invocation_entries_size; i++) {
- if (invocation_entries[i].active == 0) {
- invocation_addr = &invocation_entries[i];
- loc = i;
- break;
- }
- }
- if (invocation_addr == 0) {
- invocation_temp = (struct invocation *)realloc (invocation_entries,
- (invocation_entries_size + 1) * sizeof (struct invocation));
- if (invocation_temp == 0) {
- return (-1);
- }
- invocation_entries = invocation_temp;
- invocation_addr = &invocation_entries[invocation_entries_size];
- loc = invocation_entries_size;
- invocation_entries_size += 1;
- }
- invocation_addr->interface = interface;
- invocation_addr->conn_info = conn_info;
- invocation_addr->active = 1;
- return (loc);
- }
- int req_amf_invocation_get_and_destroy (int invocation, int *interface,
- struct conn_info **conn_info)
- {
- if (invocation > invocation_entries_size) {
- printf ("a\n");
- return (-1);
- }
- if (invocation_entries[invocation].active == 0) {
- printf ("b\n");
- return (-1);
- }
- *interface = invocation_entries[invocation].interface;
- *conn_info = invocation_entries[invocation].conn_info;
- memset (&invocation_entries[invocation], 0, sizeof (struct invocation));
-
- return (0);
- }
- void componentUnregister (
- struct saAmfComponent *component)
- {
- struct req_exec_amf_componentunregister req_exec_amf_componentunregister;
- struct iovec iovecs[2];
- /*
- * This only works on local components
- */
- if (component == 0 || component->local != 1) {
- return;
- }
- log_printf (LOG_LEVEL_DEBUG, "componentUnregister: unregistering component %s\n",
- getSaNameT (&component->name));
- component->probableCause = SA_AMF_NOT_RESPONDING;
- req_exec_amf_componentunregister.header.magic = MESSAGE_MAGIC;
- req_exec_amf_componentunregister.header.size = sizeof (struct req_exec_amf_componentunregister);
- req_exec_amf_componentunregister.header.id = MESSAGE_REQ_EXEC_AMF_COMPONENTUNREGISTER;
- req_exec_amf_componentunregister.source.conn_info = 0;
- req_exec_amf_componentunregister.source.in_addr.s_addr = 0;
- memset (&req_exec_amf_componentunregister.req_lib_amf_componentunregister,
- 0, sizeof (struct req_lib_amf_componentunregister));
- memcpy (&req_exec_amf_componentunregister.req_lib_amf_componentunregister.compName,
- &component->name,
- sizeof (SaNameT));
- iovecs[0].iov_base = &req_exec_amf_componentunregister;
- iovecs[0].iov_len = sizeof (req_exec_amf_componentunregister);
- gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_MED);
- }
- #ifdef COMPILE_OUT
- This should be used for a partition I think
- // This should be used for partition changes
- void enumerateComponents (
- void (*function)(struct saAmfComponent *, void *data),
- void *data)
- {
- struct list_head *AmfGroupList;
- struct list_head *AmfUnitList;
- struct list_head *AmfComponentList;
- struct saAmfGroup *saAmfGroup;
- struct saAmfUnit *AmfUnit;
- struct saAmfComponent *AmfComponent;
- /*
- * Search all groups
- */
- for (AmfGroupList = saAmfGroupHead.next;
- AmfGroupList != &saAmfGroupHead;
- AmfGroupList = AmfGroupList->next) {
- saAmfGroup = list_entry (AmfGroupList,
- struct saAmfGroup, saAmfGroupList);
- /*
- * Search all units
- */
- for (AmfUnitList = saAmfGroup->saAmfUnitHead.next;
- AmfUnitList != &saAmfGroup->saAmfUnitHead;
- AmfUnitList = AmfUnitList->next) {
- AmfUnit = list_entry (AmfUnitList,
- struct saAmfUnit, saAmfUnitList);
- /*
- * Search all components
- */
- for (AmfComponentList = AmfUnit->saAmfComponentHead.next;
- AmfComponentList != &AmfUnit->saAmfComponentHead;
- AmfComponentList = AmfComponentList->next) {
- AmfComponent = list_entry (AmfComponentList,
- struct saAmfComponent, saAmfComponentList);
- function (AmfComponent, data);
- }
- }
- }
- }
- #endif
- int activeServiceUnitsCount (struct saAmfGroup *saAmfGroup) {
- struct saAmfUnit *saAmfUnit;
- struct saAmfComponent *saAmfComponent;
- struct list_head *saAmfComponentList;
- struct list_head *saAmfUnitList;
- int activeServiceUnits = 0;
- int thisServiceUnitActive;
- /*
- * Search all units
- */
- for (activeServiceUnits = 0, saAmfUnitList = saAmfGroup->saAmfUnitHead.next;
- saAmfUnitList != &saAmfGroup->saAmfUnitHead;
- saAmfUnitList = saAmfUnitList->next) {
- saAmfUnit = list_entry (saAmfUnitList,
- struct saAmfUnit, saAmfUnitList);
- /*
- * Search all components
- */
- for (thisServiceUnitActive = 1, saAmfComponentList = saAmfUnit->saAmfComponentHead.next;
- saAmfComponentList != &saAmfUnit->saAmfComponentHead;
- saAmfComponentList = saAmfComponentList->next) {
- saAmfComponent = list_entry (saAmfComponentList,
- struct saAmfComponent, saAmfComponentList);
- if (saAmfComponent->currentHAState != SA_AMF_ACTIVE) {
- thisServiceUnitActive = 0;
- }
- }
- /*
- * If all components are active in service unit, count service unit as active
- */
- if (thisServiceUnitActive) {
- activeServiceUnits += 1;
- }
- }
- return (activeServiceUnits);
- }
- #ifdef CONFIG_TODO
- This should be sent after a service unit is made out of service
- void CSIRemove (struct conn_info *conn_info)
- {
- struct res_amf_csiremovecallback res_amf_csiremovecallback;
-
- if (conn_info->active == 0 ||
- conn_info->service != SOCKET_SERVICE_AMF) {
- return;
- }
- log_printf (LOG_NOTICE_DEBUG, "executing CSI remove callback into API\n");
- res_amf_csiremovecallback.header.magic = MESSAGE_MAGIC;
- res_amf_csiremovecallback.header.id = MESSAGE_RES_AMF_CSIREMOVECALLBACK;
- res_amf_csiremovecallback.header.size = sizeof (struct res_amf_csiremovecallback);
- res_amf_csiremovecallback.invocation =
- req_amf_response_set (
- MESSAGE_REQ_AMF_RESPONSE_SAAMFCSIREMOVECALLBACK,
- conn_info->fd);
- memcpy (&res_amf_csiremovecallback.compName,
- &conn_info->component->name, sizeof (SaNameT));
- memcpy (&res_amf_csiremovecallback.csiName,
- &conn_info->component->saAmfProtectionGroup->name, sizeof (SaNameT));
- res_amf_csiremovecallback.csiFlags = SA_AMF_CSI_ALL_INSTANCES;
- libais_send_response (conn_info, &res_amf_csiremovecallback,
- sizeof (struct res_amf_csiremovecallback));
- }
- #endif
- void haStateSetApi (struct saAmfComponent *component, SaAmfHAStateT haState)
- {
- struct res_amf_csisetcallback res_amf_csisetcallback;
- log_printf (LOG_LEVEL_DEBUG, "sending ha state to API\n");
- if (component->local != 1) {
- return;
- }
- if (component->probableCause == SA_AMF_NOT_RESPONDING) {
- return;
- }
- /*
- * this should be an assertion
- */
- if (component->conn_info->active == 0 ||
- component->conn_info->service != SOCKET_SERVICE_AMF) {
- return;
- }
- res_amf_csisetcallback.header.magic = MESSAGE_MAGIC;
- res_amf_csisetcallback.header.id = MESSAGE_RES_AMF_CSISETCALLBACK;
- res_amf_csisetcallback.header.size = sizeof (struct res_amf_csisetcallback);
- res_amf_csisetcallback.invocation =
- req_amf_invocation_create (
- MESSAGE_REQ_AMF_RESPONSE_SAAMFCSISETCALLBACK,
- component->conn_info);
- if (res_amf_csisetcallback.invocation == -1) {
- printf ("TODO set callback\n");
- }
- memcpy (&res_amf_csisetcallback.compName,
- &component->name, sizeof (SaNameT));
- memcpy (&res_amf_csisetcallback.csiName,
- &component->saAmfProtectionGroup->name, sizeof (SaNameT));
- res_amf_csisetcallback.csiFlags = SA_AMF_CSI_ALL_INSTANCES;
- res_amf_csisetcallback.haState = haState;
- // TODO set activeCompName to correct component name
- memcpy (&res_amf_csisetcallback.activeCompName,
- &component->name, sizeof (SaNameT));
- res_amf_csisetcallback.transitionDescriptor = SA_AMF_CSI_NEW_ASSIGN;
- component->newHAState = haState;
- libais_send_response (component->conn_info, &res_amf_csisetcallback,
- sizeof (struct res_amf_csisetcallback));
- }
- #ifdef COMPILE_OUT
- void haStateSetClusterInit (
- struct conn_info *conn_info,
- struct saAmfComponent *saAmfComponent)
- {
- struct req_exec_amf_hastatesetcluster req_exec_amf_hastatesetcluster;
- return;
- req_exec_amf_hastatesetcluster.header.magic = MESSAGE_MAGIC;
- req_exec_amf_hastatesetcluster.header.id = MESSAGE_REQ_EXEC_AMF_HASTATESET;
- req_exec_amf_hastatesetcluster.header.size = sizeof (struct req_exec_amf_hastatesetcluster);
- memcpy (&req_exec_amf_hastatesetcluster.compName,
- &saAmfComponent->name, sizeof (SaNameT));
- req_exec_amf_hastatesetcluster.haState = saAmfComponent->currentHAState;
- log_printf (LOG_LEVEL_DEBUG, "Sending init ha state message to cluster node to set ha state of component %s\n", getSaNameT (&saAmfComponent->name));
- log_printf (LOG_LEVEL_DEBUG, "ha state is %d\n", saAmfComponent->currentHAState);
- libais_send_response (conn_info, &req_exec_amf_hastatesetcluster,
- sizeof (struct req_exec_amf_hastatesetcluster));
- }
- #endif
- void haStateSetCluster (
- struct saAmfComponent *component,
- SaAmfHAStateT haState)
- {
- struct req_exec_amf_hastateset req_exec_amf_hastateset;
- struct iovec iovecs[2];
- req_exec_amf_hastateset.header.magic = MESSAGE_MAGIC;
- req_exec_amf_hastateset.header.id = MESSAGE_REQ_EXEC_AMF_HASTATESET;
- req_exec_amf_hastateset.header.size = sizeof (struct req_exec_amf_hastateset);
- memcpy (&req_exec_amf_hastateset.compName, &component->name, sizeof (SaNameT));
- req_exec_amf_hastateset.haState = haState;
- log_printf (LOG_LEVEL_DEBUG, "Sending ha state to cluster for component %s\n", getSaNameT (&component->name));
- log_printf (LOG_LEVEL_DEBUG, "ha state is %d\n", haState);
- iovecs[0].iov_base = &req_exec_amf_hastateset;
- iovecs[0].iov_len = sizeof (req_exec_amf_hastateset);
- gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_MED);
- }
- void readinessStateSetApi (struct saAmfComponent *component,
- SaAmfReadinessStateT readinessState)
- {
- struct res_amf_readinessstatesetcallback res_amf_readinessstatesetcallback;
- /*
- * If component is local, don't request service from API
- */
- if (component->local != 1) {
- return;
- }
- if (component->probableCause == SA_AMF_NOT_RESPONDING) {
- return;
- }
-
- /*
- * this should be an assertion
- */
- if (component->conn_info->active == 0 ||
- component->conn_info->service != SOCKET_SERVICE_AMF) {
- return;
- }
- res_amf_readinessstatesetcallback.header.magic = MESSAGE_MAGIC;
- res_amf_readinessstatesetcallback.header.id = MESSAGE_RES_AMF_READINESSSTATESETCALLBACK;
- res_amf_readinessstatesetcallback.header.size = sizeof (struct res_amf_readinessstatesetcallback);
- res_amf_readinessstatesetcallback.invocation =
- req_amf_invocation_create (
- MESSAGE_REQ_AMF_RESPONSE_SAAMFREADINESSSTATESETCALLBACK,
- component->conn_info);
- if (res_amf_readinessstatesetcallback.invocation == -1) {
- printf ("TODO readiness set callback\n");
- }
- memcpy (&res_amf_readinessstatesetcallback.compName,
- &component->name, sizeof (SaNameT));
- res_amf_readinessstatesetcallback.readinessState = readinessState;
- component->newReadinessState = readinessState;
- log_printf (LOG_LEVEL_DEBUG, "Setting conn_info %x to readiness state %d\n", component->conn_info, readinessState);
- libais_send_response (component->conn_info, &res_amf_readinessstatesetcallback,
- sizeof (struct res_amf_readinessstatesetcallback));
- }
- #ifdef COMPILE_OUT
- void readinessStateSetClusterInit (
- struct conn_info *conn_info,
- struct saAmfComponent *saAmfComponent)
- {
- struct req_exec_amf_readinessstatesetcluster req_exec_amf_readinessstatesetcluster;
- return;
- req_exec_amf_readinessstatesetcluster.header.magic = MESSAGE_MAGIC;
- req_exec_amf_readinessstatesetcluster.header.id = MESSAGE_REQ_EXEC_AMF_READINESSSTATESET;
- req_exec_amf_readinessstatesetcluster.header.size = sizeof (struct req_exec_amf_readinessstateset);
- memcpy (&req_exec_amf_readinessstatesetcluster.compName,
- &saAmfComponent->name, sizeof (SaNameT));
- req_exec_amf_readinessstatesetcluster.readinessState = saAmfComponent->currentReadinessState;
- log_printf (LOG_LEVEL_DEBUG, "Sending init message to one cluster node to set readiness state of component %s\n", getSaNameT (&saAmfComponent->name));
- log_printf (LOG_LEVEL_DEBUG, "readiness state is %d\n", saAmfComponent->currentReadinessState);
- libais_send_response (conn_info, &req_exec_amf_readinessstatesetcluster,
- sizeof (struct req_exec_amf_readinessstatesetcluster));
- }
- #endif
- void readinessStateSetCluster (
- struct saAmfComponent *component,
- SaAmfReadinessStateT readinessState)
- {
- struct req_exec_amf_readinessstateset req_exec_amf_readinessstateset;
- struct iovec iovecs[2];
- req_exec_amf_readinessstateset.header.magic = MESSAGE_MAGIC;
- req_exec_amf_readinessstateset.header.id = MESSAGE_REQ_EXEC_AMF_READINESSSTATESET;
- req_exec_amf_readinessstateset.header.size = sizeof (struct req_exec_amf_readinessstateset);
- memcpy (&req_exec_amf_readinessstateset.compName, &component->name, sizeof (SaNameT));
- req_exec_amf_readinessstateset.readinessState = readinessState;
- log_printf (LOG_LEVEL_DEBUG, "Sending message to all cluster nodes to set readiness state of component %s\n",
- getSaNameT (&component->name));
- log_printf (LOG_LEVEL_DEBUG, "readiness state is %d\n", readinessState);
- iovecs[0].iov_base = &req_exec_amf_readinessstateset;
- iovecs[0].iov_len = sizeof (req_exec_amf_readinessstateset);
- gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_MED);
- }
- #ifdef CMOPILE_OUT
- void enumerateComponentsClusterInit (
- struct saAmfComponent *component,
- void *data)
- {
- struct conn_info *conn_info = (int)data;
- return;
- readinessStateSetClusterInit (fd, component);
- haStateSetClusterInit (fd, component);
- }
- #endif
- static void dsmDisabledUnlockedRegisteredOrErrorCancel (
- struct saAmfComponent *component)
- {
- struct saAmfUnit *unit;
- struct list_head *list;
- int serviceUnitEnabled;
-
- log_printf (LOG_LEVEL_DEBUG, "dsmDisabledUnlockedRegisteredOrErrorCancel for %s\n",
- getSaNameT (&component->name));
- unit = component->saAmfUnit;
- for (serviceUnitEnabled = 1, list = unit->saAmfComponentHead.next;
- list != &unit->saAmfComponentHead;
- list = list->next) {
- component = list_entry (list,
- struct saAmfComponent, saAmfComponentList);
- if (component->registered == 0 ||
- component->probableCause) {
- log_printf (LOG_LEVEL_DEBUG, "dsm: Can't transition states, found component not registered or failed.\n", getSaNameT (&component->name));
- serviceUnitEnabled = 0;
- break;
- }
- }
- if (serviceUnitEnabled == 1) {
- log_printf (LOG_LEVEL_DEBUG, "dsm entering AMF_ENABLED_UNLOCKED state.\n");
- component->saAmfUnit->operationalAdministrativeState = AMF_ENABLED_UNLOCKED;
- component->disabledUnlockedState = -1; // SHOULD BE INVALID
- component->enabledUnlockedState = AMF_ENABLED_UNLOCKED_INITIAL;
- dsm (component);
- }
- }
- static void dsmDisabledUnlockedFailed (
- struct saAmfComponent *component)
- {
- struct saAmfUnit *unit;
- struct list_head *list;
- unit = component->saAmfUnit;
- for (list = unit->saAmfComponentHead.next;
- list != &unit->saAmfComponentHead;
- list = list->next) {
- component = list_entry (list, struct saAmfComponent, saAmfComponentList);
- log_printf (LOG_LEVEL_DEBUG, "dsmDisabledUnlockedFailed: for %s.\n",
- getSaNameT (&component->name));
- switch (component->enabledUnlockedState) {
- case AMF_ENABLED_UNLOCKED_IN_SERVICE_REQUESTED:
- case AMF_ENABLED_UNLOCKED_IN_SERVICE_COMPLETED:
- component->disabledUnlockedState = AMF_DISABLED_UNLOCKED_OUT_OF_SERVICE_REQUESTED;
- if (component->probableCause == SA_AMF_NOT_RESPONDING) {
- readinessStateSetCluster (component, SA_AMF_OUT_OF_SERVICE);
- } else {
- readinessStateSetApi (component, SA_AMF_OUT_OF_SERVICE);
- }
- break;
- case AMF_ENABLED_UNLOCKED_ACTIVE_REQUESTED:
- case AMF_ENABLED_UNLOCKED_ACTIVE_COMPLETED:
- case AMF_ENABLED_UNLOCKED_STANDBY_REQUESTED:
- case AMF_ENABLED_UNLOCKED_STANDBY_COMPLETED:
- component->disabledUnlockedState = AMF_DISABLED_UNLOCKED_QUIESCED_REQUESTED;
- if (component->probableCause == SA_AMF_NOT_RESPONDING) {
- haStateSetCluster (component, SA_AMF_QUIESCED);
- } else {
- haStateSetApi (component, SA_AMF_QUIESCED);
- }
- poll_timer_delete (aisexec_poll_handle,
- component->timer_healthcheck);
- component->timer_healthcheck = 0;
- break;
- default:
- log_printf (LOG_LEVEL_DEBUG, "invalid case 5 %d\n", component->enabledUnlockedState);
- break;
- }
- }
- }
- static void dsmDisabledUnlockedQuiescedRequested (
- struct saAmfComponent *component)
- {
- component->disabledUnlockedState = AMF_DISABLED_UNLOCKED_QUIESCED_COMPLETED;
- dsm (component);
- }
- static void dsmDisabledUnlockedQuiescedCompleted (
- struct saAmfComponent *component)
- {
- struct saAmfUnit *unit;
- struct list_head *list;
- int serviceUnitQuiesced;
-
- unit = component->saAmfUnit;
- for (serviceUnitQuiesced = 1, list = unit->saAmfComponentHead.next;
- list != &unit->saAmfComponentHead;
- list = list->next) {
- component = list_entry (list, struct saAmfComponent, saAmfComponentList);
- if (component->probableCause != SA_AMF_NOT_RESPONDING && component->registered) {
- if (component->currentHAState != SA_AMF_QUIESCED) {
- log_printf (LOG_LEVEL_DEBUG, "dsm: Can't transition states, found component not quiesced.\n", getSaNameT (&component->name));
- serviceUnitQuiesced = 0;
- break;
- }
- }
- }
- if (serviceUnitQuiesced == 1) {
- log_printf (LOG_LEVEL_DEBUG, "All components have quiesced, Quiescing completed\n");
- for (list = unit->saAmfComponentHead.next;
- list != &unit->saAmfComponentHead;
- list = list->next) {
- component = list_entry (list, struct saAmfComponent, saAmfComponentList);
- log_printf (LOG_LEVEL_DEBUG, "dsm: Sending readiness state set to OUTOFSERVICE for comp %s.\n",
- getSaNameT (&component->name));
- readinessStateSetApi (component, SA_AMF_OUT_OF_SERVICE);
- component->disabledUnlockedState = AMF_DISABLED_UNLOCKED_OUT_OF_SERVICE_REQUESTED;
- }
- }
- }
- static void dsmDisabledUnlockedOutOfServiceRequested (
- struct saAmfComponent *component)
- {
- component->disabledUnlockedState = AMF_DISABLED_UNLOCKED_OUT_OF_SERVICE_COMPLETED;
- dsm (component);
- }
- static void dsmDisabledUnlockedOutOfServiceCompleted (
- struct saAmfComponent *component)
- {
- struct saAmfUnit *unit;
- struct list_head *list;
- int serviceUnitOutOfService;
- struct saAmfGroup *group = 0;
- struct list_head *comp_list = 0;
- struct list_head *unit_list = 0;
- int serviceUnitInStandby = 0;
- /*
- * Once all components of a service unit are out of service,
- * activate another service unit in standby
- */
- log_printf (LOG_LEVEL_DEBUG, "dsmDisabledUnlockedOutOfServiceCompleted: component out of service %s\n", getSaNameT (&component->name));
- /*
- * Determine if all components have responded to going out of service
- */
-
- unit = component->saAmfUnit;
- for (serviceUnitOutOfService = 1, list = unit->saAmfComponentHead.next;
- list != &unit->saAmfComponentHead;
- list = list->next) {
- component = list_entry (list, struct saAmfComponent, saAmfComponentList);
- if (component->probableCause != SA_AMF_NOT_RESPONDING && component->registered) {
- if (component->currentReadinessState != SA_AMF_OUT_OF_SERVICE) {
- log_printf (LOG_LEVEL_DEBUG, "dsm: Can't transition states, found component not quiesced.\n", getSaNameT (&component->name));
- serviceUnitOutOfService = 0;
- break;
- }
- }
- }
- group = unit->saAmfGroup;
- if (serviceUnitOutOfService == 1) {
- log_printf (LOG_LEVEL_DEBUG, "SU has gone out of service.\n");
- /*
- * Search all units
- */
- for (unit_list = group->saAmfUnitHead.next;
- unit_list != &group->saAmfUnitHead;
- unit_list = unit_list->next) {
- unit = list_entry (unit_list,
- struct saAmfUnit, saAmfUnitList);
- log_printf (LOG_LEVEL_DEBUG, "Checking if service unit is in standby %s\n", getSaNameT (&unit->name));
- /*
- * Search all components
- */
- for (serviceUnitInStandby = 1,
- comp_list = unit->saAmfComponentHead.next;
- comp_list != &unit->saAmfComponentHead;
- comp_list = comp_list->next) {
-
- component = list_entry (comp_list,
- struct saAmfComponent, saAmfComponentList);
-
- if (component->currentHAState != SA_AMF_STANDBY) {
- serviceUnitInStandby = 0;
- break; /* for iteration of service unit components */
- }
- }
- if (serviceUnitInStandby) {
- break; /* for iteration of service group's service units */
- }
- }
- /*
- * All components in service unit are standby, activate standby service unit
- */
- if (serviceUnitInStandby) {
- log_printf (LOG_LEVEL_DEBUG, "unit in standby\n");
- for (list = unit->saAmfComponentHead.next;
- list != &unit->saAmfComponentHead;
- list = list->next) {
-
- component = list_entry (list,
- struct saAmfComponent, saAmfComponentList);
-
- haStateSetApi (component, SA_AMF_ACTIVE);
- }
- } else {
- log_printf (LOG_LEVEL_DEBUG, "Can't activate standby service unit because no standby is available.\n");
- }
- }
- }
- static void dsmEnabledUnlockedInitial (
- struct saAmfComponent *component)
- {
- struct saAmfUnit *unit;
- struct list_head *list;
- unit = component->saAmfUnit;
- for (list = unit->saAmfComponentHead.next;
- list != &unit->saAmfComponentHead;
- list = list->next) {
- component = list_entry (list, struct saAmfComponent, saAmfComponentList);
- readinessStateSetApi (component, SA_AMF_IN_SERVICE);
- log_printf (LOG_LEVEL_DEBUG, "dsm: telling component %s to enter SA_AMF_IN_SERVICE.\n",
- getSaNameT (&component->name));
- component->enabledUnlockedState = AMF_ENABLED_UNLOCKED_IN_SERVICE_REQUESTED;
- }
- }
- static void dsmEnabledUnlockedInServiceRequested (
- struct saAmfComponent *component)
- {
- struct saAmfUnit *unit;
- struct list_head *list;
- int in_service;
- log_printf (LOG_LEVEL_DEBUG, "dsmEnabledUnlockedInServiceRequested %s.\n", getSaNameT (&component->name));
-
- unit = component->saAmfUnit;
- for (in_service = 1, list = unit->saAmfComponentHead.next;
- list != &unit->saAmfComponentHead;
- list = list->next) {
- component = list_entry (list, struct saAmfComponent, saAmfComponentList);
- if (component->currentReadinessState != SA_AMF_IN_SERVICE) {
- log_printf (LOG_LEVEL_DEBUG, "dsm: Found atleast one component not in service\n");
- in_service = 0;
- break;
- }
- }
- if (in_service) {
- log_printf (LOG_LEVEL_DEBUG, "DSM determined component is in service\n");
-
- component->enabledUnlockedState = AMF_ENABLED_UNLOCKED_IN_SERVICE_COMPLETED;
- dsm (component);
- }
- }
- static void dsmEnabledUnlockedInServiceCompleted (
- struct saAmfComponent *component)
- {
- struct saAmfUnit *unit;
- struct list_head *list;
- SaAmfHAStateT newHaState;
- int activeServiceUnits;
- log_printf (LOG_LEVEL_DEBUG, "dsmEnabledUnlockedInServiceCompleted %s.\n", getSaNameT (&component->name));
- unit = component->saAmfUnit;
- for (list = unit->saAmfComponentHead.next;
- list != &unit->saAmfComponentHead;
- list = list->next) {
- component = list_entry (list,
- struct saAmfComponent, saAmfComponentList);
- log_printf (LOG_LEVEL_DEBUG, "Requesting component go active.\n", getSaNameT (&component->name));
- /*
- * Count number of active service units
- */
- activeServiceUnits = activeServiceUnitsCount (component->saAmfUnit->saAmfGroup);
- if (activeServiceUnits < component->saAmfUnit->saAmfGroup->saAmfActiveUnitsDesired) {
- newHaState = SA_AMF_ACTIVE;
- log_printf (LOG_LEVEL_DEBUG, "Setting ha state of component %s to SA_AMF_ACTIVE\n", getSaNameT (&component->name));
- component->enabledUnlockedState = AMF_ENABLED_UNLOCKED_ACTIVE_REQUESTED;
- } else {
- newHaState = SA_AMF_STANDBY;
- log_printf (LOG_LEVEL_DEBUG, "Setting ha state of component %s to SA_AMF_STANDBY\n", getSaNameT (&component->name));
- component->enabledUnlockedState = AMF_ENABLED_UNLOCKED_STANDBY_REQUESTED;
- }
- haStateSetApi (component, newHaState);
- }
- }
-
- void dsmEnabledUnlockedActiveRequested (
- struct saAmfComponent *component)
- {
- if (component->local == 1) {
- log_printf (LOG_LEVEL_DEBUG, "Adding healthcheck timer\n");
- poll_timer_add (aisexec_poll_handle,
- component->healthcheckInterval,
- (void *)component->conn_info,
- timer_function_libamf_healthcheck,
- &component->timer_healthcheck);
- }
- component->enabledUnlockedState = AMF_ENABLED_UNLOCKED_ACTIVE_COMPLETED;
- }
- void dsmEnabledUnlockedStandbyRequested (
- struct saAmfComponent *component)
- {
- if (component->local == 1) {
- log_printf (LOG_LEVEL_DEBUG, "Adding healthcheck timer\n");
- poll_timer_add (aisexec_poll_handle,
- component->healthcheckInterval,
- (void *)component->conn_info,
- timer_function_libamf_healthcheck,
- &component->timer_healthcheck);
- }
- component->enabledUnlockedState = AMF_ENABLED_UNLOCKED_STANDBY_COMPLETED;
- }
- void dsmEnabledUnlockedTransitionDisabledUnlocked (
- struct saAmfComponent *component)
- {
- struct saAmfUnit *unit;
- struct list_head *list;
- unit = component->saAmfUnit;
- for (list = unit->saAmfComponentHead.next;
- list != &unit->saAmfComponentHead;
- list = list->next) {
- component = list_entry (list, struct saAmfComponent, saAmfComponentList);
- log_printf (LOG_LEVEL_DEBUG, "Requesting component %s transition to disabled.\n",
- getSaNameT (&component->name));
- component->saAmfUnit->operationalAdministrativeState = AMF_DISABLED_UNLOCKED;
- component->disabledUnlockedState = AMF_DISABLED_UNLOCKED_FAILED;
- }
- dsm (component);
- }
-
- static void dsmEnabledUnlocked (
- struct saAmfComponent *component)
- {
- switch (component->enabledUnlockedState) {
- case AMF_ENABLED_UNLOCKED_INITIAL:
- dsmEnabledUnlockedInitial (component);
- break;
- case AMF_ENABLED_UNLOCKED_IN_SERVICE_REQUESTED:
- dsmEnabledUnlockedInServiceRequested (component);
- break;
- case AMF_ENABLED_UNLOCKED_IN_SERVICE_COMPLETED:
- dsmEnabledUnlockedInServiceCompleted (component);
- break;
- case AMF_ENABLED_UNLOCKED_ACTIVE_REQUESTED:
- dsmEnabledUnlockedActiveRequested (component);
- break;
- case AMF_ENABLED_UNLOCKED_ACTIVE_COMPLETED:
- /* noop - operational state */
- break;
- case AMF_ENABLED_UNLOCKED_STANDBY_REQUESTED:
- dsmEnabledUnlockedActiveRequested (component);
- break;
- case AMF_ENABLED_UNLOCKED_STANDBY_COMPLETED:
- /* noop - operational state */
- break;
-
- default:
- log_printf (LOG_LEVEL_DEBUG, "dsmEnabledUnlocked: unkown state machine value.\n");
- }
- }
- static void dsmDisabledUnlocked (
- struct saAmfComponent *component)
- {
- log_printf (LOG_LEVEL_DEBUG, "dsmDisabledUnlocked for %s state %d\n",
- getSaNameT (&component->name),
- component->disabledUnlockedState);
- switch (component->disabledUnlockedState) {
- case AMF_DISABLED_UNLOCKED_REGISTEREDORERRORCANCEL:
- dsmDisabledUnlockedRegisteredOrErrorCancel (component);
- break;
- case AMF_DISABLED_UNLOCKED_FAILED:
- dsmDisabledUnlockedFailed (component);
- break;
- case AMF_DISABLED_UNLOCKED_QUIESCED_REQUESTED:
- dsmDisabledUnlockedQuiescedRequested (component);
- break;
- case AMF_DISABLED_UNLOCKED_QUIESCED_COMPLETED:
- dsmDisabledUnlockedQuiescedCompleted (component);
- break;
- case AMF_DISABLED_UNLOCKED_OUT_OF_SERVICE_REQUESTED:
- dsmDisabledUnlockedOutOfServiceRequested (component);
- break;
- case AMF_DISABLED_UNLOCKED_OUT_OF_SERVICE_COMPLETED:
- dsmDisabledUnlockedOutOfServiceCompleted (component);
- break;
- default:
- log_printf (LOG_LEVEL_DEBUG, "dsmDisabledUnlocked: unkown state machine value %d.\n", component->disabledUnlockedState);
- }
- }
- static void dsm (
- struct saAmfComponent *component)
- {
- log_printf (LOG_LEVEL_DEBUG, "dsm for component %s\n", getSaNameT (&component->name));
- switch (component->saAmfUnit->operationalAdministrativeState) {
- case AMF_DISABLED_UNLOCKED:
- dsmDisabledUnlocked (component);
- break;
- case AMF_ENABLED_UNLOCKED:
- dsmEnabledUnlocked (component);
- break;
- /*
- AMF_DISABLED_LOCKED,
- AMF_ENABLED_STOPPING
- */
- default:
- log_printf (LOG_LEVEL_DEBUG, "dsm: unknown state machine value.\n");
- }
- }
- #if 0
- /*
- * This is currently unused, but executes the componentterminatecallback
- * callback in the AMF api.
- */
- void componentTerminate (struct conn_info *conn_info)
- {
- struct res_amf_componentterminatecallback res_amf_componentterminatecallback;
- res_amf_componentterminatecallback.header.magic = MESSAGE_MAGIC;
- res_amf_componentterminatecallback.header.id = MESSAGE_RES_AMF_COMPONENTTERMINATECALLBACK;
- res_amf_componentterminatecallback.header.size = sizeof (struct res_amf_componentterminatecallback);
- res_amf_componentterminatecallback.invocation =
- req_amf_response_set (
- MESSAGE_REQ_AMF_RESPONSE_SAAMFCOMPONENTTERMINATECALLBACK,
- fd);
- memcpy (&res_amf_componentterminatecallback.compName,
- &connections[fd].component->name, sizeof (SaNameT));
- connections[fd].component->newReadinessState = SA_AMF_OUT_OF_SERVICE;
- log_printf (LOG_LEVEL_DEBUG, "terminating component on fd %d\n", fd);
- libais_send_response (fd, &res_amf_componentterminatecallback,
- sizeof (struct res_amf_componentterminatecallback));
- }
- #endif /* Not currently implemented */
- void errorReport (
- struct saAmfComponent *component,
- SaAmfProbableCauseT probableCause)
- {
- struct req_exec_amf_errorreport req_exec_amf_errorreport;
- struct iovec iovecs[2];
- req_exec_amf_errorreport.header.magic = MESSAGE_MAGIC;
- req_exec_amf_errorreport.header.size = sizeof (struct req_exec_amf_errorreport);
- req_exec_amf_errorreport.header.id = MESSAGE_REQ_EXEC_AMF_ERRORREPORT;
- req_exec_amf_errorreport.source.conn_info = 0;
- req_exec_amf_errorreport.source.in_addr.s_addr = 0;
- memcpy (&req_exec_amf_errorreport.req_lib_amf_errorreport.erroneousComponent,
- &component->name,
- sizeof (SaNameT));
- req_exec_amf_errorreport.req_lib_amf_errorreport.errorDescriptor.probableCause = probableCause;
- iovecs[0].iov_base = &req_exec_amf_errorreport;
- iovecs[0].iov_len = sizeof (req_exec_amf_errorreport);
- gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_MED);
- }
- int healthcheck_instance = 0;
- void timer_function_libamf_healthcheck (void *data) {
- struct res_amf_healthcheckcallback res_amf_healthcheckcallback;
- struct conn_info *conn_info = (struct conn_info *)data;
- res_amf_healthcheckcallback.header.magic = MESSAGE_MAGIC;
- res_amf_healthcheckcallback.header.id = MESSAGE_RES_AMF_HEALTHCHECKCALLBACK;
- res_amf_healthcheckcallback.header.size = sizeof (struct res_amf_healthcheckcallback);
- log_printf (LOG_LEVEL_DEBUG, "checking healthcheck on component %s\n",
- getSaNameT (&conn_info->component->name));
- if (conn_info->component->healthcheck_outstanding == 1) {
- log_printf (LOG_LEVEL_DEBUG, "Healthcheck timed out on component %s\n",
- getSaNameT (&conn_info->component->name));
- /*
- * Report the error to the rest of the cluster using the normal state machine
- */
- errorReport (conn_info->component, SA_AMF_NOT_RESPONDING);
- conn_info->component->healthcheck_outstanding = 2;
- } else
- if (conn_info->component->healthcheck_outstanding == 0) {
- conn_info->component->healthcheck_outstanding = 1;
- /*
- * Send healthcheck message
- */
- res_amf_healthcheckcallback.invocation =
- req_amf_invocation_create (
- MESSAGE_REQ_AMF_RESPONSE_SAAMFHEALTHCHECKCALLBACK,
- conn_info);
- if (res_amf_healthcheckcallback.invocation == -1) {
- printf ("TODO healthcheck set callback\n");
- }
- memcpy (&res_amf_healthcheckcallback.compName,
- &conn_info->component->name,
- sizeof (SaNameT));
- res_amf_healthcheckcallback.checkType = SA_AMF_HEARTBEAT;
- log_printf (LOG_LEVEL_DEBUG, "Sending instance %d\n", healthcheck_instance);
- res_amf_healthcheckcallback.instance = healthcheck_instance++;
- libais_send_response (conn_info,
- &res_amf_healthcheckcallback,
- sizeof (struct res_amf_healthcheckcallback));
- poll_timer_add (aisexec_poll_handle,
- conn_info->component->healthcheckInterval,
- (void *)conn_info,
- timer_function_libamf_healthcheck,
- &conn_info->component->timer_healthcheck);
- }
- }
- struct saAmfProtectionGroup *findProtectionGroup (
- SaNameT *csiName)
- {
- struct list_head *AmfGroupList;
- struct list_head *AmfProtectionGroupList;
- struct saAmfGroup *saAmfGroup;
- struct saAmfProtectionGroup *AmfProtectionGroup;
- /*
- * Search all groups
- */
- for (AmfGroupList = saAmfGroupHead.next;
- AmfGroupList != &saAmfGroupHead;
- AmfGroupList = AmfGroupList->next) {
- saAmfGroup = list_entry (AmfGroupList,
- struct saAmfGroup, saAmfGroupList);
- /*
- * Search all protection groups
- */
- for (AmfProtectionGroupList = saAmfGroup->saAmfProtectionGroupHead.next;
- AmfProtectionGroupList != &saAmfGroup->saAmfProtectionGroupHead;
- AmfProtectionGroupList = AmfProtectionGroupList->next) {
- AmfProtectionGroup = list_entry (AmfProtectionGroupList,
- struct saAmfProtectionGroup, saAmfProtectionGroupList);
- if (SaNameTisNameT (csiName, &AmfProtectionGroup->name)) {
- return (AmfProtectionGroup);
- }
- }
- }
- return (0);
- }
- struct saAmfComponent *findComponentInProtectionGroup (
- SaNameT *csiName,
- SaNameT *compName)
- {
- struct list_head *AmfGroupList = 0;
- struct list_head *AmfProtectionGroupList = 0;
- struct list_head *AmfComponentList = 0;
- struct saAmfGroup *saAmfGroup = 0;
- struct saAmfProtectionGroup *AmfProtectionGroup = 0;
- struct saAmfComponent *AmfComponent = 0;
- int found = 0;
- /*
- * Search all groups
- */
- for (AmfGroupList = saAmfGroupHead.next;
- AmfGroupList != &saAmfGroupHead;
- AmfGroupList = AmfGroupList->next) {
- saAmfGroup = list_entry (AmfGroupList,
- struct saAmfGroup, saAmfGroupList);
- /*
- * Search all protection groups
- */
- for (AmfProtectionGroupList = saAmfGroup->saAmfProtectionGroupHead.next;
- AmfProtectionGroupList != &saAmfGroup->saAmfProtectionGroupHead;
- AmfProtectionGroupList = AmfProtectionGroupList->next) {
- AmfProtectionGroup = list_entry (AmfProtectionGroupList,
- struct saAmfProtectionGroup, saAmfProtectionGroupList);
- if (SaNameTisNameT (csiName, &AmfProtectionGroup->name)) {
- /*
- * Search all components
- */
- for (AmfComponentList = AmfProtectionGroup->saAmfMembersHead.next;
- AmfComponentList != &AmfProtectionGroup->saAmfMembersHead;
- AmfComponentList = AmfComponentList->next) {
- AmfComponent = list_entry (AmfComponentList,
- struct saAmfComponent, saAmfProtectionGroupList);
- if (SaNameTisNameT (compName, &AmfComponent->name)) {
- found = 1;
- }
- }
- }
- }
- }
- if (found) {
- return (AmfComponent);
- } else {
- return (0);
- }
- }
- DECLARE_LIST_INIT (library_notification_send_listhead);
- void sendProtectionGroupNotifications (
- struct saAmfComponent *changedComponent,
- SaAmfProtectionGroupChangesT changeToComponent)
- {
- int i;
- struct conn_info *conn_info;
- struct list_head *list;
- log_printf (LOG_LEVEL_DEBUG, "sendProtectionGroupNotifications: sending PGs to API.\n");
- /*
- * Iterate all tracked connections
- */
- for (list = library_notification_send_listhead.next;
- list != &library_notification_send_listhead;
- list = list->next) {
- conn_info = list_entry (list, struct conn_info, conn_list);
- for (i = 0; i < conn_info->ais_ci.u.libamf_ci.trackEntries; i++) {
- if (conn_info->ais_ci.u.libamf_ci.tracks[i].active) {
- sendProtectionGroupNotification (conn_info,
- conn_info->ais_ci.u.libamf_ci.tracks[i].notificationBufferAddress,
- changedComponent->saAmfProtectionGroup,
- changedComponent,
- changeToComponent,
- conn_info->ais_ci.u.libamf_ci.tracks[i].trackFlags);
- } /* if track flags active */
- } /* for all track entries */
- } /* for all connection entries */
- }
- void sendProtectionGroupNotification (struct conn_info *conn_info,
- SaAmfProtectionGroupNotificationT *notificationBufferAddress,
- struct saAmfProtectionGroup *amfProtectionGroup,
- struct saAmfComponent *changedComponent,
- SaAmfProtectionGroupChangesT changeToComponent,
- SaUint8T trackFlags)
- {
- struct res_amf_protectiongrouptrackcallback res_amf_protectiongrouptrackcallback;
- SaAmfProtectionGroupNotificationT *protectionGroupNotification = 0;
- int notifyEntries = 0;
- struct saAmfComponent *component;
- struct list_head *componentList;
- /*
- * Step through all components and generate protection group list for csi
- */
- for (componentList = amfProtectionGroup->saAmfMembersHead.next;
- componentList != &amfProtectionGroup->saAmfMembersHead;
- componentList = componentList->next) {
- component = list_entry (componentList,
- struct saAmfComponent, saAmfProtectionGroupList);
- /*
- * Generate new track entry for following cases:
- * 1. If this component is the changed component and
- * SA_TRACK_CHANGES_ONLY is set
- * 2. If track flags indicate SA_TRACK_CURRENT or SA_TRACK_CHANGES
- */
- if (component == changedComponent ||
- (trackFlags & (SA_TRACK_CURRENT | SA_TRACK_CHANGES))) {
- protectionGroupNotification = (SaAmfProtectionGroupNotificationT *)mempool_realloc (protectionGroupNotification,
- sizeof (SaAmfProtectionGroupNotificationT) * (notifyEntries + 1));
- memcpy (&protectionGroupNotification[notifyEntries].member.compName,
- &component->name, sizeof (SaNameT));
- memcpy (&protectionGroupNotification[notifyEntries].member.readinessState,
- &component->currentReadinessState, sizeof (SaAmfReadinessStateT));
- memcpy (&protectionGroupNotification[notifyEntries].member.haState,
- &component->currentHAState, sizeof (SaAmfHAStateT));
- if (component == changedComponent) {
- protectionGroupNotification[notifyEntries].change = changeToComponent;
- } else {
- protectionGroupNotification[notifyEntries].change = SA_AMF_PROTECTION_GROUP_NO_CHANGE;
- }
- notifyEntries += 1;
- }
- } /* for */
- /*
- * Send track callback
- */
- if (notifyEntries) {
- res_amf_protectiongrouptrackcallback.header.magic = MESSAGE_MAGIC;
- res_amf_protectiongrouptrackcallback.header.size =
- sizeof (struct res_amf_protectiongrouptrackcallback) +
- (notifyEntries * sizeof (SaAmfProtectionGroupNotificationT));
- res_amf_protectiongrouptrackcallback.header.id = MESSAGE_RES_AMF_PROTECTIONGROUPTRACKCALLBACK;
- res_amf_protectiongrouptrackcallback.numberOfItems = notifyEntries;
- res_amf_protectiongrouptrackcallback.numberOfMembers = notifyEntries;
- memcpy (&res_amf_protectiongrouptrackcallback.csiName,
- &amfProtectionGroup->name, sizeof (SaNameT));
- res_amf_protectiongrouptrackcallback.notificationBufferAddress = notificationBufferAddress;
- libais_send_response (conn_info, &res_amf_protectiongrouptrackcallback,
- sizeof (struct res_amf_protectiongrouptrackcallback));
- libais_send_response (conn_info, protectionGroupNotification,
- sizeof (SaAmfProtectionGroupNotificationT) * notifyEntries);
- mempool_free (protectionGroupNotification);
- }
- }
- /*
- * The response handler for readiness state set callback
- */
- static void response_handler_readinessstatesetcallback (struct conn_info *conn_info,
- struct req_amf_response *req_amf_response)
- {
- if (req_amf_response->error == SA_OK && conn_info->component) {
- log_printf (LOG_LEVEL_DEBUG, "CALLBACK sending readiness state to %s\n",
- getSaNameT (&conn_info->component->name));
- readinessStateSetCluster (conn_info->component,
- conn_info->component->newReadinessState);
- }
- }
- /*
- * iterate service unit components
- * telling all components not already QUIESCING to enter SA_AMF_QUIESCED state
- */
- static void response_handler_csisetcallback (struct conn_info *conn_info,
- struct req_amf_response *req_amf_response)
- {
- if (req_amf_response->error == SA_OK && conn_info->component) {
- haStateSetCluster (conn_info->component,
- conn_info->component->newHAState);
- }
- }
- int amfExecutiveInitialize (void)
- {
- return (0);
- }
- int amf_exit_fn (struct conn_info *conn_info)
- {
- /*
- * Unregister all components registered to this file descriptor
- */
- if (conn_info->service == SOCKET_SERVICE_AMF) {
- componentUnregister (conn_info->component);
- if (conn_info->component && conn_info->component->timer_healthcheck) {
- poll_timer_delete (aisexec_poll_handle,
- conn_info->component->timer_healthcheck);
- conn_info->component->timer_healthcheck = 0;
- }
- if (conn_info->ais_ci.u.libamf_ci.tracks) {
- mempool_free (conn_info->ais_ci.u.libamf_ci.tracks);
- conn_info->ais_ci.u.libamf_ci.tracks = 0;
- }
- }
- return (0);
- }
- static int message_handler_req_exec_amf_componentregister (void *message)
- {
- struct req_exec_amf_componentregister *req_exec_amf_componentregister = (struct req_exec_amf_componentregister *)message;
- struct res_lib_amf_componentregister res_lib_amf_componentregister;
- struct saAmfComponent *component;
- struct saAmfComponent *amfProxyComponent;
- SaErrorT error;
- log_printf (LOG_LEVEL_DEBUG, "Executive: ComponentRegister for component %s\n",
- getSaNameT (&req_exec_amf_componentregister->req_lib_amf_componentregister.compName));
- /*
- * Determine if proxy isn't registered
- */
- error = SA_OK;
- component = findComponent (&req_exec_amf_componentregister->req_lib_amf_componentregister.compName);
- amfProxyComponent = findComponent (&req_exec_amf_componentregister->req_lib_amf_componentregister.proxyCompName);
- /*
- * If component not in configuration files, return error
- */
- if (component == 0) {
- error = SA_ERR_NOT_EXIST;
- }
- /*
- * If proxy doesn't exist and isn't registered, return error
- */
- if ((amfProxyComponent == 0 &&
- req_exec_amf_componentregister->req_lib_amf_componentregister.proxyCompName.length > 0) ||
- (amfProxyComponent && amfProxyComponent->registered == 0)) {
- error = SA_ERR_NOT_EXIST;
- }
- /*
- * If component already registered, return error
- */
- if (error == SA_OK) {
- if (component->registered) {
- error = SA_ERR_EXIST;
- }
- }
- /*
- * Finally register component and setup links for proxy if
- * proxy present
- */
- if (error == SA_OK) {
- component->local = 0;
- component->registered = 1;
- component->conn_info = req_exec_amf_componentregister->source.conn_info;
- component->currentReadinessState = SA_AMF_OUT_OF_SERVICE;
- component->newReadinessState = SA_AMF_OUT_OF_SERVICE;
- component->currentHAState = SA_AMF_QUIESCED;
- component->newHAState = SA_AMF_QUIESCED;
- component->probableCause = 0;
- component->enabledUnlockedState = 0;
- component->disabledUnlockedState = 0;
- if (req_exec_amf_componentregister->req_lib_amf_componentregister.proxyCompName.length > 0) {
- component->saAmfProxyComponent = amfProxyComponent;
- }
- }
- /*
- * If this node originated the request to the cluster, respond back
- * to the AMF library
- */
- if (req_exec_amf_componentregister->source.in_addr.s_addr == this_ip.sin_addr.s_addr) {
- if (error == SA_OK) {
- component->local = 1;
- req_exec_amf_componentregister->source.conn_info->component = component;
- }
- log_printf (LOG_LEVEL_DEBUG, "sending component register response to fd %d\n", req_exec_amf_componentregister->source.conn_info);
- res_lib_amf_componentregister.header.magic = MESSAGE_MAGIC;
- res_lib_amf_componentregister.header.size = sizeof (struct res_lib_amf_componentregister);
- res_lib_amf_componentregister.header.id = MESSAGE_RES_AMF_COMPONENTREGISTER;
- res_lib_amf_componentregister.error = error;
- libais_send_response (req_exec_amf_componentregister->source.conn_info,
- &res_lib_amf_componentregister,
- sizeof (struct res_lib_amf_componentregister));
- }
-
- /*
- * If no error on registration, determine if we should enter new state
- */
- if (error == SA_OK) {
- dsm (component);
- }
- return (0);
- }
- static int message_handler_req_exec_amf_componentunregister (void *message)
- {
- struct req_exec_amf_componentunregister *req_exec_amf_componentunregister = (struct req_exec_amf_componentunregister *)message;
- struct res_lib_amf_componentunregister res_lib_amf_componentunregister;
- struct saAmfComponent *component;
- struct saAmfComponent *amfProxyComponent;
- SaErrorT error;
- log_printf (LOG_LEVEL_DEBUG, "Executive: ComponentUnregister for %s\n",
- getSaNameT (&req_exec_amf_componentunregister->req_lib_amf_componentunregister.compName));
- component = findComponent (&req_exec_amf_componentunregister->req_lib_amf_componentunregister.compName);
- amfProxyComponent = findComponent (&req_exec_amf_componentunregister->req_lib_amf_componentunregister.proxyCompName);
- /*
- * Check for proxy and component not existing in system
- */
- error = SA_OK;
- if (component == 0) {
- error = SA_ERR_NOT_EXIST;
- }
- if (req_exec_amf_componentunregister->req_lib_amf_componentunregister.proxyCompName.length > 0) {
- if (amfProxyComponent) {
- if (amfProxyComponent->registered == 0) {
- error = SA_ERR_NOT_EXIST;
- }
- } else {
- error = SA_ERR_NOT_EXIST;
- }
- }
- /*
- * If there is a proxycompname, make sure it is the proxy
- * of compName
- */
- if (error == SA_OK && amfProxyComponent) {
- if (component->saAmfProxyComponent != amfProxyComponent) {
- error = SA_ERR_BAD_OPERATION;
- }
- }
- /*
- * Finally unregister the component
- */
- if (error == SA_OK) {
- component->registered = 0;
- dsmEnabledUnlockedTransitionDisabledUnlocked (component);
- }
-
- /*
- * If this node originated the request to the cluster, respond back
- * to the AMF library
- */
- if (req_exec_amf_componentunregister->source.in_addr.s_addr == this_ip.sin_addr.s_addr) {
- log_printf (LOG_LEVEL_DEBUG, "sending component unregister response to fd %d\n",
- req_exec_amf_componentunregister->source.conn_info);
- res_lib_amf_componentunregister.header.magic = MESSAGE_MAGIC;
- res_lib_amf_componentunregister.header.size = sizeof (struct res_lib_amf_componentunregister);
- res_lib_amf_componentunregister.header.id = MESSAGE_RES_AMF_COMPONENTUNREGISTER;
- res_lib_amf_componentunregister.error = error;
- libais_send_response (req_exec_amf_componentunregister->source.conn_info,
- &res_lib_amf_componentunregister, sizeof (struct res_lib_amf_componentunregister));
- }
- return (0);
- }
- static int message_handler_req_exec_amf_errorreport (void *message)
- {
- struct req_exec_amf_errorreport *req_exec_amf_errorreport = (struct req_exec_amf_errorreport *)message;
- struct res_lib_amf_errorreport res_lib_amf_errorreport;
- struct saAmfComponent *component;
- SaErrorT error = SA_ERR_BAD_OPERATION;
- log_printf (LOG_LEVEL_DEBUG, "Executive: ErrorReport for %s\n",
- getSaNameT (&req_exec_amf_errorreport->req_lib_amf_errorreport.erroneousComponent));
- component = findComponent (&req_exec_amf_errorreport->req_lib_amf_errorreport.erroneousComponent);
- if (component && component->registered) {
- component->probableCause = req_exec_amf_errorreport->req_lib_amf_errorreport.errorDescriptor.probableCause;
- /*
- * One registered component left, so transition
- * SU to failed operational state
- */
- dsmEnabledUnlockedTransitionDisabledUnlocked (component);
- error = SA_OK;
- }
- /*
- * If this node originated the request to the cluster, respond back
- * to the AMF library
- */
- if (req_exec_amf_errorreport->source.in_addr.s_addr == this_ip.sin_addr.s_addr) {
- log_printf (LOG_LEVEL_DEBUG, "sending error report response to fd %d\n",
- req_exec_amf_errorreport->source.conn_info);
- res_lib_amf_errorreport.header.magic = MESSAGE_MAGIC;
- res_lib_amf_errorreport.header.size = sizeof (struct res_lib_amf_errorreport);
- res_lib_amf_errorreport.header.id = MESSAGE_RES_AMF_ERRORREPORT;
- res_lib_amf_errorreport.error = error;
- libais_send_response (req_exec_amf_errorreport->source.conn_info,
- &res_lib_amf_errorreport, sizeof (struct res_lib_amf_errorreport));
- }
- return (0);
- }
- static int message_handler_req_exec_amf_errorcancelall (void *message)
- {
- struct req_exec_amf_errorcancelall *req_exec_amf_errorcancelall = (struct req_exec_amf_errorcancelall *)message;
- struct res_lib_amf_errorcancelall res_lib_amf_errorcancelall;
- struct saAmfComponent *component;
- SaErrorT error = SA_ERR_BAD_OPERATION;
- log_printf (LOG_LEVEL_DEBUG, "Executive: ErrorCancelAll for %s\n",
- getSaNameT (&req_exec_amf_errorcancelall->req_lib_amf_errorcancelall.compName));
- component = findComponent (&req_exec_amf_errorcancelall->req_lib_amf_errorcancelall.compName);
- if (component && component->registered) {
- /*
- * Mark component in service if its a AMF service
- * connected to this aisexec
- */
- if (component->probableCause) {
- component->probableCause = 0;
- component->disabledUnlockedState = AMF_DISABLED_UNLOCKED_REGISTEREDORERRORCANCEL;
- dsm (component);
- }
- error = SA_OK;
- }
-
- /*
- * If this node originated the request to the cluster, respond back
- * to the AMF library
- */
- if (req_exec_amf_errorcancelall->source.in_addr.s_addr == this_ip.sin_addr.s_addr) {
- log_printf (LOG_LEVEL_DEBUG, "sending error report response to fd %d\n",
- req_exec_amf_errorcancelall->source.conn_info);
- res_lib_amf_errorcancelall.header.magic = MESSAGE_MAGIC;
- res_lib_amf_errorcancelall.header.size = sizeof (struct res_lib_amf_errorcancelall);
- res_lib_amf_errorcancelall.header.id = MESSAGE_RES_AMF_ERRORCANCELALL;
- res_lib_amf_errorcancelall.error = error;
- libais_send_response (req_exec_amf_errorcancelall->source.conn_info,
- &res_lib_amf_errorcancelall, sizeof (struct res_lib_amf_errorcancelall));
- }
- return (0);
- }
- /*
- * If receiving this message from another cluster node, another cluster node
- * has selected a readiness state for a component connected to _that_ cluster
- * node. That cluster node API has verified the readiness state, so its time to let
- * the rest of the cluster nodes know about the readiness state change.
- */
- static int message_handler_req_exec_amf_readinessstateset (void *message)
- {
- struct req_exec_amf_readinessstateset *req_exec_amf_readinessstateset = (struct req_exec_amf_readinessstateset *)message;
- struct saAmfComponent *component;
- component = findComponent (&req_exec_amf_readinessstateset->compName);
- if (component) {
- log_printf (LOG_LEVEL_DEBUG, "found component %s, setting current readiness state to %d\n",
- getSaNameT (&component->name),
- req_exec_amf_readinessstateset->readinessState);
- component->currentReadinessState = req_exec_amf_readinessstateset->readinessState;
- dsm (component);
- }
-
- return (0);
- }
- /*
- * If receiving this message from another cluster node, another cluster node
- * has selected a ha state for a component connected to _that_ cluster
- * node. That cluster node API has verified the ha state, so its time to let
- * the rest of the cluster nodes know about the HA state change.
- */
- static int message_handler_req_exec_amf_hastateset (void *message)
- {
- struct req_exec_amf_hastateset *req_exec_amf_hastateset = (struct req_exec_amf_hastateset *)message;
- struct saAmfComponent *component;
- component = findComponent (&req_exec_amf_hastateset->compName);
- if (component) {
- log_printf (LOG_LEVEL_DEBUG, "found component %s, setting current HA state to %d\n",
- getSaNameT (&component->name),
- req_exec_amf_hastateset->haState);
- component->currentHAState = req_exec_amf_hastateset->haState;
- dsm (component);
- }
-
- return (0);
- }
- static int message_handler_req_amf_init (struct conn_info *conn_info, void *message)
- {
- struct res_lib_init res_lib_init;
- SaErrorT error = SA_ERR_SECURITY;
- log_printf (LOG_LEVEL_DEBUG, "Got AMF request to initalize availability management framework service.\n");
- if (conn_info->authenticated) {
- conn_info->service = SOCKET_SERVICE_AMF;
- error = SA_OK;
- }
- res_lib_init.header.magic = MESSAGE_MAGIC;
- res_lib_init.header.size = sizeof (struct res_lib_init);
- res_lib_init.header.id = MESSAGE_RES_INIT;
- res_lib_init.error = error;
- libais_send_response (conn_info, &res_lib_init, sizeof (res_lib_init));
- if (conn_info->authenticated) {
- return (0);
- }
- return (-1);
- }
- static int message_handler_req_lib_activatepoll (int conn_info, void *message)
- {
- struct res_lib_activatepoll res_lib_activatepoll;
- res_lib_activatepoll.header.magic = MESSAGE_MAGIC;
- res_lib_activatepoll.header.size = sizeof (struct res_lib_activatepoll);
- res_lib_activatepoll.header.id = MESSAGE_RES_LIB_ACTIVATEPOLL;
- libais_send_response (conn_info, &res_lib_activatepoll, sizeof (struct res_lib_activatepoll));
- return (0);
- }
- static int message_handler_req_amf_componentregister (int conn_info, void *message)
- {
- struct req_amf_componentregister *req_lib_amf_componentregister = (struct req_amf_componentregister *)message;
- struct req_exec_amf_componentregister req_exec_amf_componentregister;
- struct iovec iovecs[2];
- int result;
- req_exec_amf_componentregister.header.magic = MESSAGE_MAGIC;
- req_exec_amf_componentregister.header.size = sizeof (struct req_exec_amf_componentregister);
- req_exec_amf_componentregister.header.id = MESSAGE_REQ_EXEC_AMF_COMPONENTREGISTER;
- req_exec_amf_componentregister.source.conn_info = conn_info;
- req_exec_amf_componentregister.source.in_addr.s_addr = this_ip.sin_addr.s_addr;
- memcpy (&req_exec_amf_componentregister.req_lib_amf_componentregister,
- req_lib_amf_componentregister,
- sizeof (struct req_lib_amf_componentregister));
- iovecs[0].iov_base = &req_exec_amf_componentregister;
- iovecs[0].iov_len = sizeof (req_exec_amf_componentregister);
- result = gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_MED);
- return (0);
- }
- static int message_handler_req_amf_componentunregister (struct conn_info *conn_info, void *message)
- {
- struct req_lib_amf_componentunregister *req_lib_amf_componentunregister = (struct req_lib_amf_componentunregister *)message;
- struct req_exec_amf_componentunregister req_exec_amf_componentunregister;
- struct iovec iovecs[2];
- int result;
- struct saAmfComponent *component;
- req_exec_amf_componentunregister.header.magic = MESSAGE_MAGIC;
- req_exec_amf_componentunregister.header.size = sizeof (struct req_exec_amf_componentunregister);
- req_exec_amf_componentunregister.header.id = MESSAGE_REQ_EXEC_AMF_COMPONENTUNREGISTER;
- req_exec_amf_componentunregister.source.conn_info = conn_info;
- req_exec_amf_componentunregister.source.in_addr.s_addr = this_ip.sin_addr.s_addr;
- memcpy (&req_exec_amf_componentunregister.req_lib_amf_componentunregister,
- req_lib_amf_componentunregister,
- sizeof (struct req_lib_amf_componentunregister));
- component = findComponent (&req_lib_amf_componentunregister->compName);
- if (component && component->registered && component->local) {
- component->probableCause = SA_AMF_NOT_RESPONDING;
- }
- iovecs[0].iov_base = &req_exec_amf_componentunregister;
- iovecs[0].iov_len = sizeof (req_exec_amf_componentunregister);
- result = gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_MED);
- return (0);
- }
- static int message_handler_req_amf_readinessstateget (struct conn_info *conn_info, void *message)
- {
- struct req_amf_readinessstateget *req_amf_readinessstateget = (struct req_amf_readinessstateget *)message;
- struct res_amf_readinessstateget res_amf_readinessstateget;
- struct saAmfComponent *component;
- log_printf (LOG_LEVEL_DEBUG, "got request to return readiness state\n");
- res_amf_readinessstateget.header.magic = MESSAGE_MAGIC;
- res_amf_readinessstateget.header.id = MESSAGE_RES_AMF_READINESSSTATEGET;
- res_amf_readinessstateget.header.size = sizeof (struct res_amf_readinessstateget);
- res_amf_readinessstateget.error = SA_ERR_NOT_EXIST;
- component = findComponent (&req_amf_readinessstateget->compName);
- log_printf (LOG_LEVEL_DEBUG, "readinessstateget: found component %p\n", component);
- if (component) {
- memcpy (&res_amf_readinessstateget.readinessState,
- &component->currentReadinessState, sizeof (SaAmfReadinessStateT));
- res_amf_readinessstateget.error = SA_OK;
- }
- libais_send_response (conn_info, &res_amf_readinessstateget, sizeof (struct res_amf_readinessstateget));
- return (0);
- }
- static int message_handler_req_amf_hastateget (struct conn_info *conn_info, void *message)
- {
- struct req_amf_hastateget *req_amf_hastateget = (struct req_amf_hastateget *)message;
- struct res_amf_hastateget res_amf_hastateget;
- struct saAmfComponent *component;
- res_amf_hastateget.header.magic = MESSAGE_MAGIC;
- res_amf_hastateget.header.id = MESSAGE_RES_AMF_HASTATEGET;
- res_amf_hastateget.header.size = sizeof (struct res_amf_hastateget);
- res_amf_hastateget.error = SA_ERR_NOT_EXIST;
- component = findComponentInProtectionGroup (&req_amf_hastateget->csiName, &req_amf_hastateget->compName);
- if (component) {
- memcpy (&res_amf_hastateget.haState,
- &component->currentHAState, sizeof (SaAmfHAStateT));
- res_amf_hastateget.error = SA_OK;
- }
- libais_send_response (conn_info, &res_amf_hastateget, sizeof (struct res_amf_hastateget));
- return (0);
- }
- static int message_handler_req_amf_protectiongrouptrackstart (struct conn_info *conn_info, void *message)
- {
- struct req_amf_protectiongrouptrackstart *req_amf_protectiongrouptrackstart = (struct req_amf_protectiongrouptrackstart *)message;
- struct res_amf_protectiongrouptrackstart res_amf_protectiongrouptrackstart;
- struct libamf_ci_trackentry *track = 0;
- int i;
- struct saAmfProtectionGroup *amfProtectionGroup;
- amfProtectionGroup = findProtectionGroup (&req_amf_protectiongrouptrackstart->csiName);
- if (amfProtectionGroup) {
- log_printf (LOG_LEVEL_DEBUG, "protectiongrouptrackstart: Got valid track start on CSI: %s.\n", getSaNameT (&req_amf_protectiongrouptrackstart->csiName));
- for (i = 0; i < conn_info->ais_ci.u.libamf_ci.trackEntries; i++) {
- if (conn_info->ais_ci.u.libamf_ci.tracks[i].active == 0) {
- track = &conn_info->ais_ci.u.libamf_ci.tracks[i];
- break;
- }
- }
- if (track == 0) {
- grow_amf_track_table (conn_info, 1);
- track = &conn_info->ais_ci.u.libamf_ci.tracks[i];
- }
- track->active = 1;
- track->trackFlags = req_amf_protectiongrouptrackstart->trackFlags;
- track->notificationBufferAddress = req_amf_protectiongrouptrackstart->notificationBufferAddress;
- memcpy (&track->csiName,
- &req_amf_protectiongrouptrackstart->csiName, sizeof (SaNameT));
- conn_info->ais_ci.u.libamf_ci.trackActive += 1;
- list_add (&conn_info->conn_list, &library_notification_send_listhead);
-
- /*
- * If SA_TRACK_CURRENT is specified, write out all current connections
- */
- } else {
- log_printf (LOG_LEVEL_DEBUG, "invalid track start, csi not registered with system.\n");
- }
- res_amf_protectiongrouptrackstart.header.magic = MESSAGE_MAGIC;
- res_amf_protectiongrouptrackstart.header.id = MESSAGE_RES_AMF_PROTECTIONGROUPTRACKSTART;
- res_amf_protectiongrouptrackstart.header.size = sizeof (struct res_amf_protectiongrouptrackstart);
- res_amf_protectiongrouptrackstart.error = SA_ERR_NOT_EXIST;
- if (amfProtectionGroup) {
- res_amf_protectiongrouptrackstart.error = SA_OK;
- }
- libais_send_response (conn_info, &res_amf_protectiongrouptrackstart,
- sizeof (struct res_amf_protectiongrouptrackstart));
- if (amfProtectionGroup &&
- req_amf_protectiongrouptrackstart->trackFlags & SA_TRACK_CURRENT) {
- sendProtectionGroupNotification (conn_info,
- track->notificationBufferAddress,
- amfProtectionGroup,
- 0,
- 0,
- track->trackFlags);
- track->trackFlags &= ~SA_TRACK_CURRENT;
- }
- return (0);
- }
- static int message_handler_req_amf_protectiongrouptrackstop (struct conn_info *conn_info, void *message)
- {
- struct req_amf_protectiongrouptrackstop *req_amf_protectiongrouptrackstop = (struct req_amf_protectiongrouptrackstop *)message;
- struct res_amf_protectiongrouptrackstop res_amf_protectiongrouptrackstop;
- struct libamf_ci_trackentry *track = 0;
- int i;
- for (i = 0; i < conn_info->ais_ci.u.libamf_ci.trackEntries; i++) {
- if (SaNameTisNameT (&req_amf_protectiongrouptrackstop->csiName,
- &conn_info->ais_ci.u.libamf_ci.tracks[i].csiName)) {
- track = &conn_info->ais_ci.u.libamf_ci.tracks[i];
- }
- }
- if (track) {
- log_printf (LOG_LEVEL_DEBUG, "protectiongrouptrackstop: Trackstop on CSI: %s\n", getSaNameT (&req_amf_protectiongrouptrackstop->csiName));
- memset (track, 0, sizeof (struct libamf_ci_trackentry));
- conn_info->ais_ci.u.libamf_ci.trackActive -= 1;
- if (conn_info->ais_ci.u.libamf_ci.trackActive == 0) {
- list_del (&conn_info->conn_list);
- }
- }
- res_amf_protectiongrouptrackstop.header.magic = MESSAGE_MAGIC;
- res_amf_protectiongrouptrackstop.header.id = MESSAGE_RES_AMF_PROTECTIONGROUPTRACKSTOP;
- res_amf_protectiongrouptrackstop.header.size = sizeof (struct res_amf_protectiongrouptrackstop);
- res_amf_protectiongrouptrackstop.error = SA_ERR_NOT_EXIST;
- if (track) {
- res_amf_protectiongrouptrackstop.error = SA_OK;
- }
- libais_send_response (conn_info, &res_amf_protectiongrouptrackstop,
- sizeof (struct res_amf_protectiongrouptrackstop));
- return (0);
- }
- static int message_handler_req_amf_errorreport (struct conn_info *conn_info, void *message)
- {
- struct req_lib_amf_errorreport *req_lib_amf_errorreport = (struct req_lib_amf_errorreport *)message;
- struct req_exec_amf_errorreport req_exec_amf_errorreport;
- struct iovec iovecs[2];
- int result;
- req_exec_amf_errorreport.header.magic = MESSAGE_MAGIC;
- req_exec_amf_errorreport.header.size = sizeof (struct req_exec_amf_errorreport);
- req_exec_amf_errorreport.header.id = MESSAGE_REQ_EXEC_AMF_ERRORREPORT;
- req_exec_amf_errorreport.source.conn_info = conn_info;
- req_exec_amf_errorreport.source.in_addr.s_addr = this_ip.sin_addr.s_addr;
- memcpy (&req_exec_amf_errorreport.req_lib_amf_errorreport,
- req_lib_amf_errorreport,
- sizeof (struct req_lib_amf_errorreport));
- iovecs[0].iov_base = &req_exec_amf_errorreport;
- iovecs[0].iov_len = sizeof (req_exec_amf_errorreport);
- // iovecs[0].iov_len = sizeof (req_exec_amf_errorreport) - sizeof (req_lib_amf_errorreport);
- // iovecs[1].iov_base = &req_lib_amf_errorreport;
- // iovecs[1].iov_len = sizeof (req_lib_amf_errorreport);
- result = gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_MED);
- return (0);
- }
- static int message_handler_req_amf_errorcancelall (struct conn_info *conn_info, void *message)
- {
- struct req_lib_amf_errorcancelall *req_lib_amf_errorcancelall = (struct req_lib_amf_errorcancelall *)message;
- struct req_exec_amf_errorcancelall req_exec_amf_errorcancelall;
- struct iovec iovecs[2];
- int result;
- req_exec_amf_errorcancelall.header.magic = MESSAGE_MAGIC;
- req_exec_amf_errorcancelall.header.size = sizeof (struct req_exec_amf_errorcancelall);
- req_exec_amf_errorcancelall.header.id = MESSAGE_REQ_EXEC_AMF_ERRORCANCELALL;
- req_exec_amf_errorcancelall.source.conn_info = conn_info;
- req_exec_amf_errorcancelall.source.in_addr.s_addr = this_ip.sin_addr.s_addr;
- memcpy (&req_exec_amf_errorcancelall.req_lib_amf_errorcancelall,
- req_lib_amf_errorcancelall,
- sizeof (struct req_lib_amf_errorcancelall));
- iovecs[0].iov_base = &req_exec_amf_errorcancelall;
- iovecs[0].iov_len = sizeof (req_exec_amf_errorcancelall);
- // iovecs[0].iov_len = sizeof (req_exec_amf_errorcancelall) - sizeof (req_lib_amf_errorcancelall);
- // iovecs[1].iov_base = &req_lib_amf_errorcancelall;
- // iovecs[1].iov_len = sizeof (req_lib_amf_errorcancelall);
- result = gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_MED);
- return (0);
- }
- static int message_handler_req_amf_stoppingcomplete (struct conn_info *conn_info_notused,
- void *message)
- {
- struct req_amf_stoppingcomplete *req_amf_stoppingcomplete = (struct req_amf_stoppingcomplete *)message;
- struct conn_info *inv_conn_info;
- int interface;
- log_printf (LOG_LEVEL_DEBUG, "handling stopping complete\n");
- req_amf_invocation_get_and_destroy (req_amf_stoppingcomplete->invocation,
- &interface, &inv_conn_info);
- inv_conn_info->component->currentReadinessState = inv_conn_info->component->newReadinessState;
- readinessStateSetCluster (inv_conn_info->component, SA_AMF_STOPPING);
- sendProtectionGroupNotifications (inv_conn_info->component,
- SA_AMF_PROTECTION_GROUP_STATE_CHANGE);
- return (0);
- }
- void response_handler_healthcheckcallback (struct conn_info *conn_info,
- struct req_amf_response *req_amf_response) {
- if (req_amf_response->error == SA_OK) {
- log_printf (LOG_LEVEL_DEBUG, "setting healthcheck ok\n");
- conn_info->component->healthcheck_outstanding = 0;
- }
- }
- static int message_handler_req_amf_response (struct conn_info *conn_info_nouse, void *message)
- {
- struct req_amf_response *req_amf_response = (struct req_amf_response *)message;
- struct conn_info *conn_info;
- int interface;
- int res;
- res = req_amf_invocation_get_and_destroy (req_amf_response->invocation,
- &interface, &conn_info);
- log_printf (LOG_LEVEL_DEBUG, "handling response connection %x interface %x\n", conn_info, interface);
- switch (interface) {
- case MESSAGE_REQ_AMF_RESPONSE_SAAMFHEALTHCHECKCALLBACK:
- response_handler_healthcheckcallback (conn_info, req_amf_response);
- break;
- case MESSAGE_REQ_AMF_RESPONSE_SAAMFREADINESSSTATESETCALLBACK:
- response_handler_readinessstatesetcallback (conn_info, req_amf_response);
- break;
- case MESSAGE_REQ_AMF_RESPONSE_SAAMFCSISETCALLBACK:
- response_handler_csisetcallback (conn_info, req_amf_response);
- break;
- case MESSAGE_REQ_AMF_RESPONSE_SAAMFCSIREMOVECALLBACK:
- break;
- default:
- // TODO
- log_printf (LOG_LEVEL_ERROR, "invalid invocation value %x\n", req_amf_response->invocation);
- break;
- }
- return (0);
- }
- static int message_handler_req_amf_componentcapabilitymodelget (struct conn_info *conn_info, void *message)
- {
- struct req_amf_componentcapabilitymodelget *req_amf_componentcapabilitymodelget = (struct req_amf_componentcapabilitymodelget *)message;
- struct res_amf_componentcapabilitymodelget res_amf_componentcapabilitymodelget;
- struct saAmfComponent *component;
- SaErrorT error = SA_OK;
- log_printf (LOG_LEVEL_DEBUG, "componentcapabilitymodelget: Retrieve name %s.\n", getSaNameT (&req_amf_componentcapabilitymodelget->compName));
- component = findComponent (&req_amf_componentcapabilitymodelget->compName);
- if (component && component->registered) {
- memcpy (&res_amf_componentcapabilitymodelget.componentCapabilityModel,
- &component->componentCapabilityModel, sizeof (SaAmfComponentCapabilityModelT));
- } else {
- error = SA_ERR_NOT_EXIST;
- }
- res_amf_componentcapabilitymodelget.header.magic = MESSAGE_MAGIC;
- res_amf_componentcapabilitymodelget.header.size = sizeof (struct res_amf_componentcapabilitymodelget);
- res_amf_componentcapabilitymodelget.header.id = MESSAGE_RES_AMF_COMPONENTCAPABILITYMODELGET;
- res_amf_componentcapabilitymodelget.error = error;
- libais_send_response (conn_info, &res_amf_componentcapabilitymodelget,
- sizeof (struct res_amf_componentcapabilitymodelget));
- return (0);
- }
|