/* Callback for circuit changes */ void callbackCircuitChange(circuitView *cp){ char s[MAX_LEN_ADDRESS_AS_STR]; printf("!!! ******** callbackCircuitChange called with %d members (process ", cp->cv_nmemb); if (!addrIsNull(cp->cv_joined)) { printf("%s has arrived)\n", addrToStr(s, cp->cv_joined)); } else { printf("%s is gone)\n", addrToStr(s, cp->cv_departed)); if (!measurementDone) { printf("!!! ******** Experience has failed ******** !!!\n"); exit(EXIT_FAILURE); } } if (cp->cv_nmemb >= number) { // We compute the rank of the process in the group for (rank = 0; (rank < cp->cv_nmemb) && !addrIsMine(cp->cv_members[rank]); rank++) ; // We can start the experience printf("!!! ******** enough members to start oBroadcasting\n"); int rc = sem_post(&semWaitEnoughMembers); if (rc) ERROR_AT_LINE(EXIT_FAILURE, errno, __FILE__, __LINE__, "sem_post()"); } }
void callbackCircuitChange(circuitView *cp){ char s[MAX_LEN_ADDRESS_AS_STR]; printf("!!! ******** callbackCircuitChange called with %d members (process ", cp->cv_nmemb); if (!addrIsNull(cp->cv_joined)) { printf("%s has arrived)\n", addrToStr(s, cp->cv_joined)); } else { printf("%s is gone)\n", addrToStr(s, cp->cv_departed)); } }
static void logSFlowSettings(HSPSFlow *sFlow) { HSPSFlowSettings *settings = sFlow->sFlowSettings; char agentAddr[255]; addrToStr(&sFlow->agentIP, agentAddr, 255); myLog(debug, "sFlow configuration agent=%s serialNumber=%u: pollingInterval=%u, samplingRate=%u", agentAddr, settings->serialNumber, settings->pollingInterval, settings->samplingRate); for (HSPCollector *collector= settings->collectors; collector; collector = collector->nxt) { myLog(debug, "collector=%s:%u", collector->name, collector->udpPort); } }
/* Callback for messages to be O-delivered */ void callbackODeliver(address sender, t_typ messageTyp, message *mp){ char s[MAX_LEN_ADDRESS_AS_STR]; static int nbRecMsg = 0; if (payloadSize(mp) != size) { fprintf(stderr, "Error in file %s:%d : Payload size is incorrect: it is %zu when it should be %d\n", __FILE__, __LINE__, payloadSize(mp), size); exit(EXIT_FAILURE); } nbRecMsg++; if (verbose) printf("!!! %5d-ieme message (recu de %s / contenu = %5d)\n", nbRecMsg, addrToStr(s, sender), *((int*) (mp->payload))); }
int main() { addressSet arrivedSet; addressSet goneSet; compare("addrIsNull", addrIsNull(nullAddress), true); compare("addrIsNull", addrIsNull(myAddress), false); compare("addrCmp", addrCmp(nullAddress,myAddress), true); compare("addrCmp", addrCmp(myAddress,nullAddress), false); compare("addrIsEqual", addrIsEqual(nullAddress,nullAddress), true); compare("addrIsEqual", addrIsEqual(myAddress,nullAddress), false); compare("addrIsMine", addrIsMine(myAddress), true); compare("addrIsMine", addrIsMine(nullAddress), false); printf("Testing %s...", "addr_2_str"); addrToStr(s,myAddress); if (strcmp(s, "#00") != 0){ printf("... KO (s is \"%s\" instead of \"%s\")\n", s, "#00"); exit(EXIT_FAILURE); } printf("...OK\n"); compare("addrToRank", addrToRank(myAddress), 0); compare("addrToRank", addrToRank(0x8000), 15); compare("addrToRank", addrToRank(nullAddress), -1); compare("rankToAddr", rankToAddr(0), myAddress); compare("rankToAddr", rankToAddr(15), 0x8000); compare("rankToAddr", rankToAddr(16), nullAddress); compare("addrIsMember", addrIsMember(myAddress, 0xFFFF), true); compare("addrIsMember", addrIsMember(myAddress, 0xFFFE), false); arrivedSet = 0xFFFE; addrAppendArrived(&arrivedSet, myAddress); compare("addrAppendArrived", arrivedSet, 0xFFFF); arrivedSet = 0x0000; addrAppendArrived(&arrivedSet, myAddress); compare("addrAppendArrived", arrivedSet, 0x0001); arrivedSet = 0x0000; goneSet = 0xFFFE; addrAppendGone(&arrivedSet, &goneSet, myAddress); printf("Testing %s...", "addr_appendGone"); if ((arrivedSet != 0x0000) || (goneSet != 0xFFFF)){ printf("... KO (arrivedSet is \"%d\" instead of \"%d\" OR goneSet is \"%d\" instead of \"%d\")\n", arrivedSet, 0x0000, goneSet, 0xFFFF); exit(EXIT_FAILURE); } printf("...OK\n"); arrivedSet = 0xFFFF; goneSet = 0x0000; addrAppendGone(&arrivedSet, &goneSet, myAddress); printf("Testing %s...", "addr_appendGone"); if ((arrivedSet != 0xFFFE) || (goneSet != 0x0000)){ printf("... KO (arrivedSet is \"%d\" instead of \"%d\" OR goneSet is \"%d\" instead of \"%d\")\n", arrivedSet, 0xFFFF, goneSet, 0x0000); exit(EXIT_FAILURE); } printf("...OK\n"); compare("addrUpdateCircuit", addrUpdateCircuit(0xFFFF, myAddress, 0xFF00, 0x00FF), 0xFF00); compare("addrPrec", addrPrec(0x8000, 0x8000|0x0001), 0x0001); compare("addrPrec", addrPrec(0x0001, 0x8000|0x0001), 0x8000); return EXIT_SUCCESS; }