Ejemplo n.º 1
0
void capture(struct netdevice* dev, sbuff * sbuff) {
    size_t capturedLen = sbuff->totalSize;
    ASSERT_INT_EQUALS(98, capturedLen);
    char *reply = tobytes("45000054000000004001f355c0a80302c0a803010000eda80eb203a52d771b53000000006f38030000000000101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637");

    uint8_t* p = sbuff->data;
    for (int i = 14; i < capturedLen; i++) {
        ASSERT_EQUALS(reply[i-14], ((char*)p)[i]);
    }

    capturedLen = capturedLen;
    gCalled = 1;
    free(reply);
}
Ejemplo n.º 2
0
int main(int argc, char **argv) {

	int aflag = 0;
	int bflag = 0;
	char *cvalue = NULL;

	int index;
	int c;

	opterr = 0;

	if (argc == 1) {
		args();
		return;
	}

	int procid = -1;
	char *dump = NULL;
	char *find = NULL;
	char *replace = NULL;
	char utf16 = 0;

	WORD lbound = 0;
	WORD ubound = WORDMAX;

	int hex = 0;

	while ((c = getopt(argc, argv, "d:b:c:p:f:ur:l:t:h")) != -1)
		switch (c) {
			case 'd':
				dump = optarg;
				break;
			case 'b':
				bflag = 1;
				break;
			case 'c':
				cvalue = optarg;
				break;
			case 'p':
				procid = atoi(optarg);
				break;
			case 'f':
				find = optarg;
				break;
			case 'r':
				replace = optarg;
				break;
			case 'u':
				utf16 = 1;
				break;
			case 'l':
				lbound = TOWORD(optarg);
				break;
			case 't':
				ubound = TOWORD(optarg);
				break;
			case 'h':
				hex = 1;
				break;
			default:
				args();
				abort();
		}

	if (procid == -1) {
		args();
		return;
	}

	if (dump) {
		dumpprocess(procid, dump);
	}

	if (find != NULL && replace != NULL) {
		if (!utf16 && !hex) {
			procreplace(procid, find, strlen(find), replace,
				    strlen(replace), lbound, ubound);
		} else if (hex) {
			char *f_ = tobytes(find);
			char *r_ = tobytes(replace);

			if (!f_ || !r_) {
				printf
				    ("Hexadecimal must be even number of characters\n");
				return;
			}

			int fl = strlen(find) / 2;
			if (fl == 0)
				fl = 1;

			int rl = strlen(replace) / 2;
			if (rl == 0)
				rl = 1;

			procreplace(procid, f_, fl, r_, rl, lbound, ubound);

		} else {
			char *f_ = asciitou16(find);
			char *r_ = asciitou16(replace);;
			procreplace(procid, f_, u16bytes(f_), r_,
				    u16bytes(r_), lbound, ubound);
		}

	} else if (find) {
		if (!utf16 && !hex) {
			procreplace(procid, find, strlen(find), NULL, 0, lbound,
				    ubound);

		} else if (hex) {
			unsigned char *f_ = tobytes(find);

			if (!f_) {
				printf
				    ("Hexadecimal must be even number of characters\n");
				return;
			}

			int div2 = strlen(find) / 2;
			if (div2 == 0)
				div2 = 1;

			procreplace(procid, f_, div2, NULL, 0, lbound, ubound);

		} else {
			char *f_ = asciitou16(find);
			procreplace(procid, f_, u16bytes(f_), NULL, 0, lbound,
				    ubound);
		}
	}

}
Ejemplo n.º 3
0
Archivo: quota.c Proyecto: hajuuk/R7000
int uquota_getvolspace( struct vol *vol, VolSpace *bfree, VolSpace *btotal, const u_int32_t bsize)
{
	u_int64_t this_bsize;
	struct dqblk dqblk;

	this_bsize = bsize;
			
	if (getquota( vol, &dqblk, bsize) != 0 ) {
		return( AFPERR_PARAM );
	}

#ifdef linux
	this_bsize = dqblk.bsize;
#endif

#ifdef DEBUG_QUOTA
        LOG(log_debug, logtype_afpd, "after calling getquota in uquota_getvolspace!" );
        LOG(log_debug, logtype_afpd, "dqb_ihardlimit: %u", dqblk.dqb_ihardlimit );
        LOG(log_debug, logtype_afpd, "dqb_isoftlimit: %u", dqblk.dqb_isoftlimit );
        LOG(log_debug, logtype_afpd, "dqb_curinodes : %u", dqblk.dqb_curinodes );
        LOG(log_debug, logtype_afpd, "dqb_bhardlimit: %u", dqblk.dqb_bhardlimit );
        LOG(log_debug, logtype_afpd, "dqb_bsoftlimit: %u", dqblk.dqb_bsoftlimit );
        LOG(log_debug, logtype_afpd, "dqb_curblocks : %u", dqblk.dqb_curblocks );
        LOG(log_debug, logtype_afpd, "dqb_btime     : %u", dqblk.dqb_btime );
        LOG(log_debug, logtype_afpd, "dqb_itime     : %u", dqblk.dqb_itime );
        LOG(log_debug, logtype_afpd, "bsize/this_bsize : %u/%u", bsize, this_bsize );
	LOG(log_debug, logtype_afpd, "dqblk.dqb_bhardlimit size: %u", tobytes( dqblk.dqb_bhardlimit, this_bsize ));
	LOG(log_debug, logtype_afpd, "dqblk.dqb_bsoftlimit size: %u", tobytes( dqblk.dqb_bsoftlimit, this_bsize ));
	LOG(log_debug, logtype_afpd, "dqblk.dqb_curblocks  size: %u", tobytes( dqblk.dqb_curblocks, this_bsize ));
#endif /* DEBUG_QUOTA */ 

	/* no limit set for this user. it might be set in the future. */
	if (dqblk.dqb_bsoftlimit == 0 && dqblk.dqb_bhardlimit == 0) {
        	*btotal = *bfree = ~((VolSpace) 0);
    	} else if ( overquota( &dqblk )) {
        	if ( tobytes( dqblk.dqb_curblocks, this_bsize ) > tobytes( dqblk.dqb_bsoftlimit, this_bsize ) ) {
            		*btotal = tobytes( dqblk.dqb_curblocks, this_bsize );
            		*bfree = 0;
        	}
        	else {
            		*btotal = tobytes( dqblk.dqb_bsoftlimit, this_bsize );
            		*bfree  = tobytes( dqblk.dqb_bsoftlimit, this_bsize ) -
                     		  tobytes( dqblk.dqb_curblocks, this_bsize );
        	}
    	} else {
        	*btotal = tobytes( dqblk.dqb_bhardlimit, this_bsize );
        	*bfree  = tobytes( dqblk.dqb_bhardlimit, this_bsize  ) -
                 	  tobytes( dqblk.dqb_curblocks, this_bsize );
    	}

#ifdef DEBUG_QUOTA
        LOG(log_debug, logtype_afpd, "bfree          : %u", *bfree );
        LOG(log_debug, logtype_afpd, "btotal         : %u", *btotal );
        LOG(log_debug, logtype_afpd, "bfree          : %uKB", *bfree/1024 );
        LOG(log_debug, logtype_afpd, "btotal         : %uKB", *btotal/1024 );
#endif

	return( AFP_OK );
}