static void swap_agg_header(struct aggr_data *hdr)
{
	swap_32(hdr->magic);
	swap_32(hdr->version);
	swap_64(hdr->begin_time);
	swap_64(hdr->num_zfcpdd);
	swap_64(hdr->num_blkiomon);
	swap_64(hdr->end_time);
}
static void swap_header(struct file_header *f_hdr)
{
	swap_32(f_hdr->magic);
	swap_32(f_hdr->version);
	swap_64(f_hdr->size_limit);
	swap_32(f_hdr->interval_length);
	swap_32(f_hdr->msgid_utilization);
	swap_32(f_hdr->msgid_ioerr);
	swap_32(f_hdr->msgid_blkiomon);
	swap_32(f_hdr->msgid_zfcpdd);
	swap_64(f_hdr->end_time);
	swap_64(f_hdr->first_msg_offset);
	swap_64(f_hdr->begin_time);
}
static int read_message_preview(FILE *fp, struct message_preview *msg,
				struct file_header *f_hdr)
{
	int rc;

	msg->pos = ftell(fp);
	if ( (rc = read_message_header(fp, &msg->length, &msg->type)) )
		return rc;

	/* Eventually read timestamp and fforward to next msg */
	if (msg->type != ZIOMON_DACC_GARBAGE_MSG) {
		/* per convention, the first 8 bytes of the actual message
		 * is the timestamp. */
		assert(msg->length >= 8);
		if (fread(&msg->timestamp, 8, 1, fp) != 1) {
			fprintf(stderr, "%s: Error reading"
				" message timestamp\n", toolname);
			return -1;
		}
		swap_64(msg->timestamp);
		fseek(fp, msg->length - 8, SEEK_CUR);
		msg->is_blkiomon_v2 = (f_hdr->version == DATA_MGR_V2
				       && msg->type == f_hdr->msgid_blkiomon);
	}
	else
		fseek(fp, msg->length, SEEK_CUR);

	return 0;
}
int add_msg(FILE *fp, struct message *msg, struct file_header *f_hdr,
	    struct message ***del_msg, int *num_del_msg)
{
	__s32 add_garbage;
	long cur_pos, old_pos = ftell(fp);

	*num_del_msg = 0;
	add_garbage = position_in_file(fp, msg, f_hdr, del_msg, num_del_msg);
	if (add_garbage < 0)
		return -1;

	if (write_message(fp, msg) < 0)
		return -2;

	if (add_garbage > 0) {
		cur_pos = ftell(fp);
		if (write_garbage_message(fp, add_garbage) < 0)
			return -3;
		fseek(fp, cur_pos, SEEK_SET);
	}

	f_hdr->end_time = *(__u64*)(msg->data);
	swap_64(f_hdr->end_time);	/* msg content is BE by convention */
	cur_pos = ftell(fp);
	if (f_hdr->first_msg_offset != 0 || cur_pos < old_pos)
		f_hdr->first_msg_offset = ftell(fp);
	if (write_f_header(fp, f_hdr))
		return -4;
	fseek(fp, cur_pos, SEEK_SET);

	return 0;
}
Ejemplo n.º 5
0
void Nasha256_compile(hashState256 *state)
{
	int i;
	uint_64t x[16],y[16],l1,l2;
	B64 tmp;
	uint_32t A1, B1, C1, A2, B2, C2;
    uint_16t alpha1, beta1, gama1, alpha2, beta2, gama2;
	uint_8t a1,b1,c1,a2,b2,c2,a3,b3,c3;
	
	PutX(y,state);
	LinTr16(y,x);
	
	// computing the leaders l1 and l2
	l1=x[0]+x[1];
	l2=x[2]+x[3];
	
	//computing the 8-bite words a1, b1, c1,a2,b2,c2,a3,b3,c3
	tmp.bit64=x[4]+x[5];
	a1=tmp.b8[7]; b1=tmp.b8[6]; c1=tmp.b8[5];
	a2=tmp.b8[4]; b2=tmp.b8[3]; c2=tmp.b8[2];
	a3=tmp.b8[1]; b3=tmp.b8[0]; c3=a1;
	
	//computing the 16-bite words alpha1, beta1, gama1, alpha2, beta2, gama2
	tmp.bit64=x[6]+x[7];
	alpha1=tmp.bit16[3]; beta1=tmp.bit16[2]; gama1=tmp.bit16[1]; alpha2=tmp.bit16[0];
	
	tmp.bit64=x[8]+x[9]; 
	beta2=tmp.bit16[3]; gama2=tmp.bit16[2];
	
	//computing the 32-bite words A1, B1, C1, A2, B2, C2
	tmp.bit64=x[10]+x[11];
	A1=tmp.bit32[1]; B1=tmp.bit32[0];

	tmp.bit64=x[12]+x[13];
	C1=tmp.bit32[1]; A2=tmp.bit32[0];

	tmp.bit64=x[14]+x[15];
	B2=tmp.bit32[1]; C2=tmp.bit32[0];
	AE(l2,x,y,16,a1,b1,c1,a2,b2,c2,a3,b3,c3,alpha1, beta1, gama1,A1, B1, C1);
	swap_64(y,16);
	RAE(l1,y,x,15,a1,b1,c1,a2,b2,c2,a3,b3,c3,alpha2, beta2, gama2,A2, B2, C2);
	/*  Finally compute the hash digest (or/and the hash chain value) */
	for (i=0;i<4;i++){
		state->H[i]=x[(i<<2)+1];
		state->hash[i]=x[(i<<2)+3];
	}
}