예제 #1
0
파일: misc.c 프로젝트: jkhoogland/PFQ
static Action_SkBuff
log_buff(arguments_t args, SkBuff b)
{
	if (!printk_ratelimit())
		return Pass(b);

	printk(KERN_INFO "[PFQ/lang] [%p] len=%u head=%u tail=%u\n", b.skb,
								b.skb->len,
								skb_headroom(b.skb),
								skb_tailroom(b.skb));

	printk(KERN_INFO "      [%p] %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x...\n",
				b.skb->data,
				b.skb->data[0],
				b.skb->data[1],
				b.skb->data[2],
				b.skb->data[3],
				b.skb->data[4],
				b.skb->data[5],
				b.skb->data[6],
				b.skb->data[7],
				b.skb->data[8],
				b.skb->data[9],
				b.skb->data[10],
				b.skb->data[11],
				b.skb->data[12],
				b.skb->data[13]);

	return Pass(b);
}
예제 #2
0
BOOL PrivateAssertMD5(unsigned char* pucExpected, unsigned char* pucActual, int iLine, char* szFile)
{
	char szExpected[33];
	char szActual[33];

	if ((pucActual == NULL) && (pucExpected == NULL))
	{
		return Pass();
	}
	else if (pucActual == NULL)
	{
		ToMD5String(pucExpected, szExpected);
		return Fail(szExpected, "** NULL **", iLine, szFile);
	}

	if (memcmp(pucExpected, pucActual, 16) != 0)
	{
		ToMD5String(pucExpected, szExpected);
		ToMD5String(pucActual, szActual);
		return Fail(szExpected, szActual, iLine, szFile);
	}
	else
	{
		return Pass();
	}
}
예제 #3
0
파일: user.c 프로젝트: kspaans/StrombolOS
void timeit()
{
  Create(SYSCALL_LOW, timerecvrep);
  Pass();
  Create(SYSCALL_LOW, timesend);
  Pass();
  Exit();
}
예제 #4
0
파일: misc.c 프로젝트: jkhoogland/PFQ
static Action_SkBuff
log_packet(arguments_t args, SkBuff b)
{
	if (!printk_ratelimit())
		return Pass(b);

	if (eth_hdr(b.skb)->h_proto == __constant_htons(ETH_P_IP))
	{
		struct iphdr _iph;
		const struct iphdr *ip;

		ip = skb_header_pointer(b.skb, b.skb->mac_len, sizeof(_iph), &_iph);
		if (ip == NULL)
			return Pass(b);

		switch(ip->protocol)
		{
		case IPPROTO_UDP: {
			struct udphdr _udph; const struct udphdr *udp;
			udp = skb_header_pointer(b.skb, b.skb->mac_len + (ip->ihl<<2), sizeof(struct udphdr), &_udph);
			if (udp == NULL)
				return Pass(b);

			printk(KERN_INFO "[PFQ/lang] IP %pI4.%d > %pI4.%d: UDP\n",
						&ip->saddr, ntohs(udp->source),
						&ip->daddr, ntohs(udp->dest));
			return Pass(b);
		}
		case IPPROTO_TCP: {
			struct tcphdr _tcph; const struct tcphdr *tcp;
			tcp = skb_header_pointer(b.skb, b.skb->mac_len + (ip->ihl<<2), sizeof(struct tcphdr), &_tcph);
			if (tcp == NULL)
				return Pass(b);

			printk(KERN_INFO "[PFQ/lang] IP %pI4.%d > %pI4.%d: TCP\n", &ip->saddr, ntohs(tcp->source),
									      &ip->daddr, ntohs(tcp->dest));
			return Pass(b);
		}
		case IPPROTO_ICMP: {

			printk(KERN_INFO "[PFQ/lang] IP %pI4 > %pI4: ICMP\n", &ip->saddr, &ip->daddr);
			return Pass(b);
		}
		default: {

			printk(KERN_INFO "[PFQ/lang] IP %pI4 > %pI4: proto %x\n", &ip->saddr, &ip->daddr,
									     ip->protocol);
			return Pass(b);
		}

		}

	} else
		printk(KERN_INFO "[PFQ/lang] ETH proto %x\n", ntohs(eth_hdr(b.skb)->h_proto));

        return Pass(b);
}
예제 #5
0
파일: misc.c 프로젝트: pandaychen/PFQ
static ActionSkBuff
crc16_sum(arguments_t args, SkBuff skb)
{
	u16 crc = crc16(0, (u8 const *)eth_hdr(PFQ_SKB(skb)), skb->len);
	set_state(skb, crc);
        return Pass(skb);
}
예제 #6
0
int TrimCommand ::	Execute( ALib::CommandLine & cmd ) {

    GetSkipOptions( cmd );
    if ( cmd.HasFlag( FLAG_TRLEAD ) || cmd.HasFlag( FLAG_TRTRAIL ) ) {
        mTrimLead = cmd.HasFlag( FLAG_TRLEAD );
        mTrimTrail = cmd.HasFlag( FLAG_TRTRAIL );
    }
    else {
        mTrimLead = mTrimTrail = true;
    }

    if ( cmd.HasFlag( FLAG_WIDTH ) ) {
        GetWidths( cmd.GetValue( FLAG_WIDTH ) );
    }

    ALib::CommaList cl( cmd.GetValue( FLAG_COLS, "" ) );
    CommaListToIndex( cl, mFields );

    IOManager io( cmd );
    CSVRow row;

    while( io.ReadCSV( row ) ) {
        if ( Skip( row ) ) {
            continue;
        }

        if ( ! Pass( row ) ) {
            Trim( row );
        }
        io.WriteRow( row );
    }

    return 0;
}
예제 #7
0
파일: bloom.c 프로젝트: pfq/PFQ
static ActionQbuff
bloom_dst_filter(arguments_t args, struct qbuff * buff)
{
	if (bloom_dst(args, buff))
		return Pass(buff);
	return Drop(buff);
}
예제 #8
0
    //-----------------------------------------------------------------------------
    Technique& Technique::operator=(const Technique& rhs)
    {
        mName = rhs.mName;
		this->mIsSupported = rhs.mIsSupported;
        this->mLodIndex = rhs.mLodIndex;
		this->mSchemeIndex = rhs.mSchemeIndex;
		this->mShadowCasterMaterial = rhs.mShadowCasterMaterial;
		this->mShadowCasterMaterialName = rhs.mShadowCasterMaterialName;
		this->mShadowReceiverMaterial = rhs.mShadowReceiverMaterial;
		this->mShadowReceiverMaterialName = rhs.mShadowReceiverMaterialName;
		this->mGPUVendorRules = rhs.mGPUVendorRules;
		this->mGPUDeviceNameRules = rhs.mGPUDeviceNameRules;

		// copy passes
		removeAllPasses();
		Passes::const_iterator i, iend;
		iend = rhs.mPasses.end();
		for (i = rhs.mPasses.begin(); i != iend; ++i)
		{
			Pass* p = OGRE_NEW Pass(this, (*i)->getIndex(), *(*i));
			mPasses.push_back(p);
		}
        // Compile for categorised illumination on demand
        clearIlluminationPasses();
        mIlluminationPassesCompilationPhase = IPS_NOT_COMPILED;
		return *this;
    }
예제 #9
0
파일: rps.c 프로젝트: RobertElder/CS452
void RPSClient_Start() {
	robprintfbusy((const unsigned char *)"RPSClient created, tid=%d\n", MyTid());
	RPSClient client;
	RPSClient_Initialize(&client);

	// Want to play
	robprintfbusy((const unsigned char *)"Client: %d - I want to play\n", client.tid);

	RPSMessage * send_message;
	RPSMessage * reply_message;

	send_message = (RPSMessage *) client.send_buffer;
	send_message->message_type= MESSAGE_TYPE_SIGN_UP;
	Send(client.server_id, client.send_buffer, MESSAGE_SIZE, client.reply_buffer,MESSAGE_SIZE);
	reply_message = (RPSMessage *) client.reply_buffer;

	assert(reply_message->message_type == MESSAGE_TYPE_SIGN_UP_OK, "Client didn't sign up successfully");

	int i;
	for (i = 0; i < client.num_rounds_to_play; i++) {
		RPSClient_PlayARound(&client);
		Pass();
		if (!client.running) {
			robprintfbusy((const unsigned char *)"Client: %d - Quiting due to server shutdown\n", client.tid);
			Exit();
		}
	}

	RPSClient_Quit(&client);

	Exit();
}
예제 #10
0
int EditCommand :: Execute( ALib::CommandLine & cmd ) {

	GetSkipOptions( cmd );
	for ( int i = 2; i < cmd.Argc(); i++ ) {
		if ( cmd.Argv( i ) == FLAG_EDIT ) {
			AddSubCmd( cmd.Argv( i + 1 ) );
			i++;
		}
	}

	ALib::CommaList cl( cmd.GetValue( FLAG_COLS, "" ) );
	CommaListToIndex( cl, mCols );

	IOManager io( cmd );
	CSVRow row;

	while( io.ReadCSV( row ) ) {
		if ( Skip( io, row ) ) {
			continue;
		}
		if ( ! Pass( io, row ) ) {
			EditRow( row );
		}
		io.WriteRow( row );
	}

	return 0;
}
예제 #11
0
파일: rps.c 프로젝트: RobertElder/CS452
void RPSServer_ProcessMessage(RPSServer * server) {
	RPSMessage * receive_message;
	int source_tid;
	Receive(&source_tid, server->receive_buffer, MESSAGE_SIZE);
	receive_message = (RPSMessage*)server->receive_buffer;

	switch (receive_message->message_type) {
	case MESSAGE_TYPE_SIGN_UP:
		RPSServer_HandleSignup(server, receive_message, source_tid);
		break;
	case MESSAGE_TYPE_QUIT:
		RPSServer_HandleQuit(server, receive_message, source_tid);
		break;
	case MESSAGE_TYPE_PLAY:
		RPSServer_HandlePlay(server, receive_message, source_tid);
		break;
	default:
		assert(0, "RPSServer: Unknown message type from client");
		break;
	}

	RPSServer_SelectPlayers(server);

	Pass();

	if (Queue_CurrentCount(&server->player_tid_queue) == 0) {
		server->running = 0;
	}
}
예제 #12
0
int DateReadCommand :: Execute( ALib::CommandLine & cmd ) {

    GetSkipOptions( cmd );
    ProcessFlags( cmd );

    IOManager io( cmd );
    CSVRow row;

    while( io.ReadCSV( row ) ) {

        if ( Skip( io, row ) ) {
            continue;
        }
        if( Pass( io, row ) ) {
            io.WriteRow( row );
            continue;
        }

        if ( ConvertDates( row ) ) {
            io.WriteRow( row );
        }
    }

    return 0;
}
예제 #13
0
int EvalCommand ::	Execute( ALib::CommandLine & cmd ) {

	GetSkipOptions( cmd );
	IOManager io( cmd );
	CSVRow row;

	mDiscardInput = cmd.HasFlag( FLAG_DISCARD );
	GetExpressions( cmd );

	while( io.ReadCSV( row ) ) {
		if ( Skip( io, row ) ) {
			continue;
		}
		if ( ! Pass( io, row ) ) {
			SetParams( row, io );
			if ( mDiscardInput ) {
				row.clear();
			}
			Evaluate( row );
		}

		io.WriteRow( row );
	}

	return 0;
}
예제 #14
0
BOOL PrivateAssertFloat3(SFloat3 fExpected, SFloat3* pfActual, int iDecimals, int iLine, char* szFile)
{
	char	szExpected[96];
	char	szActual[96];
	float	fTolerance;
	int		iWholeNumbers;
	int		iOther;

	fTolerance = FloatToleranceForDecimals(iDecimals);
	if (!fExpected.CloselyEqual(pfActual, fTolerance))
	{
		iWholeNumbers = fExpected.WholeNumbers();
		iOther = pfActual->WholeNumbers();
		if (iOther > iWholeNumbers)
		{
			iWholeNumbers = iOther;
		}
		iWholeNumbers++;
		if (iWholeNumbers < 2)
		{
			iWholeNumbers = 2;
		}

		ToFloat3String(&fExpected, szExpected, iWholeNumbers, iDecimals);
		ToFloat3String(pfActual, szActual, iWholeNumbers, iDecimals);
		return Fail(szExpected, szActual, iLine, szFile);
	}
	else
	{
		return Pass();
	}
}
예제 #15
0
void other_task() {
	int mytid = MyTid();
	int myparenttid = MyParentTid();
	bwprintf( COM2, "My tid: %d\tMy parent tid:%d\n\r", mytid, myparenttid);
	Pass();
	bwprintf( COM2, "My tid: %d\tMy parent tid:%d\n\r", mytid, myparenttid);
	Exit();
}
예제 #16
0
파일: filter.c 프로젝트: pandaychen/PFQ
static ActionSkBuff
filter_dst_addr(arguments_t args, SkBuff b)
{
	__be32 addr = GET_ARG_0(__be32, args);
	__be32 mask = GET_ARG_1(__be32, args);

	return has_dst_addr(b, addr, mask) ? Pass(b) : Drop(b);
}
예제 #17
0
파일: misc.c 프로젝트: jkhoogland/PFQ
static Action_SkBuff
crc16_sum(arguments_t args, SkBuff b)
{
	u16 crc = crc16(0, (u8 const *)eth_hdr(b.skb), b.skb->len);
	set_state(b, crc);

        return Pass(b);
}
예제 #18
0
파일: user.c 프로젝트: kspaans/StrombolOS
void other_user_task()
{
  bwprintf(COM2, "My TID is %d and my parent's TID is %d.\n",
           MyTid(), MyParentTid());
  Pass();
  bwprintf(COM2, "My TID is %d and my parent's TID is %d.\n",
           MyTid(), MyParentTid());
  Exit();
}
예제 #19
0
파일: aabbtree.cpp 프로젝트: bntmorgan/l2
AABBTree::AABBTree(const std::vector<Object*> &e, unsigned int max_depth) :
    max_depth_(max_depth) {
  int i;
  // We copy the vector of objects
  for (i = 0; i < e.size(); i++) {
    world_.push_back(e[i]);
  }
  root_ = Pass(world_, NULL, 0);
}
예제 #20
0
void task_codes (){

	kprintf("Task id: %d\tParent task id: %d\n\r", MyTid(), MyParentTid());
	Pass();
	kprintf("Task id: %d\tParent task id: %d\n\r", MyTid(), MyParentTid());
	
	Exit();
	kprintf ("Unexpected return from Exit() at task_codes\n\r");
}
예제 #21
0
파일: tasks.c 프로젝트: RobertElder/CS452
int overflow(int times){
	robprintfbusy((const unsigned char *)"Doing overflow in task %d with time as %d\n",times, MyTid());
	int i = 0;
	Pass();
	if(times != 0){
		i = 1 + overflow(times-1);
		return i;
	}
	return i-1;
}
예제 #22
0
void	CBlender_Compile::PassSET_ZB		(BOOL bZTest, BOOL bZWrite, BOOL bInvertZTest)
{
	if (Pass())	bZWrite = FALSE;
	RS.SetRS	(D3DRS_ZFUNC,			bZTest?(bInvertZTest?D3DCMP_GREATER:D3DCMP_LESSEQUAL):D3DCMP_ALWAYS);
	RS.SetRS	(D3DRS_ZWRITEENABLE,	BC(bZWrite));
	/*
	if (bZWrite || bZTest)				RS.SetRS	(D3DRS_ZENABLE,	D3DZB_TRUE);
	else								RS.SetRS	(D3DRS_ZENABLE,	D3DZB_FALSE);
	*/
}
예제 #23
0
파일: misc.c 프로젝트: jkhoogland/PFQ
static Action_SkBuff
log_msg(arguments_t args, SkBuff b)
{
	const char *msg = GET_ARG(const char *, args);

	if (printk_ratelimit())
		printk(KERN_INFO "[PFQ/lang] log_msg: %s\n", msg);

	return Pass(b);
}
예제 #24
0
파일: filter.c 프로젝트: pandaychen/PFQ
static ActionSkBuff
filter_generic(arguments_t args, SkBuff b)
{
	predicate_t pred_ = GET_ARG(predicate_t, args);

	if (EVAL_PREDICATE(pred_, b))
		return Pass(b);

	return Drop(b);
}
예제 #25
0
파일: clock.c 프로젝트: RobertElder/CS452
void ClockServer_Start() {
	ClockServer server;
	ClockServer_Initialize(&server);
	
	GenericMessage * receive_msg = (GenericMessage *) server.receive_buffer;
	int source_tid;
	
	assert(sizeof(NotifyMessage) <= MESSAGE_SIZE, "NotifyMessage size too big");
	assert(sizeof(ClockMessage) <= MESSAGE_SIZE, "ClockMessage size too big");
	
	robprintfbusy((const unsigned char *)"ClockServer TID=%d: start\n", server.tid);
	
	int return_code = RegisterAs((char *)CLOCK_SERVER_NAME);
	assert(return_code == 0, "ClockServer: Failed to register name");
	
	int tid = Create(HIGHEST, ClockNotifier_Start);
	assert(tid > 0, "ClockNotifier tid not positive");
	
	// For Debugging
	*TIMER4_VAL_HIGH |= 1 << 8;
	server.last_timer_value = *TIMER4_VAL_LOW;
	
	while (server.running) {
		Receive(&source_tid, server.receive_buffer, MESSAGE_SIZE);
		//robprintfbusy((const unsigned char *)"ClockServer: received %d message type\n", receive_msg->message_type);
		
		switch(receive_msg->message_type) {
		case MESSAGE_TYPE_NOTIFIER:
			ClockServer_HandleNotifier(&server, source_tid, (NotifyMessage*) receive_msg);
			break;
		case MESSAGE_TYPE_TIME_REQUEST:
			ClockServer_HandleTimeRequest(&server, source_tid, (ClockMessage*) receive_msg);
			break;
		case MESSAGE_TYPE_DELAY_REQUEST:
			ClockServer_HandleDelayRequest(&server, source_tid, (ClockMessage*) receive_msg, 0);
			break;
		case MESSAGE_TYPE_DELAY_UNTIL_REQUEST:
			ClockServer_HandleDelayRequest(&server, source_tid, (ClockMessage*) receive_msg, 1);
			break;
		case MESSAGE_TYPE_SHUTDOWN:
			ClockServer_HandleShutdownRequest(&server, source_tid, (ClockMessage*) receive_msg);
			break;
		default:
			assertf(0, "ClockServer: unknown message type %d", receive_msg->message_type);
			break;
		}
		
		ClockServer_UnblockDelayedTasks(&server);
		Pass();
	}
	
	robprintfbusy((const unsigned char *)"ClockServer TID=%d: end\n", server.tid);
	
	Exit();
}
예제 #26
0
static void time_pass(char* name) {
  int i;
  unsigned int t1 = edges();
  for (i = 0; i < ITERATIONS; i++) {
    Pass();
  }
  unsigned int t2 = edges();
  printf(COM2, "%s Test: Average time for Pass: %d\n", name,
                 edges_to_micros((t2 - t1) / ITERATIONS));
  Flush();
}
예제 #27
0
BOOL PrivateAssertNull(void* pvActual, int iLine, char* szFile)
{
	if (NULL != pvActual)
	{
		return Fail("NULL", "Not NULL", iLine, szFile);
	}
	else
	{
		return Pass();
	}
}
예제 #28
0
Status MazePath(MazeType maze[][N],Postype start,Postype end) {
    SqStack S;
    SElemType_Sq nodeInf;      // 当前通道的信息
    Postype curPos;            // 当前位置
    int curStep;               // 当前通道的序号

    InitList_Sq(&S);

    curPos = start;
    curStep = 1;

    do {
        if (Pass(curPos,maze)) {    // 当前位置可通过?
            FootPrint(curPos,maze); //留下足迹
            ShowMaze(maze);

            SetSElemType(&nodeInf,curStep,curPos,East); // 设置当前位置的属性

            Push_sq(&S,nodeInf); // 加入栈

            if (EqualPosType(curPos,end)) { // 如果到终点
                printf("\n 寻路成功!!\n\n");
                return TRUE;
            }

            curPos = NextPos(curPos,East); // 设置下一个为东
            curStep++; // 探索下一块
        } else {
            if (!StackEmpty_Sq(S)) {// 如果没有倒退到原点
                Pop_Sq(&S,&nodeInf);
                while (nodeInf.di == North && !StackEmpty_Sq(S)) {
                    MarkPrint(nodeInf.seat,maze);    // 四个方向都遍历过,就回退一步
                    ShowMaze(maze);
                    Pop_Sq(&S,&nodeInf);
                }

                if (nodeInf.di < North) {
                    maze[nodeInf.seat.x][nodeInf.seat.y] = ++nodeInf.di;
                    ShowMaze(maze);
                    Push_sq(&S,nodeInf);
                    curPos = NextPos(nodeInf.seat,nodeInf.di);
                }
            }
        }
    } while (!StackEmpty_Sq(S));

    printf("\n 寻路失败!!\n\n");
    return FALSE;

}
예제 #29
0
파일: user.c 프로젝트: kspaans/StrombolOS
void first()
{
  bwprintf (COM2, "I AM FIRST USER.\n\tMODE IS ");
  print_mode ();
  bwputstr (COM2, ".\n\tCREATE???\n");
  //int z = Create (0xABCDEF01, (void*)0x10FEDCBA);
  int z = Create (3, second);
  int i=0,j=0,k=0;
  while (1) {
    bwprintf (COM2, "I AM FIRST USER.\n\tKERNEL SAID %d\n\tMODE IS ",z);
    print_mode ();
    bwputstr (COM2, ".\n\tPASS??\n");
    i++;
    if (i>10) j++;
    if (j>10) k++;
    i %= 11; j %= 11;
//    bwprintf (COM2, "(i,j,k) = (%d,%d,%d)\n",i,j,k);
    Pass();
    bwprintf (COM2, "I AM FIRST USER.\n\tMODE IS ");
    print_mode ();
    bwputstr (COM2, ".\n\tEXIT????\n");
    Exit();
  }

//  int i = 0xFFFFF;
  int r;
  while (i--) {
    bwprintf(COM2, "Hey, I'm a user(%d)!\n", i);
    r = swtch(i);
    bwprintf(COM2, "And the kernel gave me %d!\n", r);
    for (r = 0; r < 500000; ++r);
  }
  bwputstr (COM2, "CPU Mode: ");
  print_mode();
  bwputstr (COM2, "\n\n");
  int x = 42;
  int b[5];
  b[0] = 0xDEADBEEF;
  b[1] = 0xDEADBEEF;
  b[2] = 0xDEADBEEF;
  b[3] = 0xDEADBEEF;
  b[4] = 0xDEADBEEF;
  bwprintf (COM2, "x is %d\n", x);
  i = 5; while (i--) { bwprintf (COM2, "b[%d] = ", i); bwputr(COM2, b[i]); bwputstr (COM2, "\n");}
  b[2] -= x;
  b[3]--;
  bwputstr (COM2, "now b[2] = b[2] - x  and b[3] = b[3] - 1...\n");
  i = 5; while (i--) { bwprintf (COM2, "b[%d] = ", i); bwputr(COM2, b[i]); bwputstr (COM2, "\n");}
}
예제 #30
0
BOOL PrivateAssertString(char* szExpected, char* szActual, BOOL bTestCase, int iLine, char* szFile)
{
	if ((szExpected == NULL) && (szActual == NULL))
	{
		return Pass();
	}
	else if (szActual == NULL)
	{
		return Fail(szExpected, "** NULL **", iLine, szFile);
	}
	else
	{
		if (bTestCase)
		{
			if (strcmp(szExpected, szActual) != 0)
			{
				return Fail(szExpected, szActual, iLine, szFile);
			}
			else
			{
				return Pass();
			}
		}
		else
		{
			if (StrICmp(szExpected, szActual) != 0)
			{
				return Fail(szExpected, szActual, iLine, szFile);
			}
			else
			{
				return Pass();
			}
		}
	}
}