Beispiel #1
0
/*******************************************************************************
 * SEND ALARM MESSAGE TO COND
*******************************************************************************/
void Send_AlmMsg( char loctype, char invtype, short invno, char almstatus, char oldalm)
{
	st_almsts almsts;

	int				dRet;
	pst_MsgQ        pstSndMsg;
	pst_MsgQSub     pstSndSub;
	U8			   *pNODE;

	if( (dRet = dGetNode(&pNODE, &pstSndMsg)) < 0 ){
        log_print(LOGN_CRI,LH"FAILED IN dGetNode(CHSMD)",LT);
        return;
    }

	memset( &almsts, 0x00, DEF_ALMSTS_SIZE );

	almsts.ucSysType = SYSTYPE_TAF;
	almsts.ucSysNo = (unsigned char)gdSysNo;	/* NTAF */
	almsts.ucLocType = loctype;
	almsts.ucInvType = invtype;
	almsts.ucInvNo = invno;
	almsts.ucAlmLevel = almstatus;
	almsts.ucOldAlmLevel = oldalm;

	if( loctype == LOCTYPE_LOAD ){
		CalcLoad( invtype, invno, &almsts.llLoadVal );
	}
	else
		almsts.llLoadVal = 0;

	time(&almsts.tWhen);

	set_time(almsts.ucLocType, almsts.ucInvType, almsts.ucInvNo, almsts.tWhen);

#ifdef DEBUG
	log_print(LOGN_INFO,"LOCTYPE[%x], INVTYPE[%x], INVNO[%d] ALMSTATUS[%x]",
	loctype, invtype, invno, almstatus );
#endif

	/* Head 결정 */

	pstSndSub = (pst_MsgQSub)(unsigned long*)&pstSndMsg->llMType;
    pstSndSub->usType = DEF_SYS;
    pstSndSub->usSvcID = SID_STATUS;
    pstSndSub->usMsgID = MID_ALARM;

	util_makenid( SEQ_PROC_CHSMD, &pstSndMsg->llNID );
	pstSndMsg->ucNTAMID = 0;
	pstSndMsg->ucNTAFID = almsts.ucSysNo;
    pstSndMsg->ucProID = SEQ_PROC_CHSMD;
    pstSndMsg->llIndex = dNIDIndex;
    dNIDIndex++;

	pstSndMsg->dMsgQID = 0;

	/*
	* NTAFT_HEADER_LEN < Socket Header Size 만큼 +
	*/
    pstSndMsg->usBodyLen = DEF_ALMSTS_SIZE;
    pstSndMsg->usRetCode = 0;

	//memset( pstSndMsg->szBody, 0x00, MNG_PKT_HEAD_SIZE );
	memcpy( &pstSndMsg->szBody[0], &almsts, pstSndMsg->usBodyLen );

	/***************************************************************************
	 * ALMD로 메시지 전송
	***************************************************************************/
	if( (dRet = dMsgsnd(SEQ_PROC_ALMD, pNODE)) < 0 ){
        log_print(LOGN_CRI, LH"FAILED IN dMsgsnd(ALMD)"EH, LT, ET);
        return;
    }
    log_print(LOGN_DEBUG, LH"SUCCESS IN dMsgsnd(ALMD) MESSAGE PROCESSID=%d, BLEN=%d", LT, SEQ_PROC_ALMD, pstSndMsg->usBodyLen);


	/***************************************************************************
	 * COND로 전송하던 내용을 전송하는 부분 추가
	***************************************************************************/
	pstSndSub->usMsgID = MID_CONSOL;
	pstSndMsg->dMsgQID = 0;

	if( (dRet = dMsgsnd(SEQ_PROC_CI_SVC, pNODE)) < 0 ){
        log_print(LOGN_CRI, LH"FAILED IN dMsgsnd(CI_SVC)"EH, LT, ET);
        return;
    }
    log_print(LOGN_DEBUG, LH"SUCCESS IN dMsgsnd(CI_SVC) MESSAGE PROCESSID=%d, BLEN=%d, SID=%d, MID=%d", 
		LT, SEQ_PROC_CI_SVC, pstSndMsg->usBodyLen, pstSndSub->usSvcID, pstSndSub->usMsgID);

	/* UPDATE fidb.mem */
	write_FIDB();

	return;
}
Beispiel #2
0
int PlayerGetVFilterFormat(play_para_t*am_p)
{
	signed short video_index = am_p->vstream_info.video_index;
	char value[1024];
	int filter_fmt = 0;
	unsigned int codec_id;

	if (video_index != -1) {
		AVStream *pStream;
		AVCodecContext  *pCodecCtx;
		pStream = am_p->pFormatCtx->streams[video_index];
		pCodecCtx = pStream->codec;
		if (am_p->stream_type == STREAM_ES && pCodecCtx->codec_tag != 0) {
			codec_id=pCodecCtx->codec_tag;
		}
		else {
			codec_id=pCodecCtx->codec_id;
		}

		if ((pCodecCtx->codec_id == CODEC_ID_H264MVC) && (!am_p->vdec_profile.hmvc_para.exist)) {
			filter_fmt |= FILTER_VFMT_HMVC;
		}
		if ((pCodecCtx->codec_id == CODEC_ID_H264) && (!am_p->vdec_profile.h264_para.exist)) {
			filter_fmt |= FILTER_VFMT_H264;
		}
	}

    if (GetSystemSettingString("media.amplayer.disable-vcodecs", value, NULL) > 0) {
		log_print("[%s:%d]disable_vdec=%s\n", __FUNCTION__, __LINE__, value);
		if (strstr(value,"MPEG12") != NULL || strstr(value,"mpeg12") != NULL) {
			filter_fmt |= FILTER_VFMT_MPEG12;
		}
		if (strstr(value,"MPEG4") != NULL || strstr(value,"mpeg4") != NULL) {
			filter_fmt |= FILTER_VFMT_MPEG4;
		}
		if (strstr(value,"H264") != NULL || strstr(value,"h264") != NULL) {
			filter_fmt |= FILTER_VFMT_H264;
		}
		if (strstr(value,"MJPEG") != NULL || strstr(value,"mjpeg") != NULL) {
			filter_fmt |= FILTER_VFMT_MJPEG;
		}
		if (strstr(value,"REAL") != NULL || strstr(value,"real") != NULL) {
			filter_fmt |= FILTER_VFMT_REAL;
		}
		if (strstr(value,"JPEG") != NULL || strstr(value,"jpeg") != NULL) {
			filter_fmt |= FILTER_VFMT_JPEG;
		}
		if (strstr(value,"VC1") != NULL || strstr(value,"vc1") != NULL) {
			filter_fmt |= FILTER_VFMT_VC1;
		}
		if (strstr(value,"AVS") != NULL || strstr(value,"avs") != NULL) {
			filter_fmt |= FILTER_VFMT_AVS;
		}
		if (strstr(value,"SW") != NULL || strstr(value,"sw") != NULL) {
			filter_fmt |= FILTER_VFMT_SW;
		}
		if (strstr(value,"HMVC") != NULL || strstr(value,"hmvc") != NULL){
			filter_fmt |= FILTER_VFMT_HMVC;
		}
		/*filter by codec id*/
		if (strstr(value,"DIVX3") != NULL || strstr(value,"divx3") != NULL){
			if (codec_id == CODEC_TAG_DIV3)
				filter_fmt |= FILTER_VFMT_MPEG4;
		}
		if (strstr(value,"DIVX4") != NULL || strstr(value,"divx4") != NULL){
			if (codec_id == CODEC_TAG_DIV4)
				filter_fmt |= FILTER_VFMT_MPEG4;
		}
		if (strstr(value,"DIVX5") != NULL || strstr(value,"divx5") != NULL){
			if (codec_id == CODEC_TAG_DIV5)
				filter_fmt |= FILTER_VFMT_MPEG4;
		}
    }
	log_print("[%s:%d]filter_vfmt=%x\n", __FUNCTION__, __LINE__, filter_fmt);
    return filter_fmt;
}
Beispiel #3
0
/**
 * @brief Main function for oaextendmpi and oaextendsingle
 * @param argc
 * @param argv[]
 * @return
 */
int main (int argc, char *argv[]) {
#ifdef OAEXTEND_SINGLECORE
        const int n_processors = 1;
        const int this_rank = 0;
#else
        MPI::Init (argc, argv);

        const int n_processors = MPI::COMM_WORLD.Get_size ();
        const int this_rank = MPI::COMM_WORLD.Get_rank ();
#endif

        // printf("MPI: this_rank %d\n", this_rank);

        /*----------SET STARTING ARRAY(S)-----------*/
        if (this_rank != MASTER) {
#ifdef OAEXTEND_MULTICORE
                slave_print (QUIET, "M: running core %d/%d\n", this_rank, n_processors);
#endif
                algorithm_t algorithm = MODE_INVALID;
                AnyOption *opt = parseOptions (argc, argv, algorithm);
                OAextend oaextend;
                oaextend.setAlgorithm (algorithm);

#ifdef OAEXTEND_MULTICORE
                log_print (NORMAL, "slave: receiving algorithm int\n");
                algorithm = (algorithm_t)receive_int_slave ();
                oaextend.setAlgorithm (algorithm);
// printf("slave %d: receive algorithm %d\n", this_rank, algorithm);
#endif

                extend_slave_code (this_rank, oaextend);

                delete opt;
        } else {
                double Tstart = get_time_ms ();
                int nr_extensions;
                arraylist_t solutions, extensions;

                algorithm_t algorithm = MODE_INVALID;
                AnyOption *opt = parseOptions (argc, argv, algorithm);
                print_copyright ();

                int loglevel = opt->getIntValue ('l', NORMAL);
                setloglevel (loglevel);

                int dosort = opt->getIntValue ('s', 1);
                int userowsymm = opt->getIntValue ("rowsymmetry", 1);
                int maxk = opt->getIntValue ("maxk", 100000);
                int initcolprev = opt->getIntValue ("initcolprev", 1);

                const bool streaming = opt->getFlag ("streaming");

                bool restart = false;
                if (opt->getValue ("restart") != NULL || opt->getValue ('r') != NULL) {
                        restart = true;
                }

                const char *oaconfigfile = opt->getStringValue ('c', "oaconfig.txt");
                const char *resultprefix = opt->getStringValue ('o', "result");

                arrayfile::arrayfilemode_t mode = arrayfile_t::parseModeString (opt->getStringValue ('f', "T"));

                OAextend oaextend;
                oaextend.setAlgorithm (algorithm);

                if (streaming) {
                        logstream (SYSTEM) << "operating in streaming mode, sorting of arrays will not work "
                                           << std::endl;
                        oaextend.extendarraymode = OAextend::STOREARRAY;
                }

                // J5_45
                int xx = opt->getFlag ('x');
                if (xx) {
                        oaextend.j5structure = J5_45;
                }

                if (userowsymm == 0) {
                        oaextend.use_row_symmetry = userowsymm;
                        printf ("use row symmetry -> %d\n", oaextend.use_row_symmetry);
                }
                if (opt->getFlag ('g')) {
                        std::cout << "only generating arrays (no LMC check)" << endl;
                        oaextend.checkarrays = 0;
                }

                if (opt->getFlag ("help") || (opt->getValue ("coptions") != NULL)) {
                        if (opt->getFlag ("help")) {
                                opt->printUsage ();
                        }
                        if (opt->getValue ("coptions") != NULL) {
                                print_options (cout);
                        }
                } else {
                        logstream (QUIET) << "#time start: " << currenttime () << std::endl;

                        arraydata_t *ad;
                        ad = readConfigFile (oaconfigfile);
                        ad->lmc_overflow_check ();

                        if (ad == 0) {
                                return 1;
                        }

                        log_print (NORMAL, "Using design file: %s (runs %d, strength %d)\n", oaconfigfile, ad->N,
                                   ad->strength);

                        if (oaextend.getAlgorithm () == MODE_AUTOSELECT) {
                                oaextend.setAlgorithmAuto (ad);
                        }

#ifdef OAEXTEND_SINGLECORE
                        if (initcolprev == 0) {
                                log_print (NORMAL, "setting oaextend.init_column_previous to %d\n", INITCOLUMN_ZERO);
                                oaextend.init_column_previous = INITCOLUMN_ZERO;
                        }
#endif

#ifdef OAEXTEND_MULTICORE
                        int alg = oaextend.getAlgorithm ();
                        for (int i = 0; i < n_processors; i++) {
                                if (i == MASTER) {
                                        continue;
                                }
                                log_print (NORMAL, "MASTER: sending algorithm %d to slave %d\n", alg, i);
                                send_int (alg, i);
                        }
#endif
                        colindex_t col_start;

                        log_print (SYSTEM, "using algorithm %d (%s)\n", oaextend.getAlgorithm (),
                                   oaextend.getAlgorithmName ().c_str ());
                        if (log_print (NORMAL, "")) {
                                cout << oaextend.__repr__ ();
                        }

                        if (restart) { // start from result file
                                int initres = init_restart (opt->getValue ('r'), col_start, solutions);
                                if (initres == 1) { // check if restarting went OK
                                        logstream (SYSTEM) << "Problem with restart from " << opt->getValue ('r') << ""
                                                           << endl;

#ifdef OAEXTEND_MPI
                                        MPI_Abort (MPI_COMM_WORLD, 1);
#endif
                                        exit (1);
                                }

                                if (dosort) {
                                        double Ttmp = get_time_ms ();
                                        sort (solutions.begin (), solutions.end ()); // solutions.sort();

                                        log_print (QUIET, "   sorting of initial solutions: %.3f [s]\n",
                                                   get_time_ms () - Ttmp);
                                }

                                // check that oaconfig agrees with loaded arrays
                                if (solutions.size () > 0) {
                                        if (ad->N != solutions[0].n_rows) {
                                                printf ("Problem: oaconfig does not agree with loaded arrays!\n");
                                                // free_sols(solutions); ??
                                                solutions.clear ();
                                        }
                                }

                        } else {
                                // starting with root
                                if (check_divisibility (ad) == false) { 
                                        log_print (SYSTEM, "ERROR: Failed divisibility test!\n");

#ifdef OAEXTEND_MPI
                                        MPI_Abort (MPI_COMM_WORLD, 1);
#endif
                                        exit (1);
                                }
                                create_root (ad, solutions);
                                col_start = ad->strength;
                        }

                        /*-----------MAIN EXTENSION LOOP-------------*/

                        log_print (SYSTEM, "M: running with %d procs\n", n_processors);

                        maxk = std::min (maxk, ad->ncols);

                        time_t seconds;
                        for (colindex_t current_col = col_start; current_col < maxk; current_col++) {
                                fflush (stdout);
                                arraydata_t *adcol = new arraydata_t (ad, current_col + 1);

                                if (streaming) {

                                        string fname = resultprefix;
                                        fname += "-streaming";
                                        fname += "-" + oafilestring (ad);
                                        logstream (NORMAL) << "oaextend: streaming mode: create file " << fname
                                                           << std::endl;
                                        int nb = arrayfile_t::arrayNbits (*ad);

                                        oaextend.storefile.createfile (fname, adcol->N, ad->ncols, -1, ABINARY, nb);
                                }

                                log_print (SYSTEM, "Starting with column %d (%d, total time: %.2f [s])\n",
                                           current_col + 1, (int)solutions.size (), get_time_ms () - Tstart);
                                nr_extensions = 0;
                                arraylist_t::const_iterator cur_extension;

                                int csol = 0;
                                for (cur_extension = solutions.begin (); cur_extension != solutions.end ();
                                     cur_extension++) {
                                        print_progress (csol, solutions, extensions, Tstart, current_col);
                                        logstream (NORMAL) << cur_extension[0];

                                        if (n_processors == 1) {
                                                nr_extensions += extend_array (*cur_extension, adcol,
                                                                               current_col, extensions, oaextend);
                                        } else {
#ifdef OAEXTEND_MPI
                                                throw_runtime_exception("mpi version of oextend is no longer supported");
                                                double Ttmp = get_time_ms ();
                                                int slave = collect_solutions_single (extensions, adcol);
                                                log_print (DEBUG, "   time: %.2f, collect time %.2f\n",
                                                           (get_time_ms () - Tstart), (get_time_ms () - Ttmp));

                                                /* OPTIMIZE: send multiple arrays to slave 1 once step */
                                                extend_array_mpi (cur_extension->array, 1, adcol, current_col, slave);
#endif
                                        }

#ifdef OAEXTEND_MPI
                                        if ((csol + 1) % nsolsync == 0) {
                                                collect_solutions_all (extensions, adcol);
                                        }
#endif
                                        // OPTIMIZE: periodically write part of the solutions to disk
                                        csol++; /* increase current solution */
                                }
#ifdef OAEXTEND_MPI
                                collect_solutions_all (extensions, adcol);
#endif

                                if (checkloglevel (NORMAL)) {
                                        csol = 0;
                                        for (cur_extension = extensions.begin (); cur_extension != extensions.end ();
                                             cur_extension++) {
                                                log_print (DEBUG, "%i: -----\n", ++csol);
                                                logstream (DEBUG) << cur_extension[0];
                                        }
                                }
                                if (dosort) {
                                        log_print (DEBUG, "Sorting solutions, necessary for multi-processor code\n");
                                        double Ttmp = get_time_ms ();
                                        sort (extensions.begin (), extensions.end ());
                                        log_print (DEBUG, "   sorting time: %.3f [s]\n", get_time_ms () - Ttmp);
                                }

                                save_arrays (extensions, adcol, resultprefix, mode);
                                solutions.swap (extensions); // swap old and newly found solutions
                                extensions.clear ();         // clear old to free up space for new extensions

                                log_print (SYSTEM, "Done with column %i, total of %i solutions (time %.2f s))\n",
                                           current_col + 1, (int)solutions.size (), get_time_ms () - Tstart);

                                delete adcol;

#ifdef OAANALYZE_DISCR
                                logstream (NORMAL) << "Discriminant: " << endl;
                                print_discriminant (ad->N, current_col + 1);
#endif
                        }
                        /*------------------------*/
                        time (&seconds);
                        struct tm *tminfo;
                        tminfo = localtime (&seconds);
                        log_print (SYSTEM, "TIME: %.2f s, %s", get_time_ms () - Tstart, asctime (tminfo));
                        logstream (QUIET) << "#time end: " << currenttime () << std::endl;
                        logstream (QUIET) << "#time total: " << printfstring ("%.1f", get_time_ms () - Tstart)
                                          << " [s]" << std::endl;

                        solutions.clear ();
                        delete ad;

#ifdef OAEXTEND_MPI
                        stop_slaves ();
#endif
                }

                delete opt;
        } /* end of master code */

#ifdef OAEXTEND_MPI
        MPI_Finalize ();
#endif

        return 0;
}
Beispiel #4
0
static gint smtp_session_recv_msg(Session *session, const gchar *msg)
{
	SMTPSession *smtp_session = SMTP_SESSION(session);
	gboolean cont = FALSE;
	gint ret = 0;
	
	if (strlen(msg) < 4) {
		log_warning(LOG_PROTOCOL, _("bad SMTP response\n"));
		return -1;
	}

	switch (smtp_session->state) {
	case SMTP_EHLO:
	case SMTP_STARTTLS:
	case SMTP_AUTH:
	case SMTP_AUTH_PLAIN:
	case SMTP_AUTH_LOGIN_USER:
	case SMTP_AUTH_LOGIN_PASS:
	case SMTP_AUTH_CRAM_MD5:
		log_print(LOG_PROTOCOL, "ESMTP< %s\n", msg);
		break;
	default:
		log_print(LOG_PROTOCOL, "SMTP< %s\n", msg);
		break;
	}

	/* ignore all multiline responses except for EHLO */
	if (msg[3] == '-' && smtp_session->state != SMTP_EHLO)
		return session_recv_msg(session);

	if (msg[0] == '5' && msg[1] == '0' &&
	    (msg[2] == '4' || msg[2] == '3' || msg[2] == '1')) {
		log_warning(LOG_PROTOCOL, _("error occurred on SMTP session\n"));
		smtp_session->state = SMTP_ERROR;
		smtp_session->error_val = SM_ERROR;
		g_free(smtp_session->error_msg);
		smtp_session->error_msg = g_strdup(msg);
		return -1;
	}

	if (!strncmp(msg, "535", 3)) {
		log_warning(LOG_PROTOCOL, _("error occurred on authentication\n"));
		smtp_session->state = SMTP_ERROR;
		smtp_session->error_val = SM_AUTHFAIL;
		g_free(smtp_session->error_msg);
		smtp_session->error_msg = g_strdup(msg);
		return -1;
	}

	if (msg[0] != '1' && msg[0] != '2' && msg[0] != '3') {
		log_warning(LOG_PROTOCOL, _("error occurred on SMTP session\n"));
		smtp_session->state = SMTP_ERROR;
		smtp_session->error_val = SM_ERROR;
		g_free(smtp_session->error_msg);
		smtp_session->error_msg = g_strdup(msg);
		return -1;
	}

	if (msg[3] == '-')
		cont = TRUE;
	else if (msg[3] != ' ' && msg[3] != '\0') {
		log_warning(LOG_PROTOCOL, _("bad SMTP response\n"));
		smtp_session->state = SMTP_ERROR;
		smtp_session->error_val = SM_UNRECOVERABLE;
		return -1;
	}

	switch (smtp_session->state) {
	case SMTP_READY:
		if (strstr(msg, "ESMTP"))
			smtp_session->is_esmtp = TRUE;
#ifdef USE_GNUTLS
		if (smtp_session->user || session->ssl_type != SSL_NONE ||
		    smtp_session->is_esmtp)
#else
		if (smtp_session->user || smtp_session->is_esmtp)
#endif
			ret = smtp_ehlo(smtp_session);
		else
			ret = smtp_helo(smtp_session);
		break;
	case SMTP_HELO:
		ret = smtp_from(smtp_session);
		break;
	case SMTP_EHLO:
		ret = smtp_ehlo_recv(smtp_session, msg);
		if (cont == TRUE)
			break;
		if (smtp_session->max_message_size > 0
		&& smtp_session->max_message_size < 
		   smtp_session->send_data_len) {
			log_warning(LOG_PROTOCOL, _("Message is too big "
			      "(Maximum size is %s)\n"),
			      to_human_readable(
			       (goffset)(smtp_session->max_message_size)));
			smtp_session->state = SMTP_ERROR;
			smtp_session->error_val = SM_ERROR;
			return -1;
		}
#ifdef USE_GNUTLS
		if (session->ssl_type == SSL_STARTTLS &&
		    smtp_session->tls_init_done == FALSE) {
			ret = smtp_starttls(smtp_session);
			break;
		}
#endif
		if (smtp_session->user) {
			if (smtp_auth(smtp_session) != SM_OK) {
#ifdef USE_GNUTLS
				if (session->ssl_type == SSL_NONE
				&&  smtp_session->tls_init_done == FALSE
				&&  (smtp_session->avail_auth_type & SMTPAUTH_TLS_AVAILABLE))
					ret = smtp_starttls(smtp_session);
				else
#endif
					ret = smtp_from(smtp_session);
			}
		} else
			ret = smtp_from(smtp_session);
		break;
	case SMTP_STARTTLS:
#ifdef USE_GNUTLS
		if (session_start_tls(session) < 0) {
			log_warning(LOG_PROTOCOL, _("couldn't start TLS session\n"));
			smtp_session->state = SMTP_ERROR;
			smtp_session->error_val = SM_ERROR;
			return -1;
		}
		smtp_session->tls_init_done = TRUE;
		ret = smtp_ehlo(smtp_session);
#endif
		break;
	case SMTP_AUTH:
		ret = smtp_auth_recv(smtp_session, msg);
		break;
	case SMTP_AUTH_LOGIN_USER:
		ret = smtp_auth_login_user_recv(smtp_session, msg);
		break;
	case SMTP_AUTH_PLAIN:
	case SMTP_AUTH_LOGIN_PASS:
	case SMTP_AUTH_CRAM_MD5:
		ret = smtp_from(smtp_session);
		break;
	case SMTP_FROM:
		if (smtp_session->cur_to)
			ret = smtp_rcpt(smtp_session);
		break;
	case SMTP_RCPT:
		if (smtp_session->cur_to)
			ret = smtp_rcpt(smtp_session);
		else
			ret = smtp_data(smtp_session);
		break;
	case SMTP_DATA:
		ret = smtp_send_data(smtp_session);
		break;
	case SMTP_EOM:
		smtp_make_ready(smtp_session);
		break;
	case SMTP_QUIT:
		session_disconnect(session);
		break;
	case SMTP_ERROR:
	default:
		log_warning(LOG_PROTOCOL, _("error occurred on SMTP session\n"));
		smtp_session->error_val = SM_ERROR;
		return -1;
	}

	if (cont && ret == SM_OK)
		return session_recv_msg(session);

	if (ret != SM_OK)
		smtp_session->error_val = SM_ERROR;

	return ret == SM_OK ? 0 : -1;
}
Beispiel #5
0
int print_stat(struct stat *stbuf, const char *title) {
    if (debug) {
        log_print(LOG_DEBUG, "stat: %s", title);
        log_print(LOG_DEBUG, "  .st_mode=%04o", stbuf->st_mode);
        log_print(LOG_DEBUG, "  .st_nlink=%ld", stbuf->st_nlink);
        log_print(LOG_DEBUG, "  .st_uid=%d", stbuf->st_uid);
        log_print(LOG_DEBUG, "  .st_gid=%d", stbuf->st_gid);
        log_print(LOG_DEBUG, "  .st_size=%ld", stbuf->st_size);
        log_print(LOG_DEBUG, "  .st_blksize=%ld", stbuf->st_blksize);
        log_print(LOG_DEBUG, "  .st_blocks=%ld", stbuf->st_blocks);
        log_print(LOG_DEBUG, "  .st_atime=%ld", stbuf->st_atime);
        log_print(LOG_DEBUG, "  .st_mtime=%ld", stbuf->st_mtime);
        log_print(LOG_DEBUG, "  .st_ctime=%ld", stbuf->st_ctime);
    }
    return 0;
}
Beispiel #6
0
bool_t check_string_realloc(char *type, uint32_t check) {

	size_t len;
	stringer_t *s, *swap;

	if (!(s = st_alloc(check, 1)) || !(swap = st_realloc(s, st_length_get(constant)))) {
		if (s) {
			st_free(s);
		}
		return false;
	}

	// Since mapped allocations are page aligned, we reallocate to a larger than needed size to ensure an actual reallocation occurs.
	else if (check & MAPPED_T && !(swap = st_realloc(s, st_length_get(constant) + (getpagesize() * 128)))) {
		if (s) {
			st_free(s);
		}
		return false;
	}

	// Jointed strings allow reallocation without changing the address of s, of if the string is jointed and s changes, error out.
	else if (check & JOINTED && swap != s) {
		st_free(swap);
		st_free(s);
		return false;
	}

	// Contiguous strings will require the address of s to change, so if it doesn't error out. Except for the mapped type, since the jointed flag doesn't apply to it.
	else if (!(check & JOINTED) && !(check & MAPPED_T) && swap == s) {
		st_free(s);
		return false;
	}

	// For contiguous types, free the original string and replace it with the value of swap.
	else if (swap != s) {
		st_free(s);
		s = swap;
	}

	len = snprintf(st_char_get(s), st_length_int(constant) + 1, "%.*s", st_length_int(constant), st_char_get(constant));
	if (check & MAPPED_T || check & MANAGED_T) {
		st_length_set(s, len);
	}

	else if (memcmp(st_char_get(s), st_char_get(constant), st_length_get(constant))) {
		return false;
	}

	// Enlarge a buffer by a factor of 128 and make sure the data it contained wasn't changed. For managed or mapped strings, multiply the available space.
	if (check & (MANAGED_T | MAPPED_T) && !(swap = st_realloc(s, st_avail_get(s) * 128))) {
		st_free(s);
		return false;
	}

	// For other string types we multiply the space used by the string since the original allocation size isn't tracked.
	else if (!(check & (MANAGED_T | MAPPED_T)) && !(swap = st_realloc(s, st_length_get(s) * 128))) {
		st_free(s);
		return false;
	}

	// Since mapped allocations are page aligned, we reallocate to a larger than needed size to ensure an actual reallocation occurs.
	else if (check & MAPPED_T && !(swap = st_realloc(s, st_length_get(constant) + (getpagesize() * 128)))) {
		if (s) {
			st_free(s);
		}
		return false;
	}

	// Jointed strings allow reallocation without changing the address of s, of if the string is jointed and s changes, error out.
	else if (check & JOINTED && swap != s) {
		st_free(swap);
		st_free(s);
		return false;
	}

	// Contiguous strings will require the address of s to change, so if it doesn't error out. Except for the mapped type, since the jointed flag doesn't apply to it.
	else if ((check & JOINTED) ^ JOINTED && !(check & MAPPED_T) && swap == s) {
		st_free(s);
		return false;
	}

	// For contiguous types, free the original string and replace it with the value of swap.
	else if (swap != s) {
		st_free(s);
		s = swap;
	}

	else if (memcmp(st_char_get(s), st_char_get(constant), st_length_get(constant))) {
		return false;
	}

	// Now we shrink the buffer back to the bare minimum and check the data one final time.
	if (!(swap = st_realloc(s, st_length_get(constant)))) {
		if (s) {
			st_free(s);
		}
		return false;
	} else if (swap != s) {
		st_free(s);
		s = swap;
	}

	log_print("%28.28s = %.*s", type, st_length_int(s), st_char_get(s));
	st_free(s);
	return true;
}
Beispiel #7
0
int
sys_start(int argc, char *argv[])
{
	int status;
	const char* f;
	lua_State *L;
	
	if (argc<2) {
		printf("%s: <filename.lua>\n", argv[0]);
		return 1;
	}
	
    s_init();
    log_print("sound> initialized\n");
	
	L = lua_open();
	/*luaopen_base(L);*/
	luaL_openlibs(L);
	luaopen_sys(L);
	luaopen_log(L);
	luaopen_mat4(L);
	luaopen_quat(L);
	luaopen_vec3(L);
	luaopen_event(L);
	luaopen_image(L);
	luaopen_render(L);
	luaopen_shader(L);
	luaopen_sound(L);
	luaopen_net(L);
	luaopen_util(L);
	luaopen_font(L);
	luaopen_md2(L);
	//luaopen_blender(L);
	
	lua_getglobal(L, "package");
	if (LUA_TTABLE != lua_type(L, 1)) {
		log_print("lua> 'package' is not a table\n");
		return 1;
	}
	lua_getfield(L, 1, "path");
	if (LUA_TSTRING != lua_type(L, 2)) {
		log_print("lua> 'package.path' is not a string\n");
		lua_pop(L, 1);
		return 1;
	}
	lua_pop(L, 1);
	
#if defined(__IPHONE__)
	f = full_path();
#else
	f = ".";
#endif

	/* package.path = f .. "/?.lua" */
	lua_pushlstring(L, f, strlen(f));
	lua_pushliteral(L, "/?.lua");
	lua_concat(L, 2);
	lua_setfield(L, 1, "path");

	lua_bootstrap(L, f);

#if defined(__IPHONE__)
	f = full_path_to_file(argv[1]);
#else
	f = argv[1];
#endif

	log_print("lua> initialized\n");
	printf("lua> loading %s\n", f);
	
	if (luaL_loadfile(L,f)==0) { 
		/* function runme = file_content */
		lua_setglobal(L, "runme");
		lua_getglobal(L, "runme");

		status = lua_pcall(L,0,LUA_MULTRET,0);
		assert(0 == report(L, status));
        
        if (lua_gettop(L) > 0) {
            status = lua_toboolean(L, -1);
            if (!status) {
                printf("lua> %s returned false\n", f);
                sys_quit();
            }
        }
		
        log_print("lua> loaded\n");
	} else {
		printf("lua> unable to load %s\n",f);
		report(L, status);
		sys_quit();
	}

	lua_state = L;
	
	/* TODO: Double check this stuff some day when bored. */
	return status > 0 ? false : true;	
}
Beispiel #8
0
static int _pv_resize_single(struct cmd_context *cmd,
			     struct volume_group *vg,
			     struct physical_volume *pv,
			     const uint64_t new_size)
{
	struct pv_list *pvl;
	uint64_t size = 0;
	uint32_t new_pe_count = 0;
	int r = 0;
	struct dm_list mdas;
	const char *pv_name = pv_dev_name(pv);
	const char *vg_name = pv_vg_name(pv);
	struct lvmcache_info *info;
	int mda_count = 0;
	struct volume_group *old_vg = vg;

	dm_list_init(&mdas);

	if (is_orphan_vg(vg_name)) {
		if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) {
			log_error("Can't get lock for orphans");
			return 0;
		}

		if (!(pv = pv_read(cmd, pv_name, &mdas, NULL, 1, 0))) {
			unlock_vg(cmd, vg_name);
			log_error("Unable to read PV \"%s\"", pv_name);
			return 0;
		}

		mda_count = dm_list_size(&mdas);
	} else {
		vg = vg_read_for_update(cmd, vg_name, NULL, 0);

		if (vg_read_error(vg)) {
			vg_release(vg);
			log_error("Unable to read volume group \"%s\".",
				  vg_name);
			return 0;
		}

		if (!(pvl = find_pv_in_vg(vg, pv_name))) {
			log_error("Unable to find \"%s\" in volume group \"%s\"",
				  pv_name, vg->name);
			goto out;
		}

		pv = pvl->pv;

		if (!(info = info_from_pvid(pv->dev->pvid, 0))) {
			log_error("Can't get info for PV %s in volume group %s",
				  pv_name, vg->name);
			goto out;
		}

		mda_count = dm_list_size(&info->mdas);

		if (!archive(vg))
			goto out;
	}

	/* FIXME Create function to test compatibility properly */
	if (mda_count > 1) {
		log_error("%s: too many metadata areas for pvresize", pv_name);
		goto out;
	}

	if (!(pv->fmt->features & FMT_RESIZE_PV)) {
		log_error("Physical volume %s format does not support resizing.",
			  pv_name);
		goto out;
	}

	/* Get new size */
	if (!dev_get_size(pv_dev(pv), &size)) {
		log_error("%s: Couldn't get size.", pv_name);
		goto out;
	}

	if (new_size) {
		if (new_size > size)
			log_warn("WARNING: %s: Overriding real size. "
				  "You could lose data.", pv_name);
		log_verbose("%s: Pretending size is %" PRIu64 " not %" PRIu64
			    " sectors.", pv_name, new_size, pv_size(pv));
		size = new_size;
	}

	if (size < PV_MIN_SIZE) {
		log_error("%s: Size must exceed minimum of %ld sectors.",
			  pv_name, PV_MIN_SIZE);
		goto out;
	}

	if (size < pv_pe_start(pv)) {
		log_error("%s: Size must exceed physical extent start of "
			  "%" PRIu64 " sectors.", pv_name, pv_pe_start(pv));
		goto out;
	}

	pv->size = size;

	if (vg) {
		pv->size -= pv_pe_start(pv);
		new_pe_count = pv_size(pv) / vg->extent_size;

 		if (!new_pe_count) {
			log_error("%s: Size must leave space for at "
				  "least one physical extent of "
				  "%" PRIu32 " sectors.", pv_name,
				  pv_pe_size(pv));
			goto out;
		}

		if (!pv_resize(pv, vg, new_pe_count))
			goto_out;
	}

	log_verbose("Resizing volume \"%s\" to %" PRIu64 " sectors.",
		    pv_name, pv_size(pv));

	log_verbose("Updating physical volume \"%s\"", pv_name);
	if (!is_orphan_vg(vg_name)) {
		if (!vg_write(vg) || !vg_commit(vg)) {
			log_error("Failed to store physical volume \"%s\" in "
				  "volume group \"%s\"", pv_name, vg->name);
			goto out;
		}
		backup(vg);
	} else if (!(pv_write(cmd, pv, NULL, INT64_C(-1)))) {
		log_error("Failed to store physical volume \"%s\"",
			  pv_name);
		goto out;
	}

	log_print("Physical volume \"%s\" changed", pv_name);
	r = 1;

out:
	unlock_vg(cmd, vg_name);
	if (!old_vg)
		vg_release(vg);
	return r;
}
Beispiel #9
0
/** main function.
 *
 *  man Function
 *
 *  @param	argc	:	파라미터 개수
 *  @param	*argv[]	:	파라미터
 *
 *  @return			S32
 *  @see			o_svcmon_main.c o_svcmon_init.c o_svcmon_func.c
 *
 *  @exception		.
 *  @note			.
 **/
S32 main(S32 argc, S8 *argv[])
{
    S32				isChanged = 0, isHashChg = 0;
    S32				dRet;
    time_t			curtime, oldtime, stattime, nowstat;
    time_t			stattime2, nowstat2;
    st_WatchMsg		*pWATCH;
    st_MonList		*pMonList = NULL, *pOldMonList = NULL;
    st_MonList_1Min	*pMonList1Min = NULL;
    st_SvcMonMsg	*pSvcMonMsg;
    st_MsgQ			stMsgQ;
    st_MsgQSub		*pstMsgQSub = (st_MsgQSub *)&stMsgQ.llMType;

    /* log_print 초기화 */
    log_init(S_SSHM_LOG_LEVEL, getpid(), SEQ_PROC_O_SVCMON, LOG_PATH"/O_SVCMON", "O_SVCMON");

    /* O_SVCMON 초기화 */
    if((dRet = dInitOSVCMON(&pDefHash, &pAMonHash, &pSMonHash, &pThresHash, &pNasIPHash)) < 0) {
        log_print(LOGN_CRI, "[%s][%s.%d] dInitOSVCMON dRet[%d]", __FILE__, __FUNCTION__, __LINE__, dRet);
        exit(0);
    }

    if( (dRet = set_version(S_SSHM_VERSION, SEQ_PROC_O_SVCMON, vERSION)) != 0)
        log_print( LOGN_CRI, "set_version error(ret=%d,idx=%d,ver=%s)", dRet,SEQ_PROC_ALMD,vERSION);

    pMonHash = pAMonHash;
    pNextMonHash = pSMonHash;

    pBaseMonList1Min = &stABaseMonList1Min;
    pNextBaseMonList1Min = &stSBaseMonList1Min;

    log_print(LOGN_CRI, "START O_SVCMON");

    curtime = time(NULL);
    oldtime = time(NULL);
    stattime = curtime / DEF_MON_PERIOD * DEF_MON_PERIOD;

    dMakeThresHash(pThresHash, gWatchFilter);
    dMakeBaseMonList(pMonHash, pNasIPHash, gWatchFilter, &stBaseMonList, pBaseMonList1Min);
    pMonList = pGetNextMonList(gMonTotal, &stBaseMonList);
    pOldMonList = pMonList;
    pMonList1Min = pGetNextMon1MinList(gMonTotal1Min, pBaseMonList1Min);
    //PRINTLOG(LOG_DEBUG, 0, pMonList, pMonList1Min);

    /* MAIN LOOP */
    while(giStopFlag)
    {
        dRet = dIsReceivedMessage(&stMsgQ);
        if(dRet < 0) {
            log_print(LOGN_CRI, "F=%s:%s.%d dIsReceivedMessage dRet=%d", __FILE__, __FUNCTION__, __LINE__, dRet);
            usleep(0);
        } else if(dRet == 100 || dRet == 0) {
            usleep(0);
        } else {

            log_print(LOGN_INFO, "RCV MSG TYPE=%u SVCID=%u MSGID=%u. TOTSIZE[%ld]"
                      , pstMsgQSub->usType, pstMsgQSub->usSvcID, pstMsgQSub->usMsgID, sizeof(st_MsgQSub));

            switch(pstMsgQSub->usType)
            {
            case DEF_SYS:
                switch(pstMsgQSub->usSvcID)
                {
                case SID_STATUS:
                    switch(pstMsgQSub->usMsgID)
                    {
                    case MID_SVC_MONITOR:
                        pWATCH = (st_WatchMsg *)stMsgQ.szBody;
                        dProcMON(pDefHash, pMonHash, pNasIPHash, pWATCH, pMonList, &stBaseMonList, pMonList1Min, pBaseMonList1Min);
//PRINTLOG(LOGN_INFO, 1, pMonList, pMonList1Min);
                        break;
                    default:
                        log_print(LOGN_INFO, "UNKNOWN MSGID TYPE=%u SVCID=%u MSGID=%u",
                                  pstMsgQSub->usType, pstMsgQSub->usSvcID, pstMsgQSub->usMsgID);
                        break;
                    }
                    break;
                case SID_FLT:
                    switch(pstMsgQSub->usMsgID)
                    {
                    case MID_FLT_SVC:
                    case MID_FLT_SCTP:
                    case MID_FLT_EQUIP:
                    case MID_FLT_ACCESS:
                        log_print(LOGN_CRI, "RCV FILTER UPDATE");
                        dMakeBaseMonList(pNextMonHash, pNasIPHash, gWatchFilter, &stBaseMonList, pNextBaseMonList1Min);
                        isChanged = 1;
                        break;
                    case MID_FLT_MON_THRES:
                        log_print(LOGN_CRI, "RCV THRESHOLD UPDATE");
                        dMakeThresHash(pThresHash, gWatchFilter);
                        break;
                    default:
                        log_print(LOGN_INFO, "UNKNOWN MSGID TYPE=%u SVCID=%u MSGID=%u",
                                  pstMsgQSub->usType, pstMsgQSub->usSvcID, pstMsgQSub->usMsgID);
                        break;
                    }
                    break;
                default:
                    log_print(LOGN_INFO, "UNKNOWN SVCID TYPE=%u SVCID=%u MSGID=%u",
                              pstMsgQSub->usType, pstMsgQSub->usSvcID, pstMsgQSub->usMsgID);
                    break;
                }
                break;
            default:
                log_print(LOGN_INFO, "UNKNOWN TYPE TYPE=%u SVCID=%u MSGID=%u",
                          pstMsgQSub->usType, pstMsgQSub->usSvcID, pstMsgQSub->usMsgID);
                break;
            }
        }

        curtime = time(NULL);
        if(curtime != oldtime) {
            nowstat = curtime / DEF_MON_PERIOD * DEF_MON_PERIOD;
            if(stattime != nowstat) {
                /* check alarm */
                dAlarmMON(pThresHash, pMonHash, pMonList, pOldMonList);

                pSvcMonMsg = (st_SvcMonMsg *)stMsgQ.szBody;
                pSvcMonMsg->lTime = pMonList->lTime;
                pSvcMonMsg->uiIdx = gMonTotal->dCurIdx;
                log_print(LOGN_INFO, "MID_SVC_MONITOR: pSvcMonMsg->lTime[%ld] pSvcMonMsg->uiIdx[%u]", pSvcMonMsg->lTime, pSvcMonMsg->uiIdx);
                pstMsgQSub->usType = DEF_SYS;
                pstMsgQSub->usSvcID = SID_STATUS;
                pstMsgQSub->usMsgID = MID_SVC_MONITOR;
                stMsgQ.ucProID = SEQ_PROC_O_SVCMON;
                stMsgQ.usBodyLen = sizeof(st_SvcMonMsg);

                /* send signal to mond */
                if((dRet = dSendMsg(dMONDQID, &stMsgQ)) < 0) {
                    log_print(LOGN_CRI, "F=%s:%s.%d dSendMsg dRet=%d", __FILE__, __FUNCTION__, __LINE__, dRet);
                }

#ifndef _DISABLE_INTERLOCK_DNMS_ /* DNMS interlock disabled by uamyd 20101101 */
                /* send signal to m_svcmon */
                if((dRet = dSendMsg(dMSVCMONQID, &stMsgQ)) < 0) {
                    log_print(LOGN_CRI, "F=%s:%s.%d dSendMsg dRet=%d", __FILE__, __FUNCTION__, __LINE__, dRet);
                }
#endif /* _DISABLE_INTERLOCK_DNMS_ */

//PRINTLOG(LOG_DEBUG, 1, pMonList, pMonList1Min);
                PRINT_FUNC_TIME_CHECK(pFUNC);

                pOldMonList = pMonList;

                /* get next st_MonList */
                pMonList = pGetNextMonList(gMonTotal, &stBaseMonList);
                if(isChanged) {
                    void *p = pMonHash;
                    pMonHash = pNextMonHash;
                    pNextMonHash = p;

                    p = pBaseMonList1Min;
                    pBaseMonList1Min = pNextBaseMonList1Min;
                    pNextBaseMonList1Min = p;

                    isChanged = 0;
                    isHashChg = 1;
                }

                stattime = nowstat;
            }

            nowstat2 = curtime / DEF_MON_PERIOD_1MIN * DEF_MON_PERIOD_1MIN;
            if( stattime2 != nowstat2 ) {
                if(isHashChg) {
                    dAlarmMON1Min(pThresHash, pNextMonHash, pMonList1Min);
                    isHashChg = 0;
                }
                else {
                    dAlarmMON1Min(pThresHash, pMonHash, pMonList1Min);
                }

                pSvcMonMsg = (st_SvcMonMsg *)stMsgQ.szBody;
                pSvcMonMsg->lTime = pMonList1Min->lTime;
                pSvcMonMsg->uiIdx = gMonTotal1Min->dCurIdx;
                log_print(LOGN_INFO, "MID_SVC_MONITOR_1MIN: pSvcMonMsg->lTime[%ld] pSvcMonMsg->uiIdx[%u]", pSvcMonMsg->lTime, pSvcMonMsg->uiIdx);
                pstMsgQSub->usType = DEF_SYS;
                pstMsgQSub->usSvcID = SID_STATUS;
                pstMsgQSub->usMsgID = MID_SVC_MONITOR_1MIN;
                stMsgQ.ucProID = SEQ_PROC_O_SVCMON;
                stMsgQ.usBodyLen = sizeof(st_SvcMonMsg);

                /* send signal to mond */
                if((dRet = dSendMsg(dALMDQID, &stMsgQ)) < 0) {
                    log_print(LOGN_CRI, "F=%s:%s.%d dSendMsg dRet=%d", __FILE__, __FUNCTION__, __LINE__, dRet);
                }

#ifndef _DISABLE_INTERLOCK_DNMS_ /* DNMS interlock disabled by uamyd 20101101 */
                /* send signal to m_svcmon */
                if((dRet = dSendMsg(dMSVCMONQID, &stMsgQ)) < 0) {
                    log_print(LOGN_CRI, "F=%s:%s.%d dSendMsg dRet=%d", __FILE__, __FUNCTION__, __LINE__, dRet);
                }
#endif /* _DISABLE_INTERLOCK_DNMS_ */

                //PRINTLOG(LOG_DEBUG, 1, pMonList, pMonList1Min);
                PRINT_FUNC_TIME_CHECK(pFUNC);
                /* get next st_MonList */
                pMonList1Min = pGetNextMon1MinList(gMonTotal1Min, pBaseMonList1Min);
#if 0
                if(isChanged) {
                    void *p = pMonHash;
                    pMonHash = pNextMonHash;
                    pNextMonHash = p;
                    isChanged = 0;
                }
#endif
                stattime2 = nowstat2;
            }

            oldtime = curtime;
        }
    }

    FinishProgram();

    return 0;
}
int ffmpeg_parse_file_type(play_para_t *am_p, player_file_type_t *type)
{
    AVFormatContext *pFCtx = am_p->pFormatCtx;
	AVStream *sttmp=NULL;
    memset(type, 0, sizeof(*type));
	memset(&am_p->media_info, 0, sizeof(media_info_t));
    if (pFCtx->iformat != NULL) {
        unsigned int i;
        int matroska_flag = 0;
        int vpx_flag = 0;
        int flv_flag = 0;

        type->fmt_string = pFCtx->iformat->name;
        if (!strcmp(type->fmt_string, "matroska,webm")) {
            matroska_flag = 1;
        }
        if (!strcmp(type->fmt_string, "flv")) {
            flv_flag = 1;
        }

        for (i = 0; i < pFCtx->nb_streams; i++) {
            AVStream *st = pFCtx->streams[i];
            if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
                // special process for vp8 vp6 vp6f vp6a video
                if ((st->codec->codec_id == CODEC_ID_VP8) || \
                    (st->codec->codec_id == CODEC_ID_VP6) || \
                    (st->codec->codec_id == CODEC_ID_VP6F) || \
                    (st->codec->codec_id == CODEC_ID_VP6A)) {
                    if (vpx_flag == 0) {
                        sprintf(vpx_string, "%s", (st->codec->codec_id == CODEC_ID_VP8) ? "vp8" : "vp6");
                        vpx_flag = 1;
                    }
                }
                type->video_tracks++;
            } else if (st->codec->codec_type == CODEC_TYPE_AUDIO) {
                type->audio_tracks++;
                sttmp=st;
            } else if (st->codec->codec_type == CODEC_TYPE_SUBTITLE) {
                type->subtitle_tracks++;
            }
        }

		 //--------special process for m4a format with alac codec----------
		 if((type->video_tracks==0) && (type->audio_tracks==1) && (sttmp!=NULL))
		 {    if((strstr(type->fmt_string,"m4a")!=NULL) && (sttmp->codec->codec_id==CODEC_ID_ALAC))
			  {
			      memset(format_string, 0, sizeof(format_string));
			      //memcpy(format_string,"alac",4);
			      sprintf(format_string, "%s","alac");
			      log_print("NOTE: change type->fmt_string=%s to alac\n", type->fmt_string);
			      type->fmt_string = format_string;
			  }
			  if((strstr(type->fmt_string,"aac")!=NULL) && (sttmp->codec->codec_id==CODEC_ID_AAC))
			  {
				unsigned char* buf=pFCtx->pb->buffer;
				log_print("pFCtx->data_offset=%lld %c %c %c %c\n",pFCtx->data_offset,buf[0],buf[1], buf[2],buf[3]);
				if((buf[0]=='A' && buf[1]=='D' && buf[2]=='I' && buf[3]=='F'))
				{
					log_print("the stream is pure adif: set adif_ctrl_flag=1\n");
					am_p->media_info.stream_info.adif_file_flag=1;
				}
			  }
			  if((strstr(type->fmt_string,"asf")!=NULL) && pFCtx->drmcontent )
			  {
				log_print("drm wma detected\n");
			       memset(format_string, 0, sizeof(format_string));
			       sprintf(format_string, "%s","asf-drm");
				type->fmt_string = format_string;

			  }
		 }
	   //-----------------------------------------------------
        // special process for webm/vpx, flv/vp6
        if (matroska_flag || flv_flag || vpx_flag) {
            int length = 0;

            memset(format_string, 0, sizeof(format_string));

            if (matroska_flag == 1) {
                length = sprintf(format_string, "%s", (vpx_flag == 1) ? "webm" : "matroska");
            } else {
                length = sprintf(format_string, "%s", type->fmt_string);
            }

            if (vpx_flag == 1) {
                sprintf(&format_string[length], ",%s", vpx_string);
                memset(vpx_string, 0, sizeof(vpx_string));
            }

            type->fmt_string = format_string;
        }
    }
    return 0;

}
Beispiel #11
0
int main(int argc, char *argv[])
{
	S32				i;
	S32				dRet;
	OFFSET			offset;
	time_t			oldTime, nowTime;

	Capture_Header_Msg	*pCAPHEAD;
	INFO_ETH			*pINFOETH;
	CALL_KEY 			*pCALLKey;
	U8					*pNode;

	UINT 				dSndQID;
	SESSKEY_LIST 		*pstSESSKEYList;
	char 				szLOGPATH[128];
	int 				dLen, PROCNO;
	int 				LastLogTime;
	
	char    vERSION[7] = "R3.0.0";

	/* process name */
	memcpy(&gszMyProc[0], argv[0], strlen(argv[0]));

	dLen = strlen(gszMyProc);
	PROCNO = atoi(&gszMyProc[dLen-1]);
	guiSeqProcID = SEQ_PROC_A_TCP0 + PROCNO;

	/* log_print 초기화 */
	sprintf(szLOGPATH, LOG_PATH"/%s", gszMyProc);
	log_init(S_SSHM_LOG_LEVEL, getpid(), guiSeqProcID, szLOGPATH, gszMyProc);
	
	/* A_TCP 초기화 */
	if((dRet = dInitTcp(&pMEMSINFO, &pTCPHASH, &pTIMER)) < 0) {
		log_print(LOGN_CRI, "[%s][%s.%d] dInitTcp dRet[%d]", __FILE__, __FUNCTION__, __LINE__, dRet);
		exit(0);
	}

	if( (dRet = shm_init(S_SSHM_UTIL, sizeof(DEBUG_INFO), (void**)&pDEBUGINFO)) < 0 ){
		log_print(LOGN_CRI, "FAILED IN shm_init(DEBUG_INFO=%d)", S_SSHM_UTIL);
		exit(0);
	}

	if((dRet = set_version(S_SSHM_VERSION, guiSeqProcID, vERSION)) < 0 ) {
		log_print(LOGN_CRI, "SET_VERSION ERROR(RET=%d,IDX=%d,VER=%s)", dRet, guiSeqProcID, vERSION);
	}
	log_print(LOGN_CRI, "START %s[%d] TCP_SESS_CNT[%d]", gszMyProc, PROCNO, TCP_SESS_CNT);

	/* MAIN LOOP */
	while(giStopFlag)
	{
START_FUNC_TIME_CHECK(pFUNC, 0);
		timerN_invoke(pTIMER);
END_FUNC_TIME_CHECK(pFUNC, 0);

		for(i=0; i < 300; i++) {
			if((offset = gifo_read(pMEMSINFO, gpCIFO, guiSeqProcID)) > 0) {
				pCAPHEAD = (Capture_Header_Msg *)nifo_get_value(pMEMSINFO, CAP_HEADER_NUM, offset);
				pINFOETH = (INFO_ETH *)nifo_get_value(pMEMSINFO, INFO_ETH_NUM, offset);
				pCALLKey = (CALL_KEY *)nifo_get_value(pMEMSINFO, CLEAR_CALL_NUM, offset);
				pNode = nifo_ptr(pMEMSINFO, offset);
				if(pCALLKey) {
					log_print(LOGN_DEBUG, "#### RECEIVE CALL CLEAR MSG IP: %d.%d.%d.%d LASTLOGTIME: %u ", 
							HIPADDR(pCALLKey->uiSrcIP), pCALLKey->uiReserved);
					LastLogTime = pCALLKey->uiReserved;
					pCALLKey->uiReserved = 0;
					if( (pSESSKEYNODE = hasho_find(pSESSKEYINFO, (U8 *)pCALLKey)) != NULL ) {
						log_print(LOGN_INFO, "#### FIND TCP SESSION LIST IP: %d.%d.%d.%d ", HIPADDR(pCALLKey->uiSrcIP));

						pstSESSKEYList = (SESSKEY_LIST *)nifo_ptr(pSESSKEYINFO, pSESSKEYNODE->offset_Data);
						dRet = dDelSessKeyList(pstSESSKEYList, pTCPHASH, pMEMSINFO, LastLogTime, pTIMER);
						if(dRet == 0) {
							hasho_del(pSESSKEYINFO, (U8 *)pCALLKey);
						}
					} else {
						log_print(LOGN_INFO, "#### NOT EXIST CALL IP: %d.%d.%d.%d ", HIPADDR(pCALLKey->uiSrcIP));
					}
					nifo_node_delete(pMEMSINFO, pNode);
				}
				else if((pCAPHEAD == NULL) || (pINFOETH == NULL)) {
					nifo_node_delete(pMEMSINFO, pNode);
				}
				else {
					/* ETC Traffic To A_SIPM */
					//////////////////////////////////////////////////////////////////////////////////////////////////
					if(pINFOETH->usAppCode == SEQ_PROC_A_VT) {////////////////////////////////////////////////////////
						//////////////////////////////////////////////////////////////////////////////////////////////
						log_print(LOGN_DEBUG, "BYPASS ETC TRAFFIC TO A_SIPT");////////////////////////////////////////
						dSend_TCP_Data(pMEMSINFO, SEQ_PROC_A_SIPT, pNode);////////////////////////////////////////////
						//////////////////////////////////////////////////////////////////////////////////////////////
					}
					else if(pINFOETH->stIP.ucProtocol == DEF_PROTOCOL_TCP) {
						if(dProcTcpSess(pMEMSINFO, pTCPHASH, pTIMER, pCAPHEAD, pINFOETH, pNode) < 0) {
							nifo_node_delete(pMEMSINFO, pNode);
						}
					} else {
						if(pCAPHEAD->bRtxType == DEF_FROM_CLIENT)
							dSndQID = dGetProcID(pINFOETH->usAppCode, pINFOETH->stIP.dwSrcIP);
						else
							dSndQID = dGetProcID(pINFOETH->usAppCode, pINFOETH->stIP.dwDestIP);

						dSend_TCP_Data(pMEMSINFO, dSndQID, pNode);
					}
				}
			} else {
				usleep(0);
				break;
			}
		}
#if 0
		nowTime = time(NULL);
		if(nowTime >= oldTime + 60) {
			int hashoCnt = hasho_get_occupied_node_count(pTCPHASH);
			log_print(LOGN_CRI, 
				"SESS CUR=%lld SESS=%lld RNODE=%lld:%.3fMbps SND=%lld HTTP=%lld ONLI=%lld DIFSEQ=%lld UPD=%lld C7=%lld AFT=%lld HASH=%u:%.2f%%", 
				curSessCnt, sessCnt, rcvNodeCnt, (double)((rcvSize * 8) / (((nowTime - oldTime) == 0) ? 1 : (nowTime - oldTime))) / (1024*1024), allSndCnt, httpSndCnt, onlineSndCnt, diffSeqCnt, updateCnt, case7Cnt, afterCnt, hashoCnt, (float)((float)hashoCnt / ((curSessCnt == 0) ? 1 : curSessCnt)) * 100.0);
			rcvNodeCnt = 0;
			rcvSize = 0;
			httpSndCnt = 0;
			onlineSndCnt = 0;
			allSndCnt = 0;
			diffSeqCnt = 0;
			sessCnt = 0;
			updateCnt = 0;
			case7Cnt = 0;
			afterCnt = 0;
			oldTime = nowTime;
PRINT_FUNC_TIME_CHECK(pFUNC);
		}
#endif
		nowTime = time(NULL);
		if(nowTime >= oldTime + 60) {
			memcpy(&pDEBUGINFO->ATCPINFO[PROCNO].ATCPSUBINFO, pATCPSUBINFO, sizeof(ATCP_SUBINFO));
			pDEBUGINFO->ATCPINFO[PROCNO].curtime = nowTime;
			pATCPSUBINFO->rcvNodeCnt = 0;
			pATCPSUBINFO->rcvSize = 0;
			pATCPSUBINFO->httpSndCnt = 0;
			pATCPSUBINFO->delCnt = 0;
			pATCPSUBINFO->allSndCnt = 0;
			pATCPSUBINFO->diffSeqCnt = 0;
			pATCPSUBINFO->sessCnt = 0;
			pATCPSUBINFO->updateCnt = 0;
			oldTime = nowTime;
PRINT_FUNC_TIME_CHECK(pFUNC);
		}
	} /* while-loop end (main) */

	FinishProgram();
	exit(0);
}
Beispiel #12
0
/** 
 * ci_log로 부터 받은 메시지를 처리한다.
 * 
 * @param dLen 
 * @param szBuf 
 * @param pstHeader 
 * @param dSubNo 
 * 
 * @return 
 */
int dHandle_RecvMsg(int dLen, char *szBuf, pst_NTAFTHeader pstHeader, int dSubNo)
{
    int                 	dRet, dProcID, type, size;
	U8						*pNODE, *pDATA;
	LOG_COMMON				*pLOG;

#ifdef _RPPI_MULTI_
    int						dIMSI; /**< IMSI의 뒤에 4자리가 들어갈 변수 */
#endif

    if(pstHeader->llMagicNumber != MAGIC_NUMBER) {
        log_print(LOGN_CRI, "dSendToProc : MAGIC NUMBER ERROR, Will be Reset %llu!=%llu",
			pstHeader->llMagicNumber, MAGIC_NUMBER);
        return -1;
    } /* end of if */

    switch(pstHeader->ucSvcID)
    {
    case SID_LOG:
		if(dSubNo != pstHeader->ucNTAFID && dSubNo != 0) {	
        	log_print(LOGN_WARN, "MSGRCV SVCID=%d MSGID=%d:%s SYSNO=%d:MEM=%d", 
				pstHeader->ucSvcID, pstHeader->ucMsgID, PRINT_DEF_NUM_table_log(pstHeader->ucMsgID), 
				pstHeader->ucNTAFID, dSubNo);
		} else {
        	log_print(LOGN_INFO, "MSGRCV SVCID=%d MSGID=%d:%s SYSNO=%d:MEM=%d", 
				pstHeader->ucSvcID, pstHeader->ucMsgID, 
				(pstHeader->ucMsgID == START_CALL_NUM || pstHeader->ucMsgID == STOP_CALL_NUM 
				|| pstHeader->ucMsgID == START_SERVICE_DEF_NUM) 
				? PRINT_TAG_DEF_ALL_CALL_INPUT(pstHeader->ucMsgID) : PRINT_DEF_NUM_table_log(pstHeader->ucMsgID), 
				pstHeader->ucNTAFID, dSubNo);
		}

		dProcID = SEQ_PROC_A_RPPI; 

		switch(pstHeader->ucMsgID) {
		case START_CALL_NUM:
			type = START_CALL_NUM;
			size = LOG_SIGNAL_SIZE;
			break;
		case START_SERVICE_DEF_NUM:
			type = START_SERVICE_DEF_NUM;
			size = LOG_COMMON_SIZE;
			break;
		case STOP_CALL_NUM:
			type = STOP_CALL_NUM;
			size = LOG_SIGNAL_SIZE;
			break;
		case LOG_DIALUP_SESS_DEF_NUM:
			type = LOG_DIALUP_SESS_DEF_NUM;
			size = LOG_DIALUP_SESS_SIZE;
			break;
		case LOG_SIGNAL_DEF_NUM:
			type = LOG_SIGNAL_DEF_NUM;
			size = LOG_SIGNAL_SIZE;
			break;
		case LOG_TCP_SESS_DEF_NUM:
			type = LOG_TCP_SESS_DEF_NUM;
			size = LOG_TCP_SESS_SIZE;
			break;
        case LOG_HTTP_TRANS_DEF_NUM:
			type = LOG_HTTP_TRANS_DEF_NUM;
			size = LOG_HTTP_TRANS_SIZE;
			break;
        case LOG_RTSP_TRANS_DEF_NUM:
			type = LOG_HTTP_TRANS_DEF_NUM;
			size = LOG_HTTP_TRANS_SIZE;
			break;
        case LOG_PAGE_TRANS_DEF_NUM:
			type = LOG_PAGE_TRANS_DEF_NUM;
			size = LOG_PAGE_TRANS_SIZE;
			break;
        case LOG_ONLINE_TRANS_DEF_NUM:
			type = LOG_ONLINE_TRANS_DEF_NUM;
			size = LOG_ONLINE_TRANS_SIZE;
			break;
        case LOG_JNC_TRANS_DEF_NUM:
			type = LOG_JNC_TRANS_DEF_NUM;
			size = LOG_JNC_TRANS_SIZE;
			break;
        case LOG_IV_DEF_NUM:
			type = LOG_IV_DEF_NUM;
			size = LOG_IV_SIZE;
			break;
        case LOG_VOD_SESS_DEF_NUM:
			type = LOG_VOD_SESS_DEF_NUM;
			size = LOG_VOD_SESS_SIZE;
			break;
		case LOG_SIP_TRANS_DEF_NUM:  		
			type = LOG_SIP_TRANS_DEF_NUM;
			size = LOG_SIP_TRANS_SIZE;
			break;
		case LOG_MSRP_TRANS_DEF_NUM:
			type = LOG_MSRP_TRANS_DEF_NUM;
			size = LOG_MSRP_TRANS_SIZE;
			break;
		case LOG_VT_SESS_DEF_NUM:
			type = LOG_VT_SESS_DEF_NUM;
			size = LOG_VT_SESS_SIZE;
			break;
		case LOG_IM_SESS_DEF_NUM:
			type = LOG_IM_SESS_DEF_NUM;
			size = LOG_IM_SESS_SIZE;
			break;
		case LOG_FTP_DEF_NUM: 
			type = LOG_FTP_DEF_NUM;
			size = LOG_FTP_SIZE;
			break;
		case st_TraceMsgHdr_DEF_NUM: 
			dProcID = SEQ_PROC_M_TRACE;
			type = st_TraceMsgHdr_DEF_NUM;
			size = pstHeader->usBodyLen;
			break;
		case LOG_DNS_DEF_NUM: 
			type = LOG_DNS_DEF_NUM;
			size = LOG_DNS_SIZE;
			break;
		case LOG_INET_DEF_NUM: 
			type = LOG_INET_DEF_NUM;
			size = LOG_INET_SIZE;
			break;
		case LOG_ITCP_SESS_DEF_NUM: 
			type = LOG_ITCP_SESS_DEF_NUM;
			size = LOG_ITCP_SESS_SIZE;
			break;
		case LOG_IHTTP_TRANS_DEF_NUM: 
			type = LOG_IHTTP_TRANS_DEF_NUM;
			size = LOG_IHTTP_TRANS_SIZE;
			break;
		case START_PI_DATA_RECALL_NUM:
			type = START_PI_DATA_RECALL_NUM;
			size = LOG_SIGNAL_SIZE;
			break;
		case START_RP_DATA_RECALL_NUM:
			type = START_RP_DATA_RECALL_NUM;
			size = LOG_SIGNAL_SIZE;
			break;
		case START_PI_SIG_RECALL_NUM:
			type = START_PI_SIG_RECALL_NUM;
			size = LOG_SIGNAL_SIZE;
			break;
		case START_RP_SIG_RECALL_NUM:
			type = START_RP_SIG_RECALL_NUM;
			size = LOG_SIGNAL_SIZE;
			break;
		case STOP_PI_RECALL_NUM:
			type = STOP_PI_RECALL_NUM;
			size = LOG_SIGNAL_SIZE;
			break;
		case STOP_RP_RECALL_NUM:
			type = STOP_RP_RECALL_NUM;
			size = LOG_SIGNAL_SIZE;
			break;
		default :
            log_print(LOGN_CRI, "dSendToProc ERROR : INVALID MSG ID [MID]:[%d] ", pstHeader->ucMsgID);
			return 0;
        }

		if(pstHeader->usBodyLen != size) {
			log_print(LOGN_CRI, "F=%s:%s.%d DIFF SIZE TYPE=%d:%s RCV=%d ORG=%d", 
					__FILE__, __FUNCTION__, __LINE__, type, PRINT_DEF_NUM_table_log(type), pstHeader->usBodyLen, size);
			return 0;
		}

		if((pNODE = nifo_node_alloc(pMEMSINFO)) == NULL) {
			log_print(LOGN_CRI, "F=%s:%s.%d nifo_node_alloc NULL TYPE=%d:%s", 
					__FILE__, __FUNCTION__, __LINE__, type, PRINT_DEF_NUM_table_log(type));
			return 0;
		}
		
		if((pDATA = nifo_tlv_alloc(pMEMSINFO, pNODE, type, size, DEF_MEMSET_OFF)) == NULL) {
			log_print(LOGN_CRI, "F=%s:%s.%d nifo_tlv_alloc NULL TYPE=%d:%s", 
					__FILE__, __FUNCTION__, __LINE__, type, PRINT_DEF_NUM_table_log(type));
			nifo_node_delete(pMEMSINFO, pNODE);
			return 0;
		}

		memcpy(pDATA, szBuf+NTAFT_HEADER_LEN, size);

		if(dProcID == SEQ_PROC_A_RPPI) {
            /**
             * A_ROAM으로 분기하는 부분
             * A_RPPI 멀티시 default 에서 qid를 변경하는 것으로 간단히 처리하겠다.
             */
			pLOG = (LOG_COMMON *)pDATA;
			switch(pLOG->ucBranchID)
			{
			case TYPE_LNS:
			case TYPE_LAC:
			case TYPE_CRX:
            case TYPE_PDIF:
				log_print(LOGN_INFO, "RCV ROAM DATA BRANCHID=%d", pLOG->ucBranchID);
				dProcID = SEQ_PROC_A_ROAM;
				break;
			default:
#ifdef _RPPI_MULTI_
                /**
                 * TODO
                 * IMSI의 뒤에 4자리를 숫자로 변경한후 RPPI의 숫자 만큼 mod한다.
                 * mod수를 배열의 index로 참조한 RPPI Queue ID로 node를 write 하겠다.
                 * IMSI 배열의 SIZE는 16이며 define명은 MAX_MIN_SIZE 이다.
                 * 실제 IMSI의 String size는 15이다.
                 * IMSI의 11번째 index부터 atoi로 넘겨서 IMSI를 Number로 변경하겠다.
                 */
                dIMSI = atoi((char*)&pLOG->szIMSI[11]);
                dProcID = SEQ_PROC_A_RPPI0 + (dIMSI % gARPPICnt);
				log_print(LOGN_INFO, "Send ProcID:%d Index:%d IMSI:%s dIMSI:%d gARPPICnt:%d", dProcID, (dIMSI%gARPPICnt), pLOG->szIMSI, dIMSI, gARPPICnt);
                if(dProcID == -1)
                {
                    log_print(LOGN_CRI, LH" *** CAN'T EVENT *** PROCID=%d, IMSI=%d, A_RPPICnt=%d",
						LT, dProcID, dIMSI, gARPPICnt);
                    nifo_node_delete(pMEMSINFO, pNODE);
                    return 0;
                }
#endif                
				log_print(LOGN_INFO, "RCV DATA BRANCHID=%d", pLOG->ucBranchID);
				break;
			}
		}
		
		if((dRet = gifo_write(pMEMSINFO, gpCIFO, SEQ_PROC_SI_LOG, dProcID, nifo_offset(pMEMSINFO, pNODE))) < 0) {
			log_print(LOGN_CRI, "F=%s:%s.%d gifo_write dRet=%d TYPE=%d:%s",
					__FILE__, __FUNCTION__, __LINE__, dRet, type, PRINT_DEF_NUM_table_log(type));
			nifo_node_delete(pMEMSINFO, pNODE);
			return 0;
		}

        break;
    default:
        log_print(LOGN_CRI, "dSendToProc : SVCID=%d MSGID=%d Not Support Msg", 
			pstHeader->ucSvcID, pstHeader->ucMsgID);
        break;
    } /* end of switch */

    return 0;
} /* end of dSendToProc */
Beispiel #13
0
/*******************************************************************************
 FinishProgram
*******************************************************************************/
void FinishProgram()
{
    log_print( LOGN_CRI, "PROGRAM IS NORMALLY TERMINATED, Cause = %d", gdFinishFlag);
    exit(0);
}
Beispiel #14
0
/*******************************************************************************
 IGNORE SIGNAL
*******************************************************************************/
void IgnoreSignal(int sign)
{
    if (sign != SIGALRM)
        log_print( LOGN_CRI, "UNWANTED SIGNAL IS RECEIVED, signal = %d", sign);
    signal(sign, IgnoreSignal);
}
Beispiel #15
0
bool_t check_string_merge(void) {

	uint64_t total;
	bool_t result = true;
	stringer_t *strings[16];

	mm_set(strings, 0, sizeof(strings));

	strings[0] = st_alloc(PLACER_T | JOINTED | HEAP, 0);
	st_placer_set(strings[0], st_data_get(constant), st_length_get(constant));

	strings[1] = st_merge(NULLER_T | CONTIGUOUS | HEAP, "s", strings[0]);
	strings[2] = st_merge(NULLER_T | JOINTED | HEAP, "s", strings[1]);
	strings[3] = st_merge(BLOCK_T | CONTIGUOUS | HEAP, "s", strings[2]);
	strings[4] = st_merge(BLOCK_T | JOINTED | HEAP, "s", strings[3]);
	strings[5] = st_merge(MANAGED_T | CONTIGUOUS | HEAP, "s", strings[4]);
	strings[6] = st_merge(MANAGED_T | JOINTED | HEAP, "s", strings[5]);
	strings[7] = st_merge(MAPPED_T | JOINTED | HEAP, "s", strings[6]);

	strings[8] = st_merge(NULLER_T | CONTIGUOUS | SECURE, "s", strings[7]);
	strings[9] = st_merge(NULLER_T | JOINTED | SECURE, "s", strings[8]);
	strings[10] = st_merge(BLOCK_T | CONTIGUOUS | SECURE, "s", strings[9]);
	strings[11] = st_merge(BLOCK_T | JOINTED | SECURE, "s", strings[10]);
	strings[12] = st_merge(MANAGED_T | CONTIGUOUS | SECURE, "s", strings[11]);
	strings[13] = st_merge(MANAGED_T | JOINTED | SECURE, "s", strings[12]);
	strings[14] = st_merge(MAPPED_T | JOINTED | SECURE, "s", strings[13]);

	for (int i = 0; i < 15 && strings[i]; i++) {
		for (unsigned int j = total = 0; strings[i] && j < st_length_get(strings[i]); j++) {
			total += *(st_char_get(strings[i]) + j);
		}

		if (total != 5366) {
			result = false;
		}
	}

	if (result) {

		strings[15] = st_merge(MANAGED_T | JOINTED | HEAP, "snsnsnsnsnsnsnsnsnsnsnsnsnsnsnsn", constant, "\n", strings[0], "\n", strings[1], "\n", strings[2], "\n",
				strings[3], "\n", strings[4], "\n", strings[5], "\n", strings[6], "\n", strings[7], "\n", strings[8], "\n", strings[9], "\n", strings[10], "\n", strings[11],
				"\n", strings[12], "\n", strings[13], "\n", strings[14], "\n");

		for (unsigned int i = total = 0; strings[15] && i < st_length_get(strings[15]); i++) {
			total += *(st_char_get(strings[15]) + i);
		}

		if (total != (5376lu * 16lu)) {
			result = false;
		}

	}

	log_print("%28.28s = %s", "merged", result ? "passed" : "failed");

	for (int i = 0; i < 16; i++) {
		if (strings[i])
			st_free(strings[i]);
	}

	return result;

}
Beispiel #16
0
//-----------------------------------------------------------------------------
// either log directly to the file (slow), or buffer and set an event.
void logger(logging_t *log, short int level, const char *format, ...)
{
	char buffer[30], timebuf[48];
	struct timeval tv;
	time_t curtime;
	va_list ap;
	int redo;
	int n;
	struct timeval t = {.tv_sec = DEFAULT_LOG_TIMER, .tv_usec = 0};

	
	assert(log);
	assert(level >= 0);
	assert(format);

	// first check if we should be logging this entry
	if (level <= log->loglevel && log->filename) {

		// calculate the time.
		gettimeofday(&tv, NULL);
		curtime=tv.tv_sec;
		strftime(buffer, 30, "%Y-%m-%d %T.", localtime(&curtime));
		snprintf(timebuf, 48, "%s%06ld ", buffer, tv.tv_usec);

		assert(log->buildbuf);
		assert(log->buildbuf->length == 0);
		assert(log->buildbuf->max > 0);

		// process the string. Apply directly to the buildbuf.  If buildbuf is not
		// big enough, increase the size and do it again.
		redo = 1;
		while (redo) {
			va_start(ap, format);
			n = vsnprintf(log->tmpbuf->data, log->tmpbuf->max, format, ap);
			va_end(ap);

			assert(n > 0);
			if (n > log->tmpbuf->max) {
				// there was not enough space, so we need to increase it, and try again.
				expbuf_shrink(log->tmpbuf, n + 1);
			}
			else {
				assert(n <= log->tmpbuf->max);
				log->tmpbuf->length = n;
				redo = 0;
			}
		}

		// we now have the built string in our tmpbuf.  We need to add it to the complete built buffer.
		assert(log->tmpbuf->length > 0);
		assert(log->buildbuf->length == 0);
			
		expbuf_set(log->buildbuf, timebuf, strlen(timebuf));
		expbuf_add(log->buildbuf, log->tmpbuf->data, log->tmpbuf->length);
		expbuf_add(log->buildbuf, "\n", 1);

		// if evbase is NULL, then we will need to write directly.
		if (log->evbase == NULL) {
			if (log->outbuf->length > 0) {
				log_print(log, log->outbuf);
				expbuf_free(log->outbuf);
			}
			
			log_print(log, log->buildbuf);
		}
		else {
			// we have an evbase, so we need to add our build data to the outbuf.
			expbuf_add(log->outbuf, log->buildbuf->data, log->buildbuf->length);
		
			// if the log_event is null, then we need to set the timeout event.
			if (log->log_event == NULL) {
				#if (_EVENT_NUMERIC_VERSION < 0x02000000)
					log->log_event = calloc(1, sizeof(*log->log_event));
					evtimer_set(log->log_event, log_handler, (void *) log);
					event_base_set(log->evbase, log->log_event);
				#else
					log->log_event = evtimer_new(log->evbase, log_handler, (void *) log);
				#endif
				assert(log->log_event);
				evtimer_add(log->log_event, &t);
			}
		}
		
		
		
		
		expbuf_clear(log->buildbuf);
	}
}


void log_inclevel(logging_t *log)
{
	assert(log);
	log->loglevel ++;
}
Beispiel #17
0
int main(void) {

	if (!mm_sec_start()) {

		log_print("Secure memory pool did not start correctly.");
		return 1;
	}

	else if (sizeof(stringer_t) != 4) {

		log_print("The string options variable should be 4 bytes/32 bits.");
		return 1;
	}

	/*chr_t *data = "Hello world.";
	size_t len = ns_length_get(data);
	stringer_t *place =
		PLACER(data, len);

	log_print("%.*s\n%.*s\n", st_length_int(PLACER(data, len)), st_char_get(PLACER(data, len)),	st_length_int((stringer_t *)place), st_char_get((stringer_t *)place));
	if (st_cmp_cs_eq(PLACER(st_data_get(constant), st_length_get(constant)), constant) || memcmp("Lorem ipsum dolor sit amet, consectetur adipiscing elit.", st_data_get(constant), st_length_get(constant)))
		exit(1);*/

	// Since were intentionally going to trigger errors, disable standard out while doing so.
	log_disable();
	// Check that we can't specify a length greater than the available buffer.
	if (!check_string_logic(MANAGED_T | CONTIGUOUS | HEAP) || !check_string_logic(MANAGED_T | JOINTED | HEAP)	|| !check_string_logic(MAPPED_T | JOINTED | HEAP)) {
		log_print("--------------------------------------- LOGIC -------------------------------------------\n");
		log_print("String logic checks failed.");
		return 1;
	}
	log_enable();

	log_print("--------------------------------------- CONSTANT ----------------------------------------\n%28.28s = %.*s",
			"constant[fixed+contiguous]", st_length_int(constant), st_char_get(constant));

	log_print("--------------------------------------- IMPORT ------------------------------------------");
	if (!check_string_import()) {
		log_print("Import check failed.");
		return 1;
	}

	// Begin allocation checks.
	log_print("--------------------------------------- ALLOCATION --------------------------------------");

	if (!check_string_alloc("nuller[heap+contiguous]", NULLER_T | CONTIGUOUS | HEAP) || !check_string_alloc("block[heap+contiguous]", BLOCK_T | CONTIGUOUS | HEAP)
			|| !check_string_alloc("managed[heap+contiguous]", MANAGED_T | CONTIGUOUS | HEAP)) {
		log_print("Standard allocation checks failed.");
		return 1;
	}

	if (!check_string_alloc("nuller[heap+jointed]", NULLER_T | JOINTED | HEAP) || !check_string_alloc("block[heap+jointed]", BLOCK_T | JOINTED | HEAP)
			|| !check_string_alloc("managed[heap+jointed]", MANAGED_T | JOINTED | HEAP) || !check_string_alloc("mapped[heap+jointed]", MAPPED_T | JOINTED | HEAP)) {
		log_print("Jointed allocation checks failed.");
		return 1;
	}

	if (!check_string_alloc("nuller[secure+contiguous]", NULLER_T | CONTIGUOUS | SECURE) || !check_string_alloc("block[secure+contiguous]", BLOCK_T | CONTIGUOUS | SECURE)
			|| !check_string_alloc("managed[secure+contiguous]", MANAGED_T | CONTIGUOUS | SECURE)) {
		log_print("Secure allocation of contiguous types failed.");
		return 1;
	}

	if (!check_string_alloc("nuller[secure+jointed]", NULLER_T | JOINTED | SECURE) || !check_string_alloc("block[secure+jointed]", BLOCK_T | JOINTED | SECURE)
			|| !check_string_alloc("managed[secure+jointed]", MANAGED_T | JOINTED | SECURE) || !check_string_alloc("mapped[secure+jointed]", MAPPED_T | JOINTED | SECURE)) {
		log_print("Secure allocation of jointed types failed.");
		return 1;
	}

	// Begin reallocation checks.
	log_print("-------------------------------------- REALLOCATION -------------------------------------");

	if (!check_string_realloc("nuller[heap+contiguous]", NULLER_T | CONTIGUOUS | HEAP) || !check_string_realloc("block[heap+contiguous]", BLOCK_T | CONTIGUOUS | HEAP)
			|| !check_string_realloc("managed[heap+contiguous]", MANAGED_T | CONTIGUOUS | HEAP)) {
		log_print("Standard reallocation checks failed.");
		return 1;
	}

	if (!check_string_realloc("nuller[heap+jointed]", NULLER_T | JOINTED | HEAP) || !check_string_realloc("block[heap+jointed]", BLOCK_T | JOINTED | HEAP)
			|| !check_string_realloc("managed[heap+jointed]", MANAGED_T | JOINTED | HEAP) || !check_string_realloc("mapped[heap+jointed]", MAPPED_T | JOINTED | HEAP)) {
		log_print("Jointed reallocation checks failed.");
		return 1;
	}

	if (!check_string_realloc("nuller[secure+contiguous]", NULLER_T | CONTIGUOUS | SECURE) || !check_string_realloc("block[secure+contiguous]", BLOCK_T | CONTIGUOUS
			| SECURE) || !check_string_realloc("managed[secure+contiguous]", MANAGED_T | CONTIGUOUS | SECURE)) {
		log_print("Secure reallocation of contiguous types failed.");
		return 1;
	}

	if (!check_string_realloc("nuller[secure+jointed]", NULLER_T | JOINTED | SECURE) || !check_string_realloc("block[secure+jointed]", BLOCK_T | JOINTED | SECURE)
			|| !check_string_realloc("managed[secure+jointed]", MANAGED_T | JOINTED | SECURE) || !check_string_realloc("mapped[secure+jointed]", MAPPED_T | JOINTED | SECURE)) {
		log_print("Secure reallocation of jointed types failed.");
		return 1;
	}

	// Begin duplication checks.
	log_print("-------------------------------------- DUPLICATION --------------------------------------");

	if (!check_string_dupe("nuller[heap+contiguous]", NULLER_T | CONTIGUOUS | HEAP) || !check_string_dupe("block[heap+contiguous]", BLOCK_T | CONTIGUOUS | HEAP)
			|| !check_string_dupe("managed[heap+contiguous]", MANAGED_T | CONTIGUOUS | HEAP)) {
		log_print("Standard duplication checks failed.");
		return 1;
	}

	if (!check_string_dupe("nuller[heap+jointed]", NULLER_T | JOINTED | HEAP) || !check_string_dupe("block[heap+jointed]", BLOCK_T | JOINTED | HEAP) || !check_string_dupe(
			"managed[heap+jointed]", MANAGED_T | JOINTED | HEAP) || !check_string_dupe("mapped[heap+jointed]", MAPPED_T | JOINTED | HEAP)) {
		log_print("Jointed duplication checks failed.");
		return 1;
	}

	if (!check_string_dupe("nuller[secure+contiguous]", NULLER_T | CONTIGUOUS | SECURE) || !check_string_dupe("block[secure+contiguous]", BLOCK_T | CONTIGUOUS | SECURE)
			|| !check_string_dupe("managed[secure+contiguous]", MANAGED_T | CONTIGUOUS | SECURE)) {
		log_print("Secure duplication of contiguous types failed.");
		return 1;
	}

	if (!check_string_dupe("nuller[secure+jointed]", NULLER_T | JOINTED | SECURE) || !check_string_dupe("block[secure+jointed]", BLOCK_T | JOINTED | SECURE)
			|| !check_string_dupe("managed[secure+jointed]", MANAGED_T | JOINTED | SECURE) || !check_string_dupe("mapped[secure+jointed]", MAPPED_T | JOINTED | SECURE)) {
		log_print("Secure duplication of jointed types failed.");
		return 1;
	}

	log_print("-------------------------------------- MERGE --------------------------------------------");
	if (!check_string_merge()) {
		log_print("The merge function failed.");
		return 1;
	}

	log_print("-------------------------------------- PRINT --------------------------------------------");
	if (!check_string_print()) {
		log_print("The print function failed.");
		return 1;
	}

	mm_sec_stop();
	log_print("---------------------------------------- FINISHED ---------------------------------------");
	return 0;
}
Beispiel #18
0
static void handle_connection (mailbox_id_type reply_mailbox_id, 
                               realtek_device_type *device)
{
  message_parameter_type message_parameter;
  ipc_structure_type ipc_structure;
  bool done = FALSE;
  unsigned int data_size = 1024;
  u32 *data;

  memory_allocate ((void **) &data, data_size);

  /* Accept the connection. */ 

  ipc_structure.output_mailbox_id = reply_mailbox_id;
  ipc_connection_establish (&ipc_structure);

  message_parameter.data = data;
  message_parameter.block = TRUE;
  message_parameter.protocol = IPC_PROTOCOL_ETHERNET;

  while (!done)
  {
    message_parameter.message_class = IPC_CLASS_NONE;
    message_parameter.length = data_size;
    
    if (ipc_receive (ipc_structure.input_mailbox_id, &message_parameter,
                     &data_size) !=
        STORM_RETURN_SUCCESS)
    {
      continue;
    }

    switch (message_parameter.message_class)
    {
      case IPC_ETHERNET_REGISTER_TARGET:
      {
        /* FIXME: Check if the protocol is already registered */

        device->target[device->number_of_targets].mailbox_id = 
          ipc_structure.output_mailbox_id;
        device->target[device->number_of_targets].protocol_type =
          system_byte_swap_u16 (data[0]);
        device->number_of_targets++;
        break;
      }

      case IPC_ETHERNET_PACKET_SEND:
      {
        if (!realtek_start_transmit ((u8 *) data,
                                    message_parameter.length, device))
        {
          log_print (&log_structure, LOG_URGENCY_ERROR,
                     "Failed to send an ethernet packet.");

          /* FIXME: Do something. */
        }
        break;
      }

      case IPC_ETHERNET_ADDRESS_GET:
      {
        memory_copy (data, &device->ethernet_address, 6);
        message_parameter.length = 6;
        system_call_mailbox_send (ipc_structure.output_mailbox_id,
                                  &message_parameter);
        break;
      }

      default:
      {
        log_print (&log_structure, LOG_URGENCY_ERROR,
                   "Unknown IPC command received.");
        break;
      }
    }
  }
}
Beispiel #19
0
int vgextend(struct cmd_context *cmd, int argc, char **argv)
{
	char *vg_name;
	struct volume_group *vg = NULL;
	int r = ECMD_FAILED;
	struct pvcreate_params pp;

	if (!argc) {
		log_error("Please enter volume group name and "
			  "physical volume(s)");
		return EINVALID_CMD_LINE;
	}

	vg_name = skip_dev_dir(cmd, argv[0], NULL);
	argc--;
	argv++;

	if (arg_count(cmd, metadatacopies_ARG)) {
		log_error("Invalid option --metadatacopies, "
			  "use --pvmetadatacopies instead.");
		return EINVALID_CMD_LINE;
	}
	pvcreate_params_set_defaults(&pp);
	if (!pvcreate_params_validate(cmd, argc, argv, &pp)) {
		return EINVALID_CMD_LINE;
	}

	log_verbose("Checking for volume group \"%s\"", vg_name);
	vg = vg_read_for_update(cmd, vg_name, NULL, 0);
	if (vg_read_error(vg)) {
		vg_release(vg);
		stack;
		return ECMD_FAILED;
	}

	if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) {
		log_error("Can't get lock for orphan PVs");
		unlock_and_release_vg(cmd, vg, vg_name);
		return ECMD_FAILED;
	}

	if (!archive(vg))
		goto_bad;

	/* extend vg */
	if (!vg_extend(vg, argc, argv, &pp))
		goto_bad;

	/* ret > 0 */
	log_verbose("Volume group \"%s\" will be extended by %d new "
		    "physical volumes", vg_name, argc);

	/* store vg on disk(s) */
	if (!vg_write(vg) || !vg_commit(vg))
		goto_bad;

	backup(vg);
	log_print("Volume group \"%s\" successfully extended", vg_name);
	r = ECMD_PROCESSED;

bad:
	unlock_vg(cmd, VG_ORPHANS);
	unlock_and_release_vg(cmd, vg, vg_name);
	return r;
}
Beispiel #20
0
static void handle_8139 (pci_device_info_type *device_info)
{
  unsigned int counter;
  u16 port_base = MAX_U16;
  u16 ports = 0;
  realtek_device_type *device;
  unsigned int physical, physical_index;
  ipc_structure_type ipc_structure;

  system_thread_name_set ("Initialising");
  
  for (counter = 0; counter < PCI_NUMBER_OF_RESOURCES; counter++)
  {
    if ((device_info->resource[counter].flags & PCI_RESOURCE_IO) != 0)
    {
      port_base = device_info->resource[counter].start;
      ports = (device_info->resource[counter].end -
               device_info->resource[counter].start + 1);
    }
  }

  if (port_base == MAX_U16)
  {
    log_print_formatted (&log_structure, LOG_URGENCY_ERROR, 
                         "No port range found -- hardware possibly broken or incompatible?");
    return;
  }

  system_call_port_range_register (port_base, ports, "Realtek 8139");

  memory_allocate ((void **) &device, sizeof (realtek_device_type));

  device->port_base = port_base;
  device->irq = device_info->irq;

  /* Initialise the adapter. */

  system_port_out_u8 (port_base + Config1, 0x00);
  
  if (read_eeprom (port_base, 0) != 0xFFFF) 
  {
    for (counter = 0; counter < 3; counter++) 
    {
      ((u16 *)(device->ethernet_address))[counter] =
        system_little_endian_to_native_u16 (read_eeprom (port_base, 
                                                        counter + 7));
    }
  }
  else 
  {
    for (counter = 0; counter < 6; counter++)
    {
      device->ethernet_address[counter] = 
        system_port_in_u8 (port_base + MAC0 + counter);
    }
  }

  log_print_formatted 
    (&log_structure, LOG_URGENCY_INFORMATIVE,
     "Realtek 8139 at 0x%X, IRQ %d, ethernet address: %02X:%02X:%02X:%02X:%02X:%02X",
     port_base, device_info->irq, device->ethernet_address[0], 
     device->ethernet_address[1], device->ethernet_address[2], 
     device->ethernet_address[3], device->ethernet_address[4],
     device->ethernet_address[5]);

  /* Find the connected MII transceivers. */

  for (physical = 0, physical_index = 0; physical < 32 &&
         physical_index < sizeof (device->mii_address); physical++)
  {
    int mii_status = mdio_read (port_base, physical, 1);

    if (mii_status != 0xFFFF && mii_status != 0x0000) 
    {
      device->mii_address[physical_index] = physical;
      physical_index++;

      log_print_formatted (&log_structure, LOG_URGENCY_INFORMATIVE,
                           "MII transceiver found at address %d.",
                           physical);
    }
  }

  if (physical_index == 0) 
  {
    if (realtek_debug > 1)
    {
      log_print_formatted (&log_structure, LOG_URGENCY_INFORMATIVE,
                           "No MII transceivers found! Assuming SYM "
                           "transceiver.");
    }

    device->mii_address[0] = -1;
  }

  /* Soft reset the chip. */

  system_port_out_u8 (port_base + ChipCommand, CommandReset);

  pci_allocate_buffer ((void **) &device->tx_buffers_dma,
                       (void **) &device->tx_buffers,
                       TX_BUFFER_SIZE * NUMBER_OF_TX_DESCRIPTORS);
  pci_allocate_buffer ((void **) &device->rx_ring_dma,
                       (void **) &device->rx_ring,
                       RX_BUFFER_LENGTH + 16);

  device->tx_full = FALSE;
  device->current_rx = 0;
  device->dirty_tx = device->current_tx = 0;

  for (counter = 0; counter < NUMBER_OF_TX_DESCRIPTORS; counter++) 
  {
    device->tx_buffer[counter] = &device->tx_buffers[counter * TX_BUFFER_SIZE];
  }
  
  /* Check that the chip has finished the reset. */

  for (counter = 0; counter < 1000; counter++)
  {
    if ((system_port_in_u8 (port_base + ChipCommand) & CommandReset) == 0)
    {
      break;
    }
  }

  /* Must enable Tx/Rx before setting transfer thresholds! */

  system_port_out_u8 (port_base + ChipCommand, 
                      CommandRxEnable | CommandTxEnable);
  system_port_out_u32 (port_base + RxConfig, 
                       (RX_FIFO_THRESHOLD << 13) | 
                       (RX_BUFFER_LENGTH_INDEX << 11) | 
                       (RX_DMA_BURST << 8));

  system_port_out_u32 (port_base + TxConfig, (TX_DMA_BURST << 8) | 0x03000000);

  if (device->mii_address[0] >= 0) 
  {
    u16 mii_reg5 = mdio_read (port_base, device->mii_address[0], 5);

    if (mii_reg5 == 0xffff)
    {
    }
    else if ((mii_reg5 & 0x0100) == 0x0100 || (mii_reg5 & 0x00C0) == 0x0040)
    {
      device->full_duplex = TRUE;
    }

    log_print_formatted (&log_structure, LOG_URGENCY_INFORMATIVE,
                         "Setting %s%s-duplex based on"
                         " auto-negotiated partner ability %4.4x.\n",
                         mii_reg5 == 0 ? "" :
                         ((mii_reg5 & 0x0180) != 0) ? "100 Mbps " : 
                         "10 Mbps ",
                         device->full_duplex ? "full" : "half", mii_reg5);
  }
  
  system_port_out_u8 (port_base + Config9346, 0xC0);
  system_port_out_u8 (port_base + Config1, device->full_duplex ? 0x60 : 0x20);
  system_port_out_u8 (port_base + Config9346, 0x00);

  system_port_out_u32 (port_base + RxBuffer, (u32) device->rx_ring_dma);
  
  /* Start the chip's Tx and Rx process. */
  
  system_port_out_u32 (port_base + RxMissed, 0);
  set_rx_mode (device);
  
  system_port_out_u8 (port_base + ChipCommand,
                      CommandRxEnable | CommandTxEnable);
  
  /* Enable all known interrupts by setting the interrupt mask. */
  
  system_port_out_u16 (port_base + InterruptMask,
                       PCIError | PCSTimeout | RxUnderrun | RxOverflow | 
                       RxFIFOOverrun | TxError | TxOK | RxError | RxOK);


  if (system_thread_create () == SYSTEM_RETURN_THREAD_NEW)
  {
    system_thread_name_set ("IRQ handler");

    if (system_call_irq_register (device_info->irq, "Realtek 8139") != 
        SYSTEM_RETURN_SUCCESS)
    {
      log_print_formatted (&log_structure, LOG_URGENCY_EMERGENCY, 
                           "Couldn't set up IRQ handler");
      return;
    }

    /* Loop and handle interrupts. */
    
    while (TRUE)
    {
      int bogus_count = max_interrupt_work;
      unsigned status, link_changed = 0;
      
      system_call_irq_wait (device->irq);
      
      do 
      {
        status = system_port_in_u16 (port_base + InterruptStatus);
        
        /* Acknowledge all of the current interrupt sources ASAP, but
           an first get an additional status bit from CSCR. */
        
        if ((status & RxUnderrun) && 
            system_port_in_u16 (port_base + CSCR) & CSCR_LinkChangeBit)
        {
          link_changed = 1;
        }
        
        system_port_out_u16 (port_base + InterruptStatus, status);
        
        if ((status & (PCIError | PCSTimeout | RxUnderrun | RxOverflow | 
                       RxFIFOOverrun | TxError | TxOK | RxError | RxOK)) == 0)
        {
          break;
        }
        
        /* Rx interrupt. */
        
        if ((status & (RxOK | RxUnderrun | RxOverflow | RxFIFOOverrun)) != 0)
        {
          realtek_receive (device);
        }
        
        if ((status & (TxOK | TxError)) != 0) 
        {
          unsigned int dirty_tx = device->dirty_tx;
          
          while (device->current_tx - dirty_tx > 0) 
          {
            int entry = dirty_tx % NUMBER_OF_TX_DESCRIPTORS;
            int txstatus = system_port_in_u32 (port_base + TxStatus0 +
                                               entry * 4);
            
            if ((txstatus & (TxStatusOK | TxUnderrun | TxAborted)) == 0)
            {
              /* It still hasn't been transmitted. */
              
              break;
            }
            
            /* Note: TxCarrierLost is always asserted at 100 Mbps. */
            
            if ((txstatus & (TxOutOfWindow | TxAborted)) != 0)
            {
              /* There was an major error, log it. */
              
              // device->stats.tx_errors++;

              if ((txstatus & TxAborted) != 0)
              {
                // tp->stats.tx_aborted_errors++;

                system_port_out_u32 (port_base + TxConfig, 
                                     (TX_DMA_BURST << 8) | 0x03000001);
              }
              
              if ((txstatus & TxCarrierLost) != 0)
              {
                // tp->stats.tx_carrier_errors++;
              }
              
              if ((txstatus & TxOutOfWindow) != 0)
              {
                // tp->stats.tx_window_errors++;
              }
            }
            else 
            {
              if ((txstatus & TxUnderrun) != 0)
              {
                /* Add 64 to the Tx FIFO threshold. */
                
                if (device->tx_flag < 0x00300000)
                {
                  device->tx_flag += 0x00020000;
                }
                
                // tp->stats.tx_fifo_errors++;
              }
              
              // tp->stats.collisions += (txstatus >> 24) & 15;
              // tp->stats.tx_bytes += txstatus & 0x7ff;
              // tp->stats.tx_packets++;
            }
            
            // if (tp->tx_info[entry].mapping != 0)
            // {
            //   pci_unmap_single (tp->pdev,
            //                     tp->tx_info[entry].mapping,
            //                     tp->tx_info[entry].skb->len,
            //                     PCI_DMA_TODEVICE);
            // tp->tx_info[entry].mapping = 0;
            // }
          
            /* Free the original skb. */
            
            // dev_kfree_skb_irq (tp->tx_info[entry].skb);
            //          tp->tx_info[entry].skb = NULL;
            
            if (device->tx_full) 
            {
              /* The ring is no longer full, wake the queue. */
              
              device->tx_full = FALSE;
              
              // netif_wake_queue(dev);
            }
            
            dirty_tx++;
          }
          
          device->dirty_tx = dirty_tx;
        }
        
        /* Check uncommon events with one test. */
        
        if ((status & (PCIError | PCSTimeout | RxUnderrun | RxOverflow | 
                       RxFIFOOverrun | TxError | RxError)) != 0)
        {
          if (realtek_debug > 2)
          {
            log_print_formatted (&log_structure, LOG_URGENCY_WARNING,
                                 "Abnormal interrupt, status %8.8x.\n",
                                 status);
          }
          
          if (status == 0xFFFFFFFF)
          {
            break;
          }
          
          /* Update the error count. */
          
          // tp->stats.rx_missed_errors += inl(port_base + RxMissed);
          system_port_out_u32 (port_base + RxMissed, 0);
          
          if ((status & RxUnderrun) != 0 && link_changed)
          {
            /* Really link-change on new chips. */
            
            int lpar = system_port_in_u16 (port_base + NWayLPAR);
            int duplex = (lpar & 0x0100) || (lpar & 0x01C0) == 0x0040; 
            
            if (device->full_duplex != duplex) 
            {
              device->full_duplex = duplex;
              
              system_port_out_u8 (port_base + Config9346, 0xC0);
              system_port_out_u8 (port_base + Config1, 
                                  device->full_duplex ? 0x60 : 0x20);
              system_port_out_u8 (port_base + Config9346, 0x00);
            }
            status &= ~RxUnderrun;
          }
          
          if ((status & (RxUnderrun | RxOverflow | RxError |
                         RxFIFOOverrun)) != 0)
          {
            // tp->stats.rx_errors++;
          }
          
          if ((status & (PCSTimeout)) != 0)
          {
            // tp->stats.rx_length_errors++;
          }
          
          if ((status & (RxUnderrun | RxFIFOOverrun)) != 0)
          {
            //  tp->stats.rx_fifo_errors++;
          }
          
          if ((status & RxOverflow) != 0)
          {
            // tp->stats.rx_over_errors++;
            device->current_rx =
              (system_port_in_u16 (port_base + RxBufferAddress) % 
               RX_BUFFER_LENGTH);
            system_port_out_u16 (port_base + RxBufferPointer, device->current_rx - 16);
          }
          
          if ((status & PCIError) != 0) 
          {
            log_print (&log_structure, LOG_URGENCY_WARNING, "PCI Bus error.");
          }
        }
        
        if (--bogus_count < 0) 
        {
          log_print_formatted (&log_structure, LOG_URGENCY_WARNING,
                               "Too much work at interrupt, "
                               "InterruptStatus = 0x%4.4x.",
                               status);
          
          /* Clear all interrupt sources. */
          
          system_port_out_u16 (port_base + InterruptStatus, 0xFFFF);
          break;
        }
      } while (TRUE);
      
      system_call_irq_acknowledge (device->irq);
    }
  }

  /* Now, use the remaining thread for the service handler. */

  system_thread_name_set ("Service handler");

  /* Create the service. */

  if (ipc_service_create ("ethernet", &ipc_structure, &empty_tag) !=
      IPC_RETURN_SUCCESS)
  {
    log_print (&log_structure, LOG_URGENCY_EMERGENCY,
               "Couldn't create ethernet service.");
    return;
  }

  while (TRUE)
  {
    mailbox_id_type reply_mailbox_id;

    ipc_service_connection_wait (&ipc_structure);
    reply_mailbox_id = ipc_structure.output_mailbox_id;

    if (system_thread_create () == SYSTEM_RETURN_THREAD_NEW)
    {
      system_call_thread_name_set ("Handling connection");
      handle_connection (reply_mailbox_id, device);
    }
  }    
}
Beispiel #21
0
static gint smtp_auth_recv(SMTPSession *session, const gchar *msg)
{
	gchar buf[MESSAGEBUFSIZE], *tmp;

	switch (session->auth_type) {
	case SMTPAUTH_LOGIN:
		session->state = SMTP_AUTH_LOGIN_USER;

		if (!strncmp(msg, "334 ", 4)) {
			tmp = g_base64_encode(session->user, strlen(session->user));

			if (session_send_msg(SESSION(session), SESSION_MSG_NORMAL,
					 tmp) < 0) {
				g_free(tmp);
				return SM_ERROR;
			}
			g_free(tmp);
			log_print(LOG_PROTOCOL, "ESMTP> [USERID]\n");
		} else {
			/* Server rejects AUTH */
			if (session_send_msg(SESSION(session), SESSION_MSG_NORMAL,
					 "*") < 0)
				return SM_ERROR;
			log_print(LOG_PROTOCOL, "ESMTP> *\n");
		}
		break;
	case SMTPAUTH_CRAM_MD5:
		session->state = SMTP_AUTH_CRAM_MD5;

		if (!strncmp(msg, "334 ", 4)) {
			gchar *response;
			gchar *response64;
			gchar *challenge;
			gsize challengelen;
			guchar hexdigest[33];

			challenge = g_base64_decode_zero(msg + 4, &challengelen);
			log_print(LOG_PROTOCOL, "ESMTP< [Decoded: %s]\n", challenge);

			g_snprintf(buf, sizeof(buf), "%s", session->pass);
			md5_hex_hmac(hexdigest, challenge, challengelen,
				     buf, strlen(session->pass));
			g_free(challenge);

			response = g_strdup_printf
				("%s %s", session->user, hexdigest);
			log_print(LOG_PROTOCOL, "ESMTP> [Encoded: %s]\n", response);

			response64 = g_base64_encode(response, strlen(response));
			g_free(response);

			if (session_send_msg(SESSION(session), SESSION_MSG_NORMAL,
					 response64) < 0) {
				g_free(response64);
				return SM_ERROR;
			}
			log_print(LOG_PROTOCOL, "ESMTP> %s\n", response64);
			g_free(response64);
		} else {
			/* Server rejects AUTH */
			if (session_send_msg(SESSION(session), SESSION_MSG_NORMAL,
					 "*") < 0)
				return SM_ERROR;
			log_print(LOG_PROTOCOL, "ESMTP> *\n");
		}
		break;
	case SMTPAUTH_DIGEST_MD5:
        default:
        	/* stop smtp_auth when no correct authtype */
		if (session_send_msg(SESSION(session), SESSION_MSG_NORMAL, "*") < 0)
			return SM_ERROR;
		log_print(LOG_PROTOCOL, "ESMTP> *\n");
		break;
	}

	return SM_OK;
}
Beispiel #22
0
static void
parse_args (int argc, char *argv[])
{
  int ch;
  char *ep;
#ifdef USE_DEBUG
  int cls, level;
  int do_packetlog = 0;
#endif

  while ((ch = getopt (argc, argv, "46c:dD:f:i:np:P:Ll:r:R:v")) != -1) {
    switch (ch) {
    case '4':
      bind_family |= BIND_FAMILY_INET4;
      break;

    case '6':
      bind_family |= BIND_FAMILY_INET6;
      break;

    case 'c':
      conf_path = optarg;
      break;

    case 'd':
      debug++;
      break;

#ifdef USE_DEBUG
    case 'D':
      if (sscanf (optarg, "%d=%d", &cls, &level) != 2)
	{
	    if (sscanf (optarg, "A=%d", &level) == 1)
	      {
		  for (cls = 0; cls < LOG_ENDCLASS; cls++)
		    log_debug_cmd (cls, level);
	      }
	    else
	      log_print ("parse_args: -D argument unparseable: %s", optarg);
	}
      else
	log_debug_cmd (cls, level);
      break;
#endif /* USE_DEBUG */

    case 'f':
      ui_fifo = optarg;
      break;

    case 'i':
      pid_file = optarg;
      break;

    case 'n':
      app_none++;
      break;

    case 'p':
      udp_default_port = optarg;
      break;

    case 'P':
      udp_bind_port = optarg;
      break;

#ifdef USE_DEBUG
    case 'l':
      pcap_file = optarg;
      /* Fallthrough intended.  */

    case 'L':
      do_packetlog++;
      break;
#endif /* USE_DEBUG */

    case 'r':
      seed = strtoul (optarg, &ep, 0);
      srandom (seed);
      if (*ep != '\0')
	log_fatal ("parse_args: invalid numeric arg to -r (%s)", optarg);
      regrand = 1;
      break;

    case 'R':
      report_file = optarg;
      break;

    case 'v':
      verbose_logging = 1;
      break;

    case '?':
    default:
      usage ();
    }
  }
  argc -= optind;
  argv += optind;

#ifdef USE_DEBUG
  if (do_packetlog && !pcap_file)
    pcap_file = PCAP_FILE_DEFAULT;
#endif
}
Beispiel #23
0
struct stat_cache_value *stat_cache_value_get(stat_cache_t *cache, const char *path, bool skip_freshness_check) {
    struct stat_cache_value *value = NULL;
    char *key;
    leveldb_readoptions_t *options;
    size_t vallen;
    char *errptr = NULL;
    //void *f;
    time_t current_time;

    key = path2key(path, false);

    log_print(LOG_DEBUG, "CGET: %s", key);

    options = leveldb_readoptions_create();
    value = (struct stat_cache_value *) leveldb_get(cache, options, key, strlen(key) + 1, &vallen, &errptr);
    leveldb_readoptions_destroy(options);
    free(key);

    //log_print(LOG_DEBUG, "Mode: %04o", value->st.st_mode);

    if (errptr != NULL) {
        log_print(LOG_ERR, "leveldb_get error: %s", errptr);
        free(errptr);
        return NULL;
    }

    if (value == NULL) {
        log_print(LOG_DEBUG, "stat_cache_value_get miss on path: %s", path);
        return NULL;
    }

    if (vallen != sizeof(struct stat_cache_value)) {
        log_print(LOG_ERR, "Length %lu is not expected length %lu.", vallen, sizeof(struct stat_cache_value));
    }

    if (!skip_freshness_check) {
        current_time = time(NULL);

        // First, check against the stat item itself.
        //log_print(LOG_DEBUG, "Current time: %lu", current_time);
        if (current_time - value->updated > CACHE_TIMEOUT) {
            char *directory;
            time_t directory_updated;
            int is_dir;

            log_print(LOG_DEBUG, "Stat entry %s is %lu seconds old.", path, current_time - value->updated);

            // If that's too old, check the last update of the directory.
            directory = strip_trailing_slash(ne_path_parent(path), &is_dir);
            directory_updated = stat_cache_read_updated_children(cache, directory);
            //log_print(LOG_DEBUG, "Directory contents for %s are %lu seconds old.", directory, (current_time - directory_updated));
            free(directory);
            if (current_time - directory_updated > CACHE_TIMEOUT) {
                log_print(LOG_DEBUG, "%s is too old.", path);
                free(value);
                return NULL;
            }
        }
    }

    /*
    if ((f = file_cache_get(path))) {
        value->st.st_size = file_cache_get_size(f);
        file_cache_unref(cache, f);
    }
    */

    //print_stat(&value->st, "CGET");

    return value;
}
Beispiel #24
0
int
main (int argc, char *argv[])
{
  fd_set *rfds, *wfds;
  int n, m;
  size_t mask_size;
  struct timeval tv, *timeout;

  /* Make sure init() won't alloc fd 0, 1 or 2, as daemon() will close them. */
  for (n = 0; n <= 2; n++)
    if (fcntl (n, F_GETFL, 0) == -1 && errno == EBADF)
      (void)open ("/dev/null", n ? O_WRONLY : O_RDONLY, 0);

  /* Log cmd line parsing and initialization errors to stderr.  */
  log_to (stderr);
  parse_args (argc, argv);
  log_init ();

  /* Do a clean daemon shutdown on TERM reception. (Needed by monitor).  */
  signal (SIGTERM, daemon_shutdown_now);
  if (debug) signal (SIGINT, daemon_shutdown_now);

#if defined (USE_PRIVSEP)
  if (monitor_init ())
    {
      /* The parent, with privileges.  */
      if (!debug)
	if (daemon (0, 0))
	  log_fatal ("main [priv]: daemon (0, 0) failed");

      /* Enter infinite monitor loop.  */
      monitor_loop (debug);
      exit (0); /* Never reached.  */
    }

  /* Child process only from this point on, no privileges left.  */
#endif

  init ();

  if (!debug)
    {
      if (daemon (0, 0))
	log_fatal ("main: daemon (0, 0) failed");
      /* Switch to syslog.  */
      log_to (0);
    }

  write_pid_file ();

  /* Reinitialize on HUP reception.  */
  signal (SIGHUP, sighup);

  /* Report state on USR1 reception.  */
  signal (SIGUSR1, sigusr1);

  /* Rehash soft expiration timers on USR2 reception.  */
  signal (SIGUSR2, sigusr2);

#if defined (USE_DEBUG)
  /* If we wanted IKE packet capture to file, initialize it now.  */
  if (pcap_file != 0)
    log_packet_init (pcap_file);
#endif

  /* Allocate the file descriptor sets just big enough.  */
  n = getdtablesize ();
  mask_size = howmany (n, NFDBITS) * sizeof (fd_mask);
  rfds = (fd_set *)malloc (mask_size);
  if (!rfds)
    log_fatal ("main: malloc (%lu) failed", (unsigned long)mask_size);
  wfds = (fd_set *)malloc (mask_size);
  if (!wfds)
    log_fatal ("main: malloc (%lu) failed", (unsigned long)mask_size);

  while (1)
    {
      /* If someone has sent SIGHUP to us, reconfigure.  */
      if (sighupped)
	{
	  log_print ("SIGHUP received");
	  reinit ();
	  sighupped = 0;
	}

      /* and if someone sent SIGUSR1, do a state report.  */
      if (sigusr1ed)
	{
	  log_print ("SIGUSR1 received");
	  report ();
	}

      /* and if someone sent SIGUSR2, do a timer rehash.  */
      if (sigusr2ed)
	{
	  log_print ("SIGUSR2 received");
	  rehash_timers ();
	}

      /*
       * and if someone set 'sigtermed' (SIGTERM or via the UI), this
       * indicated we should start a shutdown of the daemon.
       *
       * Note: Since _one_ message is sent per iteration of this enclosing
       * while-loop, and we want to send a number of DELETE notifications,
       * we must loop atleast this number of times. The daemon_shutdown()
       * function starts by queueing the DELETEs, all other calls just
       * increments the 'sigtermed' variable until it reaches a "safe"
       * value, and the daemon exits.
       */
      if (sigtermed)
	daemon_shutdown ();

      /* Setup the descriptors to look for incoming messages at.  */
      memset (rfds, 0, mask_size);
      n = transport_fd_set (rfds);
      FD_SET (ui_socket, rfds);
      if (ui_socket + 1 > n)
	n = ui_socket + 1;

      /*
       * XXX Some day we might want to deal with an abstract application
       * class instead, with many instantiations possible.
       */
      if (!app_none && app_socket >= 0)
	{
	  FD_SET (app_socket, rfds);
	  if (app_socket + 1 > n)
	    n = app_socket + 1;
	}

      /* Setup the descriptors that have pending messages to send.  */
      memset (wfds, 0, mask_size);
      m = transport_pending_wfd_set (wfds);
      if (m > n)
	n = m;

      /* Find out when the next timed event is.  */
      timeout = &tv;
      timer_next_event (&timeout);

      n = select (n, rfds, wfds, 0, timeout);
      if (n == -1)
	{
	  if (errno != EINTR)
	    {
	      log_error ("select");

	      /*
	       * In order to give the unexpected error condition time to
	       * resolve without letting this process eat up all available CPU
	       * we sleep for a short while.
	       */
	      sleep (1);
	    }
	}
      else if (n)
	{
	  transport_handle_messages (rfds);
	  transport_send_messages (wfds);
	  if (FD_ISSET (ui_socket, rfds))
	    ui_handler ();
	  if (!app_none && app_socket >= 0 && FD_ISSET (app_socket, rfds))
	    app_handler ();
	}
      timer_handle_expirations ();
    }
}
Beispiel #25
0
int PlayerGetAFilterFormat(const char *prop)
{
	char value[1024];
	int filter_fmt = 0;
#ifndef 	USE_ARM_AUDIO_DEC
    /* check the dts/ac3 firmware status */
    if(access("/system/etc/firmware/audiodsp_codec_ddp_dcv.bin",F_OK)){
#ifndef DOLBY_DAP_EN
		filter_fmt |= (FILTER_AFMT_AC3|FILTER_AFMT_EAC3);
#endif
    }
    if(access("/system/etc/firmware/audiodsp_codec_dtshd.bin",F_OK) ){
		filter_fmt  |= FILTER_AFMT_DTS;
    }
#else
    if(access("/system/lib/libstagefright_soft_dcvdec.so",F_OK)){
#ifndef DOLBY_DAP_EN
	filter_fmt |= (FILTER_AFMT_AC3|FILTER_AFMT_EAC3);
#endif
    }
    if(access("/system/lib/libstagefright_soft_dtshd.so",F_OK) ){
		filter_fmt  |= FILTER_AFMT_DTS;
    }
#endif
    if (GetSystemSettingString(prop, value, NULL) > 0) {
		log_print("[%s:%d]disable_adec=%s\n", __FUNCTION__, __LINE__, value);
		if (strstr(value,"mpeg") != NULL || strstr(value,"MPEG") != NULL) {
			filter_fmt |= FILTER_AFMT_MPEG;
		}
		if (strstr(value,"pcms16l") != NULL || strstr(value,"PCMS16L") != NULL) {
			filter_fmt |= FILTER_AFMT_PCMS16L;
		}
		if (strstr(value,"aac") != NULL || strstr(value,"AAC") != NULL) {
			filter_fmt |= FILTER_AFMT_AAC;
		}
		if (strstr(value,"ac3") != NULL || strstr(value,"AC#") != NULL) {
			filter_fmt |= FILTER_AFMT_AC3;
		}
		if (strstr(value,"alaw") != NULL || strstr(value,"ALAW") != NULL) {
			filter_fmt |= FILTER_AFMT_ALAW;
		}
		if (strstr(value,"mulaw") != NULL || strstr(value,"MULAW") != NULL) {
			filter_fmt |= FILTER_AFMT_MULAW;
		}
		if (strstr(value,"dts") != NULL || strstr(value,"DTS") != NULL) {
			filter_fmt |= FILTER_AFMT_DTS;
		}
		if (strstr(value,"pcms16b") != NULL || strstr(value,"PCMS16B") != NULL) {
			filter_fmt |= FILTER_AFMT_PCMS16B;
		}
		if (strstr(value,"flac") != NULL || strstr(value,"FLAC") != NULL) {
			filter_fmt |= FILTER_AFMT_FLAC;
		}
		if (strstr(value,"cook") != NULL || strstr(value,"COOK") != NULL) {
			filter_fmt |= FILTER_AFMT_COOK;
		}
		if (strstr(value,"pcmu8") != NULL || strstr(value,"PCMU8") != NULL) {
			filter_fmt |= FILTER_AFMT_PCMU8;
		}
		if (strstr(value,"adpcm") != NULL || strstr(value,"ADPCM") != NULL) {
			filter_fmt |= FILTER_AFMT_ADPCM;
		}
		if (strstr(value,"amr") != NULL || strstr(value,"AMR") != NULL) {
			filter_fmt |= FILTER_AFMT_AMR;
		}
		if (strstr(value,"raac") != NULL || strstr(value,"RAAC") != NULL) {
			filter_fmt |= FILTER_AFMT_RAAC;
		}
		if (strstr(value,"wma") != NULL || strstr(value,"WMA") != NULL) {
			filter_fmt |= FILTER_AFMT_WMA;
		}
		if (strstr(value,"wmapro") != NULL || strstr(value,"WMAPRO") != NULL) {
			filter_fmt |= FILTER_AFMT_WMAPRO;
		}
		if (strstr(value,"pcmblueray") != NULL || strstr(value,"PCMBLUERAY") != NULL) {
			filter_fmt |= FILTER_AFMT_PCMBLU;
		}
		if (strstr(value,"alac") != NULL || strstr(value,"ALAC") != NULL) {
			filter_fmt |= FILTER_AFMT_ALAC;
		}
		if (strstr(value,"vorbis") != NULL || strstr(value,"VORBIS") != NULL) {
			filter_fmt |= FILTER_AFMT_VORBIS;
		}
		if (strstr(value,"aac_latm") != NULL || strstr(value,"AAC_LATM") != NULL) {
			filter_fmt |= FILTER_AFMT_AAC_LATM;
		}
		if (strstr(value,"ape") != NULL || strstr(value,"APE") != NULL) {
			filter_fmt |= FILTER_AFMT_APE;
		}
		if (strstr(value,"eac3") != NULL || strstr(value,"EAC3") != NULL) {
			filter_fmt |= FILTER_AFMT_EAC3;
		}
    }
	log_print("[%s:%d]filter_afmt=%x\n", __FUNCTION__, __LINE__, filter_fmt);
    return filter_fmt;
}
Beispiel #26
0
/**
 * Set Cwnd limit
 * @param connarg tcp_stat_connection pointer
 * @param group_arg tcp_stat group pointer
 * @param agentarg tcp_stat agent pointer
 * */
void setCwndlimit(tcp_stat_connection connarg, tcp_stat_group* grouparg,
                  tcp_stat_agent* agentarg, Options* optionsarg) {
#if USE_WEB100
    web100_var *LimRwin, *yar;
#elif USE_WEB10G
    struct estats_val yar;
#endif

    u_int32_t limrwin_val;

    if (optionsarg->limit > 0) {
        log_print(1, "Setting Cwnd limit - ");

#if USE_WEB100
        if (connarg != NULL) {
            log_println(1,
                        "Got web100 connection pointer for recvsfd socket\n");
            char yuff[32];
            web100_agent_find_var_and_group(agentarg, "CurMSS", &grouparg,
                                            &yar);
            web100_raw_read(yar, connarg, yuff);
            log_println(1, "MSS = %s, multiplication factor = %d",
                        web100_value_to_text(web100_get_var_type(yar), yuff),
                        optionsarg->limit);
            limrwin_val = optionsarg->limit
                          * (atoi(
                                 web100_value_to_text(web100_get_var_type(yar),
                                         yuff)));
            web100_agent_find_var_and_group(agentarg, "LimRwin", &grouparg,
                                            &LimRwin);
            log_print(1, "now write %d to limit the Receive window",
                      limrwin_val);
            web100_raw_write(LimRwin, connarg, &limrwin_val);
#elif USE_WEB10G
        if (connarg != -1) {
            log_println(1,
                        "Got web10g connection for recvsfd socket\n");
            web10g_get_val(agentarg, connarg, "CurMSS", &yar);
            log_println(1, "MSS = %s, multiplication factor = %d",
                        yar.uv32, optionsarg->limit);
            limrwin_val = optionsarg->limit * yar.uv32;
            log_print(1, "now write %d to limit the Receive window", limrwin_val);
            estats_write_var("LimRwin", limrwin_val, connarg, agentarg);
#endif
            log_println(1, "  ---  Done");
        }
    }
}

/**
 * Check if receiver is clogged and use decision to temporarily
 * stop sending packets.
 * @param nextseqtosend integer indicating the Next Sequence Number To Be Sent
 * @param lastunackedseq integer indicating the oldest un-acked sequence number
 * @return integer indicating whether buffer is clogged
 * */
int is_buffer_clogged(int nextseqtosend, int lastunackedseq) {
    int recclog = 0;
    if ((RECLTH << 2) < (nextseqtosend - lastunackedseq - 1)) {
        recclog = 1;
    }
    return recclog;
}
Beispiel #27
0
/** main function.
 *
 *  man Function
 *
 *  @param	argc	:	파라미터 개수
 *  @param	*argv[]	:	파라미터
 *
 *  @return			S32
 *  @see			msrp_main.c
 *
 *  @exception		.
 *  @note			.
 **/
S32 main(S32 argc, S8 *argv[])
{
	S32				dRet;		/**< 함수 Return 값 */
	OFFSET			offset;
	U8				*pNode;
	U8				*pNextNode;
	U8				*p, *data;
	S32				type, len, ismalloc;
	TEXT_INFO		*pstTEXTINFO;
	U8				*pDATA;

    char    vERSION[7] = "R3.0.0";


	/* log_print 초기화 */
	log_init(S_SSHM_LOG_LEVEL, getpid(), SEQ_PROC_A_MSRPT, LOG_PATH"/A_MSRPT", "A_MSRPT");
	
	/* A_HTTP 초기화 */
	if((dRet = dInitMSRPT(&pstMEMSINFO, &pstMSRPTHASH, &pstTIMERNINFO)) < 0)
	{
		log_print(LOGN_CRI, "F=%s:%s.%d dInitMSRPT dRet=%d", __FILE__, __FUNCTION__, __LINE__, dRet);
		exit(0);
	}

    if((dRet = set_version(S_SSHM_VERSION, SEQ_PROC_A_MSRPT, vERSION)) < 0 ) {
        log_print(LOGN_CRI, "SET_VERSION ERROR(RET=%d,IDX=%d,VER=%s)", dRet, SEQ_PROC_A_MSRPT, vERSION);
    }

	guiTimerValue = flt_info->stTimerInfo.usTimerInfo[PI_MSRP_TIMEOUT];
	log_print(LOGN_CRI, "START MSRPT VER[%s] TRANSCNT[%d] TIMER[%d]", vERSION, MSRPT_TRANS_CNT, guiTimerValue);

	/* MAIN LOOP */
	while(giStopFlag)
	{
		timerN_invoke(pstTIMERNINFO);

		if((offset = gifo_read(pstMEMSINFO, gpCIFO, SEQ_PROC_A_MSRPM)) > 0) {

			log_print(LOGN_INFO, "======================================================================");

			/* DB LOG 전송을 목적으로 하는 NODE (삭제 하지 않고 전송하기 위함 )*/
			pNode = nifo_ptr(pstMEMSINFO, offset);
			pNextNode = pNode;

			pstTEXTINFO = NULL;
			pDATA = NULL;

			do {
				p = pNextNode;

				while(p != NULL) {
					if((dRet = nifo_read_tlv_cont(pstMEMSINFO, pNextNode, (U32*)&type, (U32*)&len, &data, &ismalloc, &p)) < 0)
						break;

					log_print(LOGN_INFO, "####################################################################");
					log_print(LOGN_INFO, "TYPE[%d][%s] LEN[%d] ISMALLOC[%s]", 
						type, PrintType(type), len, 
						(ismalloc == DEF_READ_MALLOC) ? "MALLOC MEM" : "ORIGIN MEM");

					switch(type)
					{
					case ETH_DATA_NUM:
						if(pstTEXTINFO != NULL) {
							pDATA = &data[pstTEXTINFO->offset];
							log_print(LOGN_INFO, "PACKET TYPE[%d]", type);
							log_print(LOGN_INFO, "DATA[%.*s]", pstTEXTINFO->len, pDATA);
						} else {
							log_print(LOGN_CRI, "RCV PACKET_DATA BUT NOT RCV TEXT_INFO");	
						}
						break;
					case TEXT_INFO_DEF_NUM:
						pstTEXTINFO = (TEXT_INFO *)data;
					
						log_print(LOGN_INFO, "TEXT_INFO TYPE[%d]", type);
						log_print(LOGN_INFO, "TEXT_INFO OFFSET[%ld]LEN[%d]S[%u.%u]U[%u.%u]A[%u.%u]", 
							pstTEXTINFO->offset, pstTEXTINFO->len, pstTEXTINFO->uiStartTime, pstTEXTINFO->uiStartMTime,
							pstTEXTINFO->uiLastUpdateTime, pstTEXTINFO->uiLastUpdateMTime, pstTEXTINFO->uiAckTime, 
							pstTEXTINFO->uiAckMTime);
						break;
					/* Ignore Case */
					default:
						log_print(LOGN_INFO, "????? UNKNOWN TYPE[%d]", type);
						break;
					}

					if(ismalloc == DEF_READ_MALLOC){ free(data); }
				}
				
				pNextNode = (U8 *)nifo_entry(nifo_ptr(pstMEMSINFO, ((NIFO *)pNextNode)->nont.offset_next), NIFO, nont);

			} while(pNode != pNextNode);

			if((pstTEXTINFO != NULL) && (pDATA != NULL)) {

				if(dProcMSRPTTrans(pstMEMSINFO, pstMSRPTHASH, pstTIMERNINFO, pstTEXTINFO, pDATA) < 0) {

				}
			}
			nifo_node_delete(pstMEMSINFO, pNode);
		} else {
			usleep(0);
		}
			
	}

	FinishProgram();

	return 0;
}
static int stream_ts_init(play_para_t *p_para)
{
    v_stream_info_t *vinfo = &p_para->vstream_info;
    a_stream_info_t *ainfo = &p_para->astream_info;
    s_stream_info_t *sinfo = &p_para->sstream_info;
    AVCodecContext  *pCodecCtx;
    codec_para_t *codec ;
    int ret = CODEC_ERROR_NONE;

    codec = codec_alloc();
    if (!codec) {
        return PLAYER_EMPTY_P;
    }
    MEMSET(codec, 0, sizeof(codec_para_t));

    codec->noblock = !!p_para->buffering_enable;
    if (vinfo->has_video) {
        codec->has_video = 1;
        codec->video_type = vinfo->video_format;
        codec->video_pid = vinfo->video_pid;
        if ((codec->video_type == VFORMAT_H264) || (codec->video_type == VFORMAT_H264MVC)) {
            codec->am_sysinfo.format = vinfo->video_codec_type;
            codec->am_sysinfo.width = vinfo->video_width;
            codec->am_sysinfo.height = vinfo->video_height;
            codec->am_sysinfo.rate = vinfo->video_rate;
            if (p_para->pFormatCtx->pb && p_para->pFormatCtx->pb->is_slowmedia) {
                /* ts slow media, use idr framerate */
                log_print("[%s:%d]Slow media detected for ts\n", __FUNCTION__, __LINE__);
                codec->am_sysinfo.param = USE_IDR_FRAMERATE;
            }
        } else if (codec->video_type == VFORMAT_VC1 || codec->video_type == VFORMAT_AVS) {
            codec->am_sysinfo.format = vinfo->video_codec_type;
            codec->am_sysinfo.width = vinfo->video_width;
            codec->am_sysinfo.height = vinfo->video_height;
            codec->am_sysinfo.rate = vinfo->video_rate;
        }
    }
    if (ainfo->has_audio) {
        codec->has_audio = 1;
        codec->audio_type = ainfo->audio_format;
        codec->audio_pid = ainfo->audio_pid;
        codec->audio_channels = ainfo->audio_channel;
        codec->audio_samplerate = ainfo->audio_samplerate;
		codec->switch_audio_flag = 0;
        pCodecCtx = p_para->pFormatCtx->streams[p_para->astream_info.audio_index]->codec;
        /*if ((codec->audio_type == AFORMAT_ADPCM) || (codec->audio_type == AFORMAT_WMA)
            || (codec->audio_type == AFORMAT_WMAPRO) || (codec->audio_type == AFORMAT_PCM_S16BE)
            || (codec->audio_type == AFORMAT_PCM_S16LE) || (codec->audio_type == AFORMAT_PCM_U8)
            || (codec->audio_type == AFORMAT_PCM_BLURAY)||(codec->audio_type == AFORMAT_AMR)) {*/
        if (IS_AUIDO_NEED_EXT_INFO(codec->audio_type)) {
            codec->audio_info.bitrate = pCodecCtx->sample_fmt;
            codec->audio_info.sample_rate = pCodecCtx->sample_rate;
            codec->audio_info.channels = pCodecCtx->channels;
            codec->audio_info.codec_id = pCodecCtx->codec_id;
            codec->audio_info.block_align = pCodecCtx->block_align;
            codec->audio_info.extradata_size = pCodecCtx->extradata_size;
            if (codec->audio_info.extradata_size > 0) {
                if (codec->audio_info.extradata_size >  AUDIO_EXTRA_DATA_SIZE) {
                    log_print("[%s:%d],extra data size exceed max  extra data buffer,cut it to max buffer size ", __FUNCTION__, __LINE__);
                    codec->audio_info.extradata_size =  AUDIO_EXTRA_DATA_SIZE;
                }
                memcpy((char*)codec->audio_info.extradata, pCodecCtx->extradata, codec->audio_info.extradata_size);
            }
            codec->audio_info.valid = 1;

        }
		if(IS_AUDIO_NOT_SUPPORTED_BY_AUDIODSP(codec->audio_type,pCodecCtx)){
				codec->dspdec_not_supported = 1;
				log_print("main profile aac not supported by dsp decoder,so set dspdec_not_supported flag\n");
		}	
        codec->avsync_threshold = p_para->start_param->avsync_threshold;
        log_print("[%s:%d]audio bitrate=%d sample_rate=%d channels=%d codec_id=%x block_align=%d,extra size\n",
                  __FUNCTION__, __LINE__, codec->audio_info.bitrate, codec->audio_info.sample_rate, codec->audio_info.channels,
                  codec->audio_info.codec_id, codec->audio_info.block_align, codec->audio_info.extradata_size);
    }
    if (sinfo->has_sub) {
        codec->has_sub = 1;
        codec->sub_pid = sinfo->sub_pid;
        codec->sub_type = sinfo->sub_type;
    }

    codec->stream_type = stream_type_convert(p_para->stream_type, codec->has_video, codec->has_audio);
    codec->packet_size = p_para->pFormatCtx->orig_packet_size;
    ret = codec_init(codec);
    if (ret != CODEC_ERROR_NONE) {
        if (ret != CODEC_OPEN_HANDLE_FAILED) {
            codec_close(codec);
        }
        goto error1;
    }

    p_para->codec = codec;
    return PLAYER_SUCCESS;
error1:
    log_print("[ts]codec_init failed!\n");
    codec_free(codec);
    return DECODER_INIT_FAILED;
}
Beispiel #29
0
int nodeup_postmove(int argc, char *argv[])
{
	FILE *f;
	char line[200];
	int i, j;
	long long values[3] = { 0, 0, 0 };

	static char *files[] = { PROC_TMP "/cpuinfo", PROC_TMP "/meminfo", 0 };
	struct info_t {
		char *fmt;
		long long *value;
		long long scale;
	} info[] = {
#if defined(__alpha__)
		{
		"cpus active             : %Ld", &values[0], 1}, {
		"cycle frequency [Hz]    : %Ld", &values[1], 1},
#endif
#if defined(__i386__) || defined(__x86_64__)
		{
		"cpu MHz         : %Ld", &values[1], 1000000}, {
		"processor\t:", &values[0], 0},
#endif
#if defined(__powerpc64__) || defined(powerpc)
		{
		"clock\t\t: %Ld", &values[1], 1000000}, {
		"processor\t:", &values[0], 0},
#endif
		{
		"MemTotal: %Ld", &values[2], 1024}, {
		0}
	};

	if (nodeup_mnt_proc(PROC_TMP))
		return -1;

	for (i = 0; files[i]; i++) {
		if (!(f = fopen(files[i], "r"))) {
			perror(files[i]);
			exit(1);
		}
		while (fgets(line, 100, f)) {
			for (j = 0; info[j].fmt; j++) {
				if (info[j].scale &&
				    sscanf(line, info[j].fmt,
					   info[j].value) == 1) {
					(*info[j].value) *= info[j].scale;
					break;
				}
				if (!info[j].scale &&
				    strncmp(info[j].fmt, line,
					    strlen(info[j].fmt)) == 0) {
					(*info[j].value)++;
					break;
				}
			}
		}
		fclose(f);
	}

	log_print(LOG_INFO, "cpus=%Ld; hz=%Ld; mem=%Ld\n",
		  values[0], values[1], values[2]);

	nodeup_rpc(store_info_callback, values, sizeof(values), 0, 0);
	return 0;
}
Beispiel #30
0
void set_time(unsigned char loctype, unsigned char invtype, unsigned char invno, time_t tWhen )
{
	int		index;

	index	= -1;
	switch(loctype)
	{
		case LOCTYPE_PHSC:
			switch(invtype)
			{
				case INVTYPE_LINK:
					index = IDX_LINK + invno;
					break;
				case INVTYPE_POWER:
					index = IDX_PWR + invno;
					break;
				case INVTYPE_FAN:
					index = IDX_FAN + invno;
					break;
				case INVTYPE_DISKARRAY:
					index = IDX_DISKAR + invno;
					break;
				case INVTYPE_PORT:
					index = IDX_PORT + invno;
			}
			break;
		case LOCTYPE_PROCESS:
			switch(invtype)
			{
				case INVTYPE_USERPROC:
					index = 0;
			}
		case LOCTYPE_LOAD:
			switch(invtype)
			{
				case INVTYPE_CPU:
					index = IDX_CPU;
					break;
				case INVTYPE_MEMORY:
					index = IDX_MEM;
					break;
				case INVTYPE_DISK:
					index = IDX_DISK+invno;
					break;
				case INVTYPE_QUEUE:
					index = IDX_QUE;
					break;
				case INVTYPE_NIFO:
					index = IDX_NIFO;
					break;
			}
			break;
	}

	if(index < 0)
	{
		log_print(LOGN_WARN,"UNVALID REFERENCE : LOCTYPE[%d] INVTYPE[%d] INVNO[%d] TIME[%ld]", loctype, invtype, invno, tWhen );
		return;
	}
	else if(index == 0)
	{
		log_print(LOGN_INFO,"INVOKED PROCESS IDX[%d]",invno);
		return;
	}

	fidb->tEventUpTime[index] = tWhen;
	log_print(LOGN_INFO, "STORED EVENTTIME[%ld] INDEX[%d]", tWhen, index);
}