int prod_retrans_abort_entry (ACQ_TABLE *p_acqtable, long prod_seqno, int err_cause) { static char FNAME[]="retrans_abort_entry"; int index_value; /* index for prod_seqno */ int retrans_table_typ; /* retrans table type */ PROD_RETRANS_ENTRY *p_retrans_entry; PROD_RETRANS_ENTRY_INFO *p_retrans_entry_info; if(prod_retrans_get_addr(p_acqtable->proc_base_channel_type_last, p_prod_retrans_table, &p_retrans_entry_info, &p_retrans_entry, &retrans_table_typ) < 0){ uerror("%s ignore abort \n",FNAME); return(ERROR); } /* Now get the index value */ index_value = prod_seqno % p_retrans_entry_info->numb_entries; if(index_value < 0) { index_value = -index_value; } if(index_value >= p_retrans_entry_info->numb_entries) { index_value = 0; } if(ulogIsVerbose ()){ uinfo("%s ok abort %s tbl[%d]=%ld\n",FNAME, GET_SBN_TYP_NAME(p_acqtable->proc_base_channel_type_last), index_value, p_retrans_entry[index_value].prod_seqno); } prod_retrans_update_entry(p_acqtable, (BUFF_HDR *)NULL, p_retrans_entry_info, &p_retrans_entry[index_value], index_value, prod_seqno, p_acqtable->proc_prod_run_id, RETRANS_ENTRY_FLAG_AVAIL, err_cause); return(0); }
int prod_retrans_ck(ACQ_TABLE *p_acqtable, BUFF_HDR *p_buffhdr, time_t *orig_arrive_time) { char FNAME[] = "prod_retrans_ck"; int index_value; int match_value; int retrans_table_type; PROD_RETRANS_ENTRY *p_retrans_entry; PROD_RETRANS_ENTRY_INFO *p_retrans_entry_info; long orig_prod_seqno; long now_prod_seqno; long delta_prod_seqno; /* delta for prod seqno */ int valid_retrans_flag; /* valid retrans flag for table */ match_value = PROD_NODUPLICATE; *orig_arrive_time = 0; if(prod_retrans_get_addr(p_acqtable->proc_base_channel_type_last, p_prod_retrans_table, &p_retrans_entry_info, &p_retrans_entry, &retrans_table_type) < 0) { log_notice("%s ignore retrans_ck\n", FNAME); return(match_value); } if(p_acqtable->proc_orig_prod_seqno_last != 0) { log_debug("%s ok retrans channel_typ=%d tbl[%d] so ck more\n", FNAME, p_acqtable->proc_base_channel_type_last, retrans_table_type); /* Assume have retransmitted product do following */ p_acqtable->proc_tot_prods_retrans_rcvd++, p_retrans_entry_info->tot_prods_retrans_rcvd++; /* If is retransmission, need to see if original product was OK */ /* and ignore the product, else process the product */ index_value = p_acqtable->proc_orig_prod_seqno_last % p_retrans_entry_info->numb_entries; if(index_value < 0) { index_value = -index_value; } if(index_value >= p_retrans_entry_info->numb_entries) { index_value = 0; } /* Check if already have product in table */ if((p_retrans_entry[index_value].prod_seqno == p_acqtable->proc_orig_prod_seqno_last) && (p_retrans_entry[index_value].prod_run_id == p_acqtable->proc_orig_prod_run_id) && (p_retrans_entry[index_value].entry_flag != RETRANS_ENTRY_FLAG_AVAIL)) { /* Assume product matched */ match_value = PROD_DUPLICATE_MATCH; p_acqtable->proc_tot_prods_retrans_rcvd_notlost++; p_retrans_entry_info->tot_prods_retrans_rcvd_notlost++; *orig_arrive_time = p_retrans_entry[index_value].prod_arrive_time; } else { match_value = PROD_DUPLICATE_NOMATCH; p_acqtable->proc_tot_prods_retrans_rcvd_lost++; p_retrans_entry_info->tot_prods_retrans_rcvd_lost++; } log_debug("%s %s duplicate run(%d) prod|orig(%ld|%ld) tbl[%d]=%ld\n", FNAME, (match_value==PROD_DUPLICATE_MATCH)?"OK MATCH":"NO MATCH", p_acqtable->proc_orig_prod_run_id, p_buffhdr->proc_prod_seqno, p_acqtable->proc_orig_prod_seqno_last, index_value, p_retrans_entry[index_value].prod_seqno); /* Check if retransmit prod is within range of table entries */ orig_prod_seqno = (long)p_acqtable->proc_orig_prod_seqno_last; now_prod_seqno = (long)p_buffhdr->proc_prod_seqno; valid_retrans_flag = 0; delta_prod_seqno = now_prod_seqno - orig_prod_seqno; if((match_value == PROD_DUPLICATE_MATCH) || (match_value == PROD_DUPLICATE_NOMATCH)) { if((delta_prod_seqno > 0) && (delta_prod_seqno < p_retrans_entry_info->numb_entries)) { valid_retrans_flag = 1; } } if((match_value == PROD_DUPLICATE_MATCH) || (match_value == PROD_DUPLICATE_NOMATCH)) { if((delta_prod_seqno < 0) && (now_prod_seqno < p_retrans_entry_info->numb_entries)) { valid_retrans_flag = 1; } } /* Now if the original is within the number of active entries */ /* go ahead and update the match table entry */ /* Note, that p_acqtable->proc_base_prod_seqno is not yet set */ if((match_value == PROD_DUPLICATE_NOMATCH) && (valid_retrans_flag == 1)){ /* Now update the prod_retrans_entry */ prod_retrans_update_entry(p_acqtable, p_buffhdr, p_retrans_entry_info, &p_retrans_entry[index_value], index_value, p_acqtable->proc_orig_prod_seqno_last, p_acqtable->proc_orig_prod_run_id, RETRANS_ENTRY_FLAG_RETRANS_VALID, 0); p_retrans_entry_info->index_last = index_value; p_retrans_entry_info->run_id_last = p_acqtable->proc_prod_run_id; } else { /* Check if retransmit prod is within range of table entries */ if((match_value == PROD_DUPLICATE_MATCH) && (valid_retrans_flag == 1)){ /* Now update the prod_retrans_entry */ /* to tell other product is ok but duplicate */ prod_retrans_update_entry(p_acqtable, p_buffhdr, p_retrans_entry_info, &p_retrans_entry[index_value], index_value, p_acqtable->proc_orig_prod_seqno_last, p_acqtable->proc_orig_prod_run_id, RETRANS_ENTRY_FLAG_RETRANS_DUP, 0); } else { if(p_retrans_entry[index_value].prod_run_id == p_acqtable->proc_orig_prod_run_id) { /* Possibly orig prod_seqno greater than current prod_seqno */ /* so discard */ } } /* Note, prod is possibly too old to fit in table */ /* Always, set product for discard */ match_value = PROD_DUPLICATE_DISCARD; } } else { /* If this a new (not retransmitted) product do following */ match_value = PROD_NODUPLICATE; } /* end if-else retransmitted product */ /* In either case need to update entry for new product */ index_value = p_buffhdr->proc_prod_seqno % p_retrans_entry_info->numb_entries; if(index_value < 0) { index_value = -index_value; } if(index_value >= p_retrans_entry_info->numb_entries) { index_value = 0; } /* IMPORTANT, this value will be removed later if product in error */ /* Now update the prod_retrans_entry */ /* and also indicate if was a retransmission product */ prod_retrans_update_entry(p_acqtable, p_buffhdr, p_retrans_entry_info, &p_retrans_entry[index_value], index_value, p_buffhdr->proc_prod_seqno, p_acqtable->proc_prod_run_id, RETRANS_ENTRY_FLAG_NEW_VALID| ((p_acqtable->proc_orig_prod_seqno_last != 0)? RETRANS_ENTRY_FLAG_NEW_W_DUP:0), 0); p_retrans_entry_info->index_last = index_value; p_retrans_entry_info->run_id_last = p_acqtable->proc_prod_run_id; /* Debug only */ if(match_value & PROD_NODUPLICATE) { log_debug(" %s %s entry(%d) prod(%ld) code=%d %s[%d]\n", FNAME, GET_PROD_TYPE_NAME(p_buffhdr->proc_prod_type), index_value, p_buffhdr->proc_prod_seqno, p_buffhdr->proc_prod_code, (match_value & PROD_NODUPLICATE)?"NO_DUPL": (match_value & PROD_DUPLICATE_MATCH)?"DUPL_MATCH": (match_value & PROD_DUPLICATE_NOMATCH)?"DUPL_NOMATCH": "UNKNOWN", match_value); } else { log_debug("%s %s entry(%d) prod|orig(%ld|%ld) code=%d %s[%d]\n", FNAME, GET_PROD_TYPE_NAME(p_buffhdr->proc_prod_type), index_value, p_buffhdr->proc_prod_seqno, p_acqtable->proc_orig_prod_seqno_last, p_buffhdr->proc_prod_code, (match_value & PROD_NODUPLICATE)?"NO_DUPL": (match_value & PROD_DUPLICATE_MATCH)?"DUPL_MATCH": (match_value & PROD_DUPLICATE_NOMATCH)?"DUPL_NOMATCH": "UNKNOWN", match_value); } /* Debug only */ return(match_value); }