⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 alc_session.c

📁 这个程序实现了FLUTE协议
💻 C
📖 第 1 页 / 共 2 页
字号:
#ifdef WIN32ULONGLONG get_object_sent_bytes(int s_id) {#elseunsigned long long get_object_sent_bytes(int s_id) {#endif  return alc_session_list[s_id]->obj_sent_bytes;}/* * This function sets number of bytes sent in session. * * Params:	int s_id: Session identifier, *			unsigned int sent_bytes: Bytes sent * * Return:	void * */                                                                                                                                       void set_session_sent_bytes(int s_id,#ifdef WIN32			    ULONGLONG sent_bytes#else			    unsigned long long sent_bytes#endif			    ) {    alc_session_list[s_id]->sent_bytes = sent_bytes;}/* * This function sets number of bytes sent for the current object. * * Params:      int s_id: Session identifier, *                      unsigned int sent_bytes: Bytes sent * * Return:      void * */ void set_object_sent_bytes(int s_id,#ifdef WIN32                            ULONGLONG sent_bytes#else                            unsigned long long sent_bytes#endif			     ) {   alc_session_list[s_id]->obj_sent_bytes = sent_bytes; }/* * This function adds sent bytes in session. * * Params:	int s_id: Session identifier, *			unsigned int sent_bytes: Bytes sent * * Return:	void * */                                                                                                                                       void add_session_sent_bytes(int s_id, unsigned int sent_bytes) {                                                                                                                                               alc_session_list[s_id]->sent_bytes += sent_bytes;}/* * This function adds sent bytes for the object. * * Params:      int s_id: Session identifier, *                      unsigned int sent_bytes: Bytes sent * * Return:      void * */void add_object_sent_bytes(int s_id, unsigned int sent_bytes) {  alc_session_list[s_id]->obj_sent_bytes += sent_bytes;}/* * This function returns last printed percent for the object. * * Params:	int s_id: Session identifier * * Return:	double: Last printed percent. * */   double get_object_last_print_tx_percent(int s_id) {                                                                                                                           return alc_session_list[s_id]->last_print_tx_percent;}                                                                                                                                       /* * This function sets last printed percent for the object. * * Params:	int s_id: Session identifier, *			double last_print_tx_percent: Percent printed. * * Return:	void * */   void set_object_last_print_tx_percent(int s_id, double last_print_tx_percent) {                                                                                          alc_session_list[s_id]->last_print_tx_percent = last_print_tx_percent;}void set_session_tx_toi(int s_id,#ifdef WIN32                        ULONGLONG toi#else                        unsigned long long toi#endif			) {    alc_session_list[s_id]->tx_toi = toi;}#ifdef WIN32ULONGLONG get_session_tx_toi(int s_id) {#elseunsigned long long get_session_tx_toi(int s_id) {#endif return alc_session_list[s_id]->tx_toi;}/* * This function adds channel to session. * Params:	int s_id: Session identifier, *			char *port: Pointer to port string, *			char *addr: Pointer to address string, *			char *intface: Pointer to interface string, *			char *intface_name: Pointer to the interface name. * * Return:	int: Identifier for created channel in success, -1 otherwise * */int add_alc_channel(int s_id, char *port, char *addr, char *intface, char *intface_name) {		alc_channel_t *ch = NULL;	alc_session_t *s = alc_session_list[s_id];		if(s->nb_channel >= s->max_channel) {		/* Could not add new alc channel to alc session */		printf("Could not create new alc channel: Max number of channels already used!\n");		return -1;	}	return open_alc_channel(ch, s, port, addr, intface, intface_name, s->def_tx_rate);}/* * This function removes channel from session. * * Params:	int s_id: Session Identifier, *			int ch_id: Channel Identifier * * Return:	int: 0 in success, -1 otherwise * */int remove_alc_channel(int s_id, int ch_id) {	alc_session_t *s = alc_session_list[s_id];	alc_channel_t *ch = s->ch_list[ch_id];		return close_alc_channel(ch, s);}/* * This function set object wanted from session. * * Params:	int s_id: Session Identifier, *			ULONGLONG/unsigned long long  toi: Transport Object Identifier, *			ULONGLONG/unsigned long long toi_len: Object length, *			unsigned short eslen: Encoding Symbol Length, *			unsigned int max_sblen: Full-Size Source Block Length, *			int fec_inst_id: FEC Instance ID, *			short fec_enc_id: FEC Encoding ID, *			unsigned short max_nb_of_enc_symb:, *			unsigned char content_enc_algo:. * * Return:	int: 0 in success, -1 otherwise * */int set_wanted_object(int s_id,#ifdef WIN32		ULONGLONG toi,        ULONGLONG toi_len,#else		unsigned long long toi,        unsigned long long toi_len,#endif		unsigned short es_len, unsigned int max_sb_len, int fec_inst_id,		short fec_enc_id, unsigned short max_nb_of_es,		unsigned char content_enc_algo) {		alc_session_t *s = alc_session_list[s_id];	wanted_obj_t *wanted_obj;	wanted_obj_t *tmp;	tmp = s->wanted_obj_list;	if(tmp == NULL) {		if (!(wanted_obj = (wanted_obj_t*)calloc(1, sizeof(wanted_obj_t)))) {			printf("Could not alloc memory for wanted object!\n");			return -1;		}		wanted_obj->toi = toi;		wanted_obj->toi_len = toi_len;		wanted_obj->es_len = es_len;		wanted_obj->max_sb_len = max_sb_len;		wanted_obj->fec_inst_id = fec_inst_id;		wanted_obj->fec_enc_id = fec_enc_id;		wanted_obj->max_nb_of_es = max_nb_of_es;		wanted_obj->content_enc_algo = content_enc_algo;		wanted_obj->prev = NULL;		wanted_obj->next = NULL;		s->wanted_obj_list = wanted_obj;	}	else {		for(;; tmp = tmp->next) {			if(tmp->toi == toi) {				break;			}			else if(tmp->next == NULL) {				if (!(wanted_obj = (wanted_obj_t*)calloc(1, sizeof(wanted_obj_t)))) {					printf("Could not alloc memory for wanted object!\n");					return -1;				}				wanted_obj->toi = toi;				wanted_obj->toi_len = toi_len;				wanted_obj->es_len = es_len;				wanted_obj->max_sb_len = max_sb_len;				wanted_obj->fec_inst_id = fec_inst_id;				wanted_obj->fec_enc_id = fec_enc_id;				wanted_obj->max_nb_of_es = max_nb_of_es;				wanted_obj->content_enc_algo = content_enc_algo;				tmp->next = wanted_obj;				wanted_obj->prev = tmp;				wanted_obj->next = NULL;				break;			}		}	}	return 0;}/* * This function checks if object identified with TOI is wanted and returns pointer to wanted object structure. * * Params:	alc_session_t *s: Pointer to Session, *			ULONGLONG/unsigned long long toi: Transport Object Identifier to be checked * * Return:	wanted_obj_t*: Pointer to wanted object structure in success, NULL otherwise * */wanted_obj_t* get_wanted_object(alc_session_t *s,								#ifdef WIN32								ULONGLONG toi) {#else								unsigned long long toi) {#endif	wanted_obj_t *tmp = s->wanted_obj_list;			while(tmp != NULL) {		if(tmp->toi == toi) {			return tmp;		}		tmp = tmp->next;	}	return NULL;}/* * This function removes wanted object identified with toi from the session. * * Params:      int s_id: Session Identifier, *              ULONGLONG/unsigned long long toi: Transport Object Identifier * * Return:      void * */void remove_wanted_object(int s_id,#ifdef WIN32						  ULONGLONG toi) {#else						  unsigned long long toi) {#endif	alc_session_t *s; 		wanted_obj_t *next_want;	wanted_obj_t *want;		s = get_alc_session(s_id);	next_want = s->wanted_obj_list;	while(next_want != NULL) {				want = next_want;		  	    	if(want->toi == toi) {				      		if(want->next != NULL) {					want->next->prev = want->prev;	      		}	      		if(want->prev != NULL) {					want->prev->next = want->next;	      		}	      		if(want == s->wanted_obj_list) {					s->wanted_obj_list = want->next;	      		}	      	      		free(want);	      		break;	    	}	    	next_want = want->next;	}}/* * This function sets FDT Instance to received list * * Params:	alc_session_t *s: Pointer to Session, *			unsigned int fdt_instance_id: FDT Instance ID to be set, * * Return:	int: 0 in success, -1 otherwise * */int set_received_instance(alc_session_t *s, unsigned int fdt_instance_id) {         rx_fdt_instance_t *rx_fdt_instance;        rx_fdt_instance_t *list;                                                                                                                                                      list = s->rx_fdt_instance_list;                                                                                                                                                      if(list == NULL) {                                                                                                                                                              if (!(rx_fdt_instance = (rx_fdt_instance_t*)calloc(1, sizeof(rx_fdt_instance_t)))) {                        printf("Could not alloc memory for rx_fdt_instance!\n");                        return -1;                }                rx_fdt_instance->fdt_instance_id = fdt_instance_id;                rx_fdt_instance->prev = NULL;                rx_fdt_instance->next = NULL;        		s->rx_fdt_instance_list = rx_fdt_instance;        }        else {                for(;; list = list->next) {                        if(list->fdt_instance_id == fdt_instance_id) {                                break;                        }                        else if(list->next == NULL) {              							if (!(rx_fdt_instance = (rx_fdt_instance_t*)calloc(1, sizeof(rx_fdt_instance_t)))) {                					printf("Could not alloc memory for rx_fdt_instance!\n");                        			return -1;                			}		 							rx_fdt_instance->fdt_instance_id = fdt_instance_id;                                                                                                                                              							list->next = rx_fdt_instance;							rx_fdt_instance->prev = list;							rx_fdt_instance->next = NULL;							break;                        }                }        }                                                                                                                                                      return 0;}/* * This function checks if FDT Instance is already received * * Params:	alc_session_t *s: Pointer to Session, *			unsigned int fdt_instance_id: FDT Instance ID to be checked * * Return:	bool: true if received, false otherwise * */                                                                                                                                              bool is_received_instance(alc_session_t *s, unsigned int fdt_instance_id) {                                                                                                                                                      bool retval = false;        rx_fdt_instance_t *list = s->rx_fdt_instance_list;                                                                                                                                                      while(list != NULL) {                if(list->fdt_instance_id == fdt_instance_id) {                        retval = true;                        break;                }                list = list->next;        }                                                                                                                                                      return retval;}/* * This function returns session's base directory. * * Params:	int s_id: Session identifier, * * Return:	char*: Pointer to base directory. * */char* get_session_basedir(int s_id) {	alc_session_t *s; 			s = get_alc_session(s_id);	return s->base_dir;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -