Ejemplo n.º 1
0
void krb_reqbody_init(KRB_CONTEXT* krb_ctx, KDCReqBody* req_body, uint8 reqtype)
{
	time_t t;

	req_body->cname = xstrdup(krb_ctx->cname);
	req_body->realm = xstrdup(krb_ctx->realm);
	
	if (reqtype == KRB_TAG_ASREQ)
	{
		req_body->kdc_options = 0x40000000 | 0x00800000 | 0x00010000 | 0x00000010;  /* forwardable , renewable, canonicalize, renewable OK */
		req_body->sname = xzalloc((strlen(req_body->realm) + 8) * sizeof(char));
		strcpy(req_body->sname, KRB_SERVER);
		strcat(req_body->sname, req_body->realm);
	}
	else if (reqtype == KRB_TAG_TGSREQ)
	{
		req_body->kdc_options = 0x40000000 | 0x00800000 | 0x00010000;  /* forwardable , renewable, canonicalize */
		req_body->sname = xzalloc((strlen(krb_ctx->settings->hostname) + 10) * sizeof(char));
		strcpy(req_body->sname, APP_SERVER);
		strcat(req_body->sname, krb_ctx->settings->hostname);
	}

	t = time(NULL);
	t += krb_ctx->clockskew; /* fix clockskew */

	req_body->from = get_utc_time((time_t)(t));
	req_body->till = get_utc_time((time_t)(t + 473040000));
	req_body->rtime = get_utc_time((time_t)(t + 473040000));
	
	crypto_nonce((uint8*) &(req_body->nonce), 4);
}
/**
@brief		save a dump of memory I/F

Performs actual file operation for saving a dump of a memory interface.

@param mld	the pointer to a mem_link_device instance
*/
void save_mem_dump(struct mem_link_device *mld)
{
#ifdef DEBUG_MODEM_IF
	struct link_device *ld = &mld->link_dev;
	char *path = mld->dump_path;
	struct file *fp;
	struct utc_time t;

	get_utc_time(&t);
	snprintf(path, MIF_MAX_PATH_LEN, "%s/%s_%d%02d%02d_%02d%02d%02d.dump",
		MIF_LOG_DIR, ld->name, t.year, t.mon, t.day, t.hour, t.min,
		t.sec);

	fp = mif_open_file(path);
	if (!fp) {
		mif_err("%s: ERR! %s open fail\n", ld->name, path);
		return;
	}
	mif_err("%s: %s opened\n", ld->name, path);

	mif_save_file(fp, mld->base, mld->size);

	mif_close_file(fp);
#endif
}
void pr_ipc(const char *tag, const char *data, size_t len)
{
	struct utc_time utc;
	unsigned char str[128];

	get_utc_time(&utc);
	dump2hex(str, data, (len > 32 ? 32 : len));
	pr_info("%s: %s: [%02d:%02d:%02d.%03d] %s\n",
		MIF_TAG, tag, utc.hour, utc.min, utc.sec, utc.msec, str);
}
void pr_ipc(int level, const char *tag, const char *data, size_t len)
{
    struct utc_time utc;
    unsigned char str[128];

    if (level < 0)
        return;

    get_utc_time(&utc);
    dump2hex(str, data, (len > 32 ? 32 : len));
    if (level > 0) {
        pr_err("%s: %s: [%02d:%02d:%02d.%03d] %s\n", MIF_TAG, tag,
               utc.hour, utc.min, utc.sec, utc.msec, str);
    } else {
        pr_info("%s: %s: [%02d:%02d:%02d.%03d] %s\n", MIF_TAG, tag,
                utc.hour, utc.min, utc.sec, utc.msec, str);
    }
}
/**
@brief		trigger an enforced CP crash

@param mld	the pointer to a mem_link_device instance
*/
void mem_forced_cp_crash(struct mem_link_device *mld)
{
	struct link_device *ld = &mld->link_dev;
	struct modem_ctl *mc = ld->mc;
	unsigned long flags;
	bool duplicated = false;
#ifdef DEBUG_MODEM_IF
	struct utc_time t;
#endif

#ifdef DEBUG_MODEM_IF
	get_utc_time(&t);
#endif

	/* Disable normal IPC */
	set_magic(mld, MEM_CRASH_MAGIC);
	set_access(mld, 0);

	spin_lock_irqsave(&mld->lock, flags);
	if (mld->forced_cp_crash)
		duplicated = true;
	else
		mld->forced_cp_crash = true;
	spin_unlock_irqrestore(&mld->lock, flags);

	if (duplicated) {
#ifdef DEBUG_MODEM_IF
		evt_log(HMSU_FMT " %s: %s: ALREADY in progress <%pf>\n",
			t.hour, t.min, t.sec, t.us, CALLEE, ld->name, CALLER);
#endif
		return;
	}

	if (!cp_online(mc)) {
#ifdef DEBUG_MODEM_IF
		evt_log(HMSU_FMT " %s: %s: %s.state %s != ONLINE <%pf>\n",
			t.hour, t.min, t.sec, t.us,
			CALLEE, ld->name, mc->name, mc_state(mc), CALLER);
#endif
		return;
	}

	if (!wake_lock_active(&mld->dump_wlock))
		wake_lock(&mld->dump_wlock);

	stop_net_ifaces(ld);

	/**
	 * If there is no CRASH_ACK from a CP in FORCE_CRASH_ACK_TIMEOUT,
	 * handle_no_cp_crash_ack() will be executed.
	 */
	mif_add_timer(&mld->crash_ack_timer, FORCE_CRASH_ACK_TIMEOUT,
		      handle_no_cp_crash_ack, (unsigned long)mld);

	/* Send CRASH_EXIT command to a CP */
	send_ipc_irq(mld, cmd2int(CMD_CRASH_EXIT));

#ifdef DEBUG_MODEM_IF
	evt_log(HMSU_FMT " CRASH_EXIT: %s->%s: CP_CRASH_REQ <by %pf>\n",
		t.hour, t.min, t.sec, t.us, ld->name, mc->name, CALLER);

	if (in_interrupt())
		queue_work(system_nrt_wq, &mld->dump_work);
	else
		save_mem_dump(mld);
#endif
}