Example #1
0
void fbcon_ega_planes_putc(struct vc_data *conp, struct display *p, int c, int yy, int xx)
{
	int fg = attr_fgcol(p,c);
	int bg = attr_bgcol(p,c);

	int y;
	u8 *cdat = p->fontdata + (c & p->charmask) * fontheight(p);
	char *where = p->screen_base + xx + yy * p->line_length * fontheight(p);

	setmode(0);
	setop(0);
	setsr(0xf);
	setcolor(bg);
	selectmask();

	setmask(0xff);
	for (y = 0; y < fontheight(p); y++, where += p->line_length) 
		rmw(where);

	where -= p->line_length * y;
	setcolor(fg);
	selectmask();
	for (y = 0; y < fontheight(p); y++, where += p->line_length) 
		if (cdat[y]) {
			setmask(cdat[y]);
			rmw(where);
		}
}
Example #2
0
void fbcon_vga_planes_putc(struct vc_data *conp, struct display *p, int c, int yy, int xx)
{
	int fg = attr_fgcol(p,c);
	int bg = attr_bgcol(p,c);

	int y;
	u8 *cdat = p->fontdata + (c & p->charmask) * fontheight(p);
	char *where = p->screen_base + xx + yy * p->line_length * fontheight(p);

	setmode(2);
	setop(0);
	setsr(0xf);
	setcolor(fg);
	selectmask();

	setmask(0xff);
	writeb(bg, where);
	rmb();
	readb(where); /* fill latches */
	setmode(3);
	wmb();
	for (y = 0; y < fontheight(p); y++, where += p->line_length) 
		writeb(cdat[y], where);
	wmb();
}
Example #3
0
void fbcon_vga_planes_clear(struct vc_data *conp, struct display *p, int sy, int sx,
		   int height, int width)
{
	int line_ofs = p->line_length - width;
	char *where;
	int x;
	
	setmode(0);
	setop(0);
	setsr(0xf);
	setcolor(attr_bgcol_ec(p, conp));
	selectmask();

	setmask(0xff);

	sy *= fontheight(p);
	height *= fontheight(p);

	where = p->screen_base + sx + sy * p->line_length;
	while (height--) {
		for (x = 0; x < width; x++) {
			writeb(0, where);
			where++;
		}
		where += line_ofs;
	}
}
Example #4
0
void search(vector<vector<int> >& mask, int step, int sz, vector<int>& res){
    if (step == sz){
        pushresult(res);
        return ;
    }
    
    for (int i = 0; i != sz; i++){
        if (!mask[step][i]){
            vector<vector<int> > tmp = mask;
            res.push_back(i);
            setmask(tmp, step, i);
            search(tmp, step + 1, sz, res);
            res.pop_back();
        }
    }
}
Example #5
0
/*
 * sigprocmask -
 *   return:
 *   how(in):
 *   set(in/out):
 *   oldset(out):
 *
 * Note:
 */
int
sigprocmask (int how, sigset_t * set, sigset_t * oldset)
{
  switch (how)
    {
    case SIG_BLOCK:
      return (block_signals (set, oldset));

    case SIG_UNBLOCK:
      return (unblock_signals (set, oldset));

    case SIG_SETMASK:
      return (setmask (set, oldset));
    }

  return (-1);
}
Example #6
0
void sec_gpu_dvfs_init(void)
{
	struct platform_device *pdev;
	int i = 0;
	ssize_t total = 0, offset = 0;

	memset(gdata, 0x00, sizeof(struct gpu_dvfs_data)*MAX_DVFS_LEVEL);

	for (i = 0; i < GPU_DVFS_MAX_LEVEL; i++) {
		gdata[i].level = default_dvfs_data[i].level;
		gdata[i].clock = default_dvfs_data[i].clock;
		gdata[i].voltage = get_match_volt(ID_G3D, default_dvfs_data[i].clock * 1000);
		gdata[i].clock_source = default_dvfs_data[i].clock_source;
		gdata[i].min_threadhold = default_dvfs_data[i].min_threadhold;
		gdata[i].max_threadhold = default_dvfs_data[i].max_threadhold;
		gdata[i].quick_down_threadhold = default_dvfs_data[i].quick_down_threadhold;
		gdata[i].quick_up_threadhold = default_dvfs_data[i].quick_up_threadhold;
		gdata[i].stay_total_count = default_dvfs_data[i].stay_total_count;
		gdata[i].mask  = setmask(default_dvfs_data[i].level, default_dvfs_data[i].clock);
		PVR_LOG(("G3D DVFS Info: Level:%d, Clock:%d MHz, Voltage:%d uV", gdata[i].level, gdata[i].clock, gdata[i].voltage));
	}

	/* default dvfs level depend on default clock setting */
	sgx_dvfs_level = sec_gpu_dvfs_level_from_clk_get(gpu_clock_get());
	sgx_dvfs_down_requirement = DOWN_REQUIREMENT_THRESHOLD;

	pdev = gpsPVRLDMDev;

	/* Required name attribute */
	if (device_create_file(&pdev->dev, &dev_attr_sgx_dvfs_min_lock) < 0)
		PVR_LOG(("device_create_file: dev_attr_sgx_dvfs_min_lock fail"));
	if (device_create_file(&pdev->dev, &dev_attr_sgx_dvfs_max_lock) < 0)
		PVR_LOG(("device_create_file: dev_attr_sgx_dvfs_max_lock fail"));
	if (device_create_file(&pdev->dev, &dev_attr_sgx_dvfs_volt_table) < 0)
		PVR_LOG(("device_create_file: dev_attr_sgx_dvfs_volt_table fail"));

	 /* Generate DVFS table list*/
	for( i = 0; i < GPU_DVFS_MAX_LEVEL ; i++) {
	    offset = sprintf(sgx_dvfs_table_string+total, "%d\n", gdata[i].clock);
	    total += offset;
	}

	sgx_dvfs_table = sgx_dvfs_table_string;
	if (device_create_file(&pdev->dev, &dev_attr_sgx_dvfs_table) < 0)
		PVR_LOG(("device_create_file: dev_attr_sgx_dvfs_table fail"));
}
Example #7
0
/*----------------------------------------------------------------------------*/
int sobel_y_image(my1Image *src, my1Image *dst)
{
	int coeff[] = { -1,-2,-1, 0,0,0, 1,2,1 };
	my1Mask mask;

	if(createmask(&mask,3)==0x0)
		return -1;

	setmask(&mask,coeff);
	mask.orig_x = 1;
	mask.orig_y = 1;

	filter_image(src,dst,&mask);
	freemask(&mask);

	return 0;
}
Example #8
0
void fbcon_vga_planes_revc(struct display *p, int xx, int yy)
{
	char *where = p->screen_base + xx + yy * p->line_length * fontheight(p);
	int y;
	
	setmode(0);
	setop(0x18);
	setsr(0xf);
	setcolor(0xf);
	selectmask();

	setmask(0xff);
	for (y = 0; y < fontheight(p); y++) {
		rmw(where);
		where += p->line_length;
	}
}
Example #9
0
/*----------------------------------------------------------------------------*/
int laplace_image(my1Image *src, my1Image *dst)
{
	int coeff[] = { 0,-1,0, -1,4,-1, 0,-1,0 };
	my1Mask mask;

	if(createmask(&mask,3)==0x0)
		return -1;

	setmask(&mask,coeff);
	mask.orig_x = 1;
	mask.orig_y = 1;

	filter_image(src,dst,&mask);
	freemask(&mask);

	return 0;
}
Example #10
0
void vga16_putc(unsigned char *cdat, int yy, int xx, int fg, int bg)
{
        int y;
        char *where = fb_mem + xx/8 + yy * fb_line_length;

        setmode(2);
        setop(0);
        setsr(0xf);
        setcolor(fg);
        selectmask();

        setmask(0xff);
        *where = bg;
        rmb();
        *(volatile char*)where; /* fill latches */
        setmode(3);
        wmb();
        *(volatile char*)where; /* fill latches */
        setmode(3);
        wmb();
        for (y = 0; y < 16; y++, where += fb_line_length)
                *where = cdat[y];
        wmb();
}
Example #11
0
/* 6.96 in my test */
void fbcon_vga_planes_putcs(struct vc_data *conp, struct display *p, const unsigned short *s,
		   int count, int yy, int xx)
{
	int fg = attr_fgcol(p,*s);
	int bg = attr_bgcol(p,*s);

	char *where;
	int n;

	setmode(2);
	setop(0);
	setsr(0xf);
	setcolor(fg);
	selectmask();

	setmask(0xff);
	where = p->screen_base + xx + yy * p->line_length * fontheight(p);
	writeb(bg, where);
	rmb();
	readb(where); /* fill latches */
	setmode(3);	
	wmb();
	for (n = 0; n < count; n++) {
		int y;
		int c = *s++ & p->charmask;
		u8 *cdat = p->fontdata + (c & p->charmask) * fontheight(p);

		for (y = 0; y < fontheight(p); y++, cdat++) {
			writeb (*cdat, where);
			where += p->line_length;
		}
		where += 1 - p->line_length * fontheight(p);
	}
	
	wmb();
}
Example #12
0
/* 28.50 in my test */
void fbcon_ega_planes_putcs(struct vc_data *conp, struct display *p, const unsigned short *s,
		   int count, int yy, int xx)
{
	int fg = attr_fgcol(p,scr_readw(s));
	int bg = attr_bgcol(p,scr_readw(s));

	char *where;
	int n;

	setmode(2);
	setop(0);
	selectmask();

	setmask(0xff);
	where = p->screen_base + xx + yy * p->line_length * fontheight(p);
	writeb(bg, where);
	rmb();
	readb(where); /* fill latches */
	wmb();
	selectmask();
	for (n = 0; n < count; n++) {
		int c = scr_readw(s++) & p->charmask;
		u8 *cdat = p->fontdata + c * fontheight(p);
		u8 *end = cdat + fontheight(p);

		while (cdat < end) {
			outb(*cdat++, GRAPHICS_DATA_REG);	
			wmb();
			writeb(fg, where);
			where += p->line_length;
		}
		where += 1 - p->line_length * fontheight(p);
	}
	
	wmb();
}
Example #13
0
    void logger::init(Facility facility, bitset<8>mask)
    {
#ifdef _WIN32
        WinLog::Create(ident);
#else
        int fac = LOG_DAEMON;
        switch (facility) {
            case AUTH:
                fac = LOG_AUTH;
                break;
            case AUTHPRIV:
                fac = LOG_AUTHPRIV;
                break;
            case CRON:
                fac = LOG_CRON;
                break;
            case DAEMON:
            default:
                fac = LOG_DAEMON;
                break;
            case FTP:
                fac = LOG_FTP;
                break;
            case KERN:
                fac = LOG_KERN;
                break;
            case LOCAL0:
                fac = LOG_LOCAL0;
                break;
            case LOCAL1:
                fac = LOG_LOCAL1;
                break;
            case LOCAL2:
                fac = LOG_LOCAL2;
                break;
            case LOCAL3:
                fac = LOG_LOCAL3;
                break;
            case LOCAL4:
                fac = LOG_LOCAL4;
                break;
            case LOCAL5:
                fac = LOG_LOCAL5;
                break;
            case LOCAL6:
                fac = LOG_LOCAL6;
                break;
            case LOCAL7:
                fac = LOG_LOCAL7;
                break;
            case LPR:
                fac = LOG_LPR;
                break;
            case MAIL:
                fac = LOG_MAIL;
                break;
            case NEWS:
                fac = LOG_NEWS;
                break;
            case SYSLOG:
                fac = LOG_SYSLOG;
                break;
            case USER:
                fac = LOG_USER;
                break;
            case UUCP:
                fac = LOG_UUCP;
                break;
        }
        openlog(ident, LOG_PID|LOG_NDELAY, fac);
        // cout << "openlog('" << ident << "', LOG_PID|LOG_NDELAY," << hex << fac << dec << ")" << endl;
#endif
        setmask(mask);
        enable();
    }
Example #14
0
int
main(int argc, char **argv)
{
	int ch, omode = 0, readonly = 0;
	vlong length = 0;
	char *end;

	bufcnt = Bufcount;
	offset = 0;
	setbuf(stdin, NULL);
	progname = *argv;
	while ((ch = getopt(argc, argv, "b:dsrm:o:l:")) != -1) {
		switch (ch) {
		case 'b':
			bufcnt = atoi(optarg);
			break;
		case 'd':
#ifdef O_DIRECT
			omode |= O_DIRECT;
#endif
			break;
		case 's':
			omode |= O_SYNC;
			break;
		case 'r':
			readonly = 1;
			break;
		case 'm':
			setmask(optarg);
			break;
		case 'o':
			offset = strtoll(optarg, &end, 0);
			if (end == optarg || offset < 0)
				usage();
			break;
		case 'l':
			length = strtoll(optarg, &end, 0);
			if (end == optarg || length < 1)
				usage();
			break;
		case '?':
		default:
			usage();
		}
	}
	argc -= optind;
	argv += optind;
	if (argc != 4 || bufcnt <= 0)
		usage();
	omode |= readonly ? O_RDONLY : O_RDWR;
	bfd = open(argv[3], omode);
	if (bfd == -1) {
		perror("open");
		exit(1);
	}
	shelf = atoi(argv[0]);
	slot = atoi(argv[1]);
	setserial(shelf, slot);
	size = getsize(bfd);
	size /= 512;
	if (size <= offset) {
                if (offset)
                        fprintf(stderr,
                                "Offset %lld too large for %lld-sector export\n",
                                offset,
                                size);
                else
                        fputs("0-sector file size is too small\n", stderr);
		exit(1);
	}
	size -= offset;
	if (length) {
		if (length > size) {
			fprintf(stderr, "Length %llu too big - exceeds size of file!\n", offset);
			exit(1);
		}
		size = length;
	}
	ifname = argv[2];
	sfd = dial(ifname, bufcnt);
	getea(sfd, ifname, mac);
	printf("pid %ld: e%d.%d, %lld sectors %s\n",
		(long) getpid(), shelf, slot, size,
		readonly ? "O_RDONLY" : "O_RDWR");
	fflush(stdout);
	atainit();
	aoe();
	return 0;
}
Example #15
0
 void logger::setmaskByName(const string & names)
 {
     setmask(namesToBitset(names));
 }
Example #16
0
void pwm_update(void) 
{
  uint8_t i, j, k;
  uint16_t tim_k ;
  uint16_t min;
  uint32_t tmp,tmp2;
  
  // PWM Maske für Start berechnen
  // gleichzeitig die Bitmasken generieren und PWM Werte kopieren
  
  pwm_sync = 0 ; // Swap vermeiden während update
  
  tmp = 0;
  tmp2= 1;
  
  for (i=0;i<PWM_CHANNELS;i++) pwm_setting[i+1] = pgm_read_word(&LogCurve[(Actual[i]>>8)]) ;
  
  
  for(i=1; i<=(PWM_CHANNELS); i++) {
    setmask(main_ptr_mask,i,~tmp2) ;
    if (pwm_setting[i]!=0) tmp |= tmp2;        // Maske zum setzen der IOs am PWM Start
    tmp2 <<= 1;
  }
  
  setmask(main_ptr_mask,0,tmp) ;
  
  // PWM settings sortieren; Einfügesortieren
  
  for(i=1; i<=PWM_CHANNELS; i++) {
    min=PWM_STEPS-1;
    k=i;
    for(j=i; j<=PWM_CHANNELS; j++) {
      if (pwm_setting[j]<min) {
	k=j;                                // Index und PWM-setting merken
	min = pwm_setting[j];
      }
    }
    if (k!=i) {
      // ermitteltes Minimum mit aktueller Sortiertstelle tauschen
      tim_k = pwm_setting[k];
      pwm_setting[k] = pwm_setting[i];
      pwm_setting[i] = tim_k;
      readmask(main_ptr_mask,k,&tmp) ;	
      readmask(main_ptr_mask,i,&tmp2) ;
      setmask(main_ptr_mask,k,tmp2) ;
      setmask(main_ptr_mask,i,tmp) ;
    }
  }
  
  // Gleiche PWM-Werte vereinigen, ebenso den PWM-Wert 0 löschen falls vorhanden
  
  k=PWM_CHANNELS;             // PWM_CHANNELS Datensätze
  i=1;                        // Startindex
  
  while(k>i) {
    while ( ((pwm_setting[i]==pwm_setting[i+1]) || (pwm_setting[i]==0))  && (k>i) ) {
      
      // aufeinanderfolgende Werte sind gleich und können vereinigt werden
      // oder PWM Wert ist Null
      if (pwm_setting[i]!=0) {
	readmask(main_ptr_mask,i,&tmp) ;
	readmask(main_ptr_mask,i+1,&tmp2) ;
	setmask(main_ptr_mask,i+1,tmp&tmp2) ;
      } ;
      
      // Datensatz entfernen,
      // Nachfolger alle eine Stufe hochschieben
      for(j=i; j<k; j++) {
	pwm_setting[j] = pwm_setting[j+1];
	readmask(main_ptr_mask,j+1,&tmp) ;
	setmask(main_ptr_mask,j,tmp) ;
      }
      k--;
    }
    i++;
  }
  
  // letzten Datensatz extra behandeln
  // Vergleich mit dem Nachfolger nicht möglich, nur löschen
  // gilt nur im Sonderfall, wenn alle Kanäle 0 sind
  if (pwm_setting[i]==0) k--;
  
  // Zeitdifferenzen berechnen
  
  if (k==0) { // Sonderfall, wenn alle Kanäle 0 sind
    main_ptr_time[0]=(uint16_t)T_PWM*PWM_STEPS/2;
    main_ptr_time[1]=(uint16_t)T_PWM*PWM_STEPS/2;
    k=1;
  }
  else {
    i=k;
    main_ptr_time[i]=(uint16_t)T_PWM*(PWM_STEPS-pwm_setting[i]);
    tim_k=pwm_setting[i];
    i--;
    for (; i>0; i--) {
      main_ptr_time[i]=(uint16_t)T_PWM*(tim_k-pwm_setting[i]);
      tim_k=pwm_setting[i];
    }
    main_ptr_time[0]=(uint16_t)T_PWM*tim_k;
  }
  
  // auf Sync warten
  pwm_cnt_max_tmp = k;
  pwm_sync=1;             // Sync wird im Interrupt gesetzt
  pwm_updated = 1 ;
}
Example #17
0
int kmain(void* mbinfo, unsigned int magic, unsigned int* pagedirectory){
	printf("Magic number: 0x%08X\n", magic);
	printf("Page directory located at: 0x%08X\n", pagedirectory);
	printf("Initializing memory management\n");
	init_mm(pagedirectory);
	printf("Multiboot structure at 0x%08X, total size: %u bytes\n",mbinfo,*((unsigned int*)mbinfo));
	void* tags_end = mbinfo+*((unsigned int*)mbinfo);
	mbinfo += 8;
	while(mbinfo<tags_end){
		void* tag_start = mbinfo;
		unsigned int tag_type = *((unsigned int*)mbinfo);
		if(!tag_type) break;
		unsigned int tag_size = *((unsigned int*)(mbinfo+4));
		mbinfo+=8;
		switch(tag_type){
		case 1:
			printf("Command line: %s\n",(char*)mbinfo);
			break;
		case 2:	
			printf("Bootloader name: %s\n",(char*)mbinfo);
			break;
		case 4:
			printf("Free: %u KB lower memory, %u KB upper memory\n",*((unsigned int*)mbinfo),*((unsigned int*)(mbinfo+4)));
			break;
		case 5:
			printf("Booted from device 0x%08X, partition 0x%08X, subpartition 0x%08X\n",*((unsigned int*)mbinfo),*((unsigned int*)(mbinfo+4)),*((unsigned int*)(mbinfo+8)));
			break;
		case 6:	{
				unsigned int entry_size = *((unsigned int*)mbinfo);
				mbinfo += 4;
				printf("Memory map - each entry is version %u and has %u bytes\n", *(unsigned int*)mbinfo, entry_size);
				mbinfo += 4;
				while((unsigned int)mbinfo<(unsigned int)tag_start+tag_size){
					unsigned long chunk_start = *((unsigned long*)mbinfo);
					unsigned long chunk_len = *((unsigned long*)(mbinfo+8));
					unsigned long chunk_end = chunk_start+chunk_len-1;
					unsigned int chunk_type = *((unsigned int*)(mbinfo+16));
					printf("Entry: %016lX - %016lX, type %u ",chunk_start,chunk_end,chunk_type);
					switch(chunk_type){
					case 1: printf("(available)\n"); break;
					case 3: printf("(available, ACPI info)\n"); break;
					case 4: printf("(hibernation-preserved)\n"); break;
					default: printf("(reserved)\n"); break;
					}
					mbinfo+=entry_size;
				}
			}
			break;
		case 7:{
				unsigned short vbe_mode =  *((unsigned short*)(mbinfo));
				unsigned short vbe_interface_seg = *((unsigned short*)(mbinfo+2));
				unsigned short vbe_interface_off = *((unsigned short*)(mbinfo+4));
				unsigned short vbe_interface_len = *((unsigned short*)(mbinfo+6));
				unsigned char* vbe_control_info = (unsigned short*)(mbinfo+8);
				unsigned char* vbe_control_info_end = (unsigned short*)(mbinfo+520);
				unsigned char* vbe_mode_info = (unsigned short*)(mbinfo+520);
				unsigned char* vbe_mode_info_end = (unsigned short*)(mbinfo+776);
				printf("VBE mode 0x%08X, interface segment 0x%08X, interface offset 0x%08X, interface length 0x%08X\n",
					vbe_mode,vbe_interface_seg,vbe_interface_off,vbe_interface_len);
				printf("VBE control info at 0x%08X, VBE mode info at 0x%08X\n",vbe_control_info,vbe_mode_info);
			}
			break;
		case 8:
			fb_addr = *((void**)mbinfo);
			colorbuffer = (unsigned int*) fb_addr;
			fb_pitch = *((unsigned int*)(mbinfo+8));
			fb_width = *((unsigned int*)(mbinfo+12));
			fb_height = *((unsigned int*)(mbinfo+16));
			fb_bpp = *((unsigned char*)(mbinfo+20));
			fb_type = *((unsigned char*)(mbinfo+21));
			mbinfo+=22;	
			printf("Framebuffer 0x%016X, pitch %u bytes, resolution %ux%u, %u bpp, type %u\n",fb_addr,fb_pitch,fb_width,fb_height,fb_bpp,fb_type);
			fb_end = (void*)(fb_addr+fb_pitch*fb_height);
			for(unsigned int i=fb_addr;i<=fb_end;i+=0x00400000) four_meg_identity_map(i);
			switch(fb_type){
			case 0:
				printf("Palette (%u colors): ",*((unsigned int*)mbinfo));
				while((unsigned int)mbinfo<(unsigned int)tag_start+tag_size){
					unsigned char r = *((unsigned char*)mbinfo++);
					unsigned char g = *((unsigned char*)mbinfo++);
					unsigned char b = *((unsigned char*)mbinfo++);
					printf("%02X%02X%02X ",r,g,b);
				}
				printf("\n");
			}
			init_video(fb_addr,fb_width,fb_height);
			redrawallchars();
			break;
		case 9:
			//printf("ELF section headers, ignoring\n");
			break;
		case 10:
			//printf("APM info, ignoring\n");
			break;
		default:
			printf("Unknown tag type %u, size %u, starts at 0x%08X. Contents:\n",tag_type,tag_size,tag_start);
			while((unsigned int)mbinfo<(unsigned int)tag_start+tag_size){
				printf("%c",*((unsigned char*)mbinfo++));
			}
			printf("\n");
			break;
		}
		mbinfo=tag_start+tag_size;
		if((unsigned int)mbinfo%8) mbinfo+=(8-(unsigned int)mbinfo%8);
	}
	printf("0x%08X : 0x%08X\n",fb_addr, pagedirectory[(unsigned int)fb_addr>>22]);
	printf("Initializing PIC and IDT\n");
	init_pic();
	setmask(0xFFFC);
	init_idt();
	printf("Initializing timer to 10 Hz\n");
	init_timer(100);
	asm volatile("sti;");
	for(;;){}
	return 0xC0DED1ED;
}
Example #18
0
/*------------------------------------------------------------------------
 *  icmp_in  -  handle ICMP packet coming in from the network
 *------------------------------------------------------------------------
 */
int
icmp_in(struct netif *pni, struct ep *pep)
{
	struct	ip	*pip;
	struct	icmp	*pic;
	int		i, len;

	pip = (struct ip *)pep->ep_data;
	pic = (struct icmp *) pip->ip_data;

	len = pip->ip_len - IP_HLEN(pip);
	if (cksum((WORD *)pic, len)) {
		IcmpInErrors++;
		freebuf(pep);
		return SYSERR;
	}
	IcmpInMsgs++;
	switch(pic->ic_type) {
	case ICT_ECHORQ:
		IcmpInEchos++;
		return icmp(ICT_ECHORP, 0, pip->ip_src, pep, 0);
	case ICT_MASKRQ:
		IcmpInAddrMasks++;
		if (!gateway) {
			freebuf(pep);
			return OK;
		}
		pic->ic_type = (char) ICT_MASKRP;
		*(IPaddr *)pic->ic_data = netmask(pip->ip_dst);
		break;
	case ICT_MASKRP:
		IcmpInAddrMaskReps++;
		for (i=0; i<Net.nif; ++i)
			if (nif[i].ni_ip == pip->ip_dst)
				break;
		if (i != Net.nif) {
			setmask(i, *(IPaddr *)pic->ic_data);
			send(pic->ic_id, ICT_MASKRP);
		}
		freebuf(pep);
		return OK;
	case ICT_ECHORP:
		IcmpInEchoReps++;
		if (send(pic->ic_id, (int)pep) != OK)
			freebuf(pep);
		return OK;
	case ICT_REDIRECT:
		IcmpInRedirects++;
		icredirect(pep);
		return OK;
	case ICT_DESTUR: IcmpInDestUnreachs++;	freebuf(pep); return OK;
	case ICT_SRCQ:	 IcmpInSrcQuenchs++;	freebuf(pep); return OK;
	case ICT_TIMEX:	 IcmpInTimeExcds++;	freebuf(pep); return OK;
	case ICT_PARAMP: IcmpInParmProbs++;	freebuf(pep); return OK;
	case ICT_TIMERQ: IcmpInTimestamps++;	freebuf(pep); return OK;
	case ICT_TIMERP: IcmpInTimestampReps++;	freebuf(pep); return OK;
	default:
		IcmpInErrors++;
		freebuf(pep);
		return OK;
	}
	icsetsrc(pip);

	len = pip->ip_len - IP_HLEN(pip);

	pic->ic_cksum = 0;
	pic->ic_cksum = cksum((WORD *)pic, len);

	IcmpOutMsgs++;
	ipsend(pip->ip_dst, pep, len, IPT_ICMP, IPP_INCTL, IP_TTL);
	return OK;
}