//----------------------------------------------------------------------------- static char *get_str(char **line) { char *res, *start, *end; int len; skip_spaces(line); start = end = *line; while (0 != end[0] && ' ' != end[0] && '\t' != end[0]) end++; len = end-start; if (0 == len) error("%s:%d:%d: string expected", config_name, config_line, config_col); skip_bytes(line, len); res = (char *)sim_malloc(len+1); memcpy(res, start, len); res[len] = 0; return res; }
/* * Création d'une entité DVB-S2 couche 2. Attention, elle ne contient * aucun MODCOD par défaut, il faut en ajouter. * * Le débit est donnée en symboles/seconde */ struct DVBS2ll_t * DVBS2ll_create(void * destination, processPDU_t destProcessPDU, unsigned long symbolPerSecond, unsigned int FECFrameBitLength) { struct DVBS2ll_t * result = (struct DVBS2ll_t * )sim_malloc(sizeof(struct DVBS2ll_t)); if (result) { result->nbModCods = 0; result->destination = destination; result->send = destProcessPDU; result->symbolPerSecond = symbolPerSecond; result->FECFrameBitLength = FECFrameBitLength; result->source = NULL; result->getPDU = NULL; result->dummyFecFrameProbe = NULL; result->available = 1; // Ajout à la liste des choses à réinitialiser avant une prochaine simu motsim_addToResetList(result, (void (*)(void *))DVBS2ll_reset); printf_debug(DEBUG_DVB, "%p created\n", result); } return result; };
struct PDUSource_t * PDUSource_create(struct dateGenerator_t * dateGen, void * destination, processPDU_t destProcessPDU) { struct PDUSource_t * result = (struct PDUSource_t *) sim_malloc(sizeof(struct PDUSource_t)); ndesObjectInit(result, PDUSource); result->pdu = NULL; result->nextPdu = NULL; PDUSource_setDateGenerator(result, dateGen); result->destProcessPDU = destProcessPDU; result->destination = destination; result->sizeGen = NULL; result->PDUGenerationSizeProbe = NULL; // Pour les sources déterministes (à refaire un jour) result->sequence = NULL; result->detNextIdx = 0; // Ajout à la liste des choses à réinitialiser avant une prochaine simu motsim_addToResetList(result, (void (*)(void *))PDUSource_start); return result; }
/* * Creation et initialisation d'un serveur */ struct srvGen_t * srvGen_create(void * destination, processPDU_t destProcessPDU) { struct srvGen_t * result = sim_malloc(sizeof(struct srvGen_t)); ndesObjectInit(result, srvGen); result->srvState = srvStateIdle; result->currentPDU = NULL; // La destination des PDU servies result->destination = destination; result->destProcessPDU = destProcessPDU; // Le mode de calcul du temps de traitement (par défaut débit unitaire) result->dateGenerator = NULL; result->serviceTime = serviceTimeProp; result->serviceTimeParameter = 1.0; // WARNING A modifier (cf struct) result->source = NULL; result->serviceProbe = NULL; return result; }
int sim_sock_socket (int domain, int type, int protocol, struct SimSocket **socket) { struct socket **kernel_socket = (struct socket **)socket; int retval = sock_create (domain, type, protocol, kernel_socket); /* XXX: SCTP code never look at flags args, but file flags instead. */ struct file *fp = sim_malloc (sizeof (struct file)); (*kernel_socket)->file = fp; return retval; }
static struct iovec *copy_iovec (const struct iovec *input, int len) { int size = sizeof (struct iovec) * len; struct iovec *output = sim_malloc (size); if (!output) return NULL; sim_memcpy (output, input, size); return output; }
/* * A la fin d'une simulation, certains objets ont besoin d'être * réinitialiser (pour remettre des compteurs à 0 par exemple). Ces * objets doivent s'enregistrer auprès du simulateur par la fonction * suivante */ void motsim_addToResetList(void * data, void (*resetFunc)(void * data)) { struct resetClient_t * resetClient = (struct resetClient_t *)sim_malloc(sizeof(struct resetClient_t)); assert (resetClient); resetClient->next = __motSim->resetClient; resetClient->data = data; resetClient->resetFunc = resetFunc; __motSim->resetClient = resetClient; }
/* * Création d'une instance du simulateur au sein de laquelle on pourra * lancer plusieurs simulations consécutives */ void motSim_create() { struct sigaction act; __motSim = (struct motsim_t * )sim_malloc(sizeof(struct motsim_t)); __motSim->currentTime = 0.0; printf_debug(DEBUG_MOTSIM, "Initialisation du simulateur ...\n"); __motSim->events = eventList_create(); __motSim->nbInsertedEvents = 0; __motSim->nbRanEvents = 0; __motSim->resetClient = NULL; printf_debug(DEBUG_MOTSIM, "gestion des signaux \n"); // We want to close files on exit, even with ^c bzero(&act, sizeof(struct sigaction)); act.sa_handler = mainHandler; act.sa_flags = SA_NOCLDWAIT; sigaction(SIGHUP, &act,NULL); sigaction(SIGINT, &act,NULL); sigaction(SIGQUIT, &act,NULL); sigaction(SIGCHLD, &act,NULL); // For periodic ping act.sa_handler = periodicHandler; sigaction(SIGALRM, &act,NULL); printf_debug(DEBUG_MOTSIM, "creation des sondes systeme\n"); // Calcul de la durée moyenne des simulations __motSim->dureeSimulation = probe_createExhaustive(); probe_setPersistent(__motSim->dureeSimulation); // Les sondes systeme PDU_createProbe = probe_createMean(); probe_setName(PDU_createProbe, "created PDUs"); PDU_reuseProbe = probe_createMean(); probe_setName(PDU_reuseProbe, "reused PDUs"); PDU_mallocProbe = probe_createMean(); probe_setName(PDU_mallocProbe, "mallocd PDUs"); PDU_releaseProbe = probe_createMean(); probe_setName(PDU_releaseProbe, "released PDUs"); // Intialisation des log printf_debug(DEBUG_MOTSIM, "Initialisation des log ...\n"); ndesLog_init(); printf_debug(DEBUG_MOTSIM, "Simulateur pret ...\n"); }
/** * @brief Création d'un scheduler avec sa "destination". * Cette dernière doit * être de type struct DVBS2ll_t et avoir déjà * été complêtement construite (tous les MODCODS créés). Le nombre de * files de QoS différentes par MODCOD est également passé en * paramètre. */ struct schedACM_t * schedACMBatch_create(struct DVBS2ll_t * dvbs2ll, int nbQoS, int declOK, int seqLgMax, int mode) { struct schedACMBatch_t * result = (struct schedACMBatch_t * ) sim_malloc(sizeof(struct schedACMBatch_t)); assert(result); assert(declOK == 0); result->schedACM = schedACM_create(dvbs2ll, nbQoS, declOK, &schedACMBatch_func); result->mode = mode; schedACM_setPrivate(result->schedACM, result); schedACM_setSeqLgMax(result->schedACM, seqLgMax); printf_debug(DEBUG_SCHED, "%p created (in schedACM %p)\n", result, result->schedACM); return result->schedACM; }
/** * @brief Creation/initialization of a source * @param MTU is the maximum transmission unit of the link * @param RTTmd is the Round Trip Time minus transmission time on the access link * @param initialWindow is the initial value of cwnd * @param destination is a pointer to the destination entity * @param destProcessPDU is the PDU processing function of the destination */ struct srcTCPSS_t * srcTCPss_create(int MTU, double RTTmd, int initialWindow, void * destination, processPDU_t destProcessPDU) { struct srcTCPSS_t * result = (struct srcTCPSS_t *) sim_malloc(sizeof(struct srcTCPSS_t )); result->windowSize = initialWindow; result->MSS = MTU - TCP_BASE_HEADER_SIZE ; result->RTT = RTTmd; result->backlog = 0; result->nbSentSegments = 0; result->destination = destination; result->destProcessPDU = destProcessPDU; result->outputQueue = filePDU_create(NULL, NULL); result->EOTEventList = eventList_create(); return result; }
/** * @brief Création et initialisation d'un ordonnanceur * @param dvbs2ll le lien sur lequel sont transmises les trames * @param nbQoS le nombre de files de qualité de service * @param declOK autorise-t-on le déclassement ? * @param exhaustif faut-il utiliser un algorithme exhaustif ? * * Création d'un scheduler avec sa "destination". Cette dernière doit * être de type struct DVBS2ll_t et avoir déjà été complêtement * construite (tous les MODCODS créés). * Le nombre de files de QoS différentes par MODCOD est également * passé en paramètre. */ struct schedACM_t * sched_kse_create(struct DVBS2ll_t * dvbs2ll, int nbQoS, int declOK, int exhaustif) { struct sched_kse_t * result = (struct sched_kse_t * ) sim_malloc(sizeof(struct sched_kse_t)); assert(result); result->schedACM = schedACM_create(dvbs2ll, nbQoS, declOK, &schedKS_func); schedACM_setPrivate(result->schedACM, result); // On initialise le tableau de l'algo tabRemplissage_init(result->remplissage, NB_SOUS_CAS_MAX, DVBS2ll_nbModcod(dvbs2ll), nbQoS); printf_debug(DEBUG_KS, "%p created (in schedACM %p)\n", result, result->schedACM); result->rechercheExhaustive = exhaustif; return result->schedACM; }
struct event_t * event_create(void (*run)(void *data), void * data) { struct event_t * result; #ifndef EVENTS_ARE_NDES_OBJECTS # ifdef EVENT_REUSE if (freeEvent) { result = freeEvent; freeEvent = result->next; event_nbReuse++; } else # endif #endif { result = (struct event_t *)sim_malloc(sizeof(struct event_t)); event_nbMalloc ++; } assert(result); event_nbCreate ++; result->type = 0; result->period = 0.0; result->run = run; result->data = data; result->date = 0.0; #ifdef EVENTS_ARE_NDES_OBJECTS ndesObjectInit(result, event); #else result->prev = NULL; result->next = NULL; #endif return result; }
int sysfs_create_dir_ns(struct kobject *kobj, const void *ns) { kobj->sd = sim_malloc (sizeof (struct kernfs_node)); return 0; }