Example #1
0
int VFL_Verify(void)
{
	int i;
	int foundSignature = false;

	LOGDBG("ftl: Attempting to read %d pages from first block of first bank.\n", NANDGeometry->pagesPerBlock);
	for(i = 0; i < NANDGeometry->pagesPerBlock; i++) {
		int ret;
		if((ret = nand_read_alternate_ecc(0, i, PageBuffer)) == 0) {
			u32 id = *((u32*) PageBuffer);
			if(id == FTL_ID_V1 || id == FTL_ID_V2 || id == FTL_ID_V3) {
				LOG("ftl: Found production format: %x\n", id);
				foundSignature = true;
				break;
			} else {
				LOGDBG("ftl: Found non-matching signature: %x\n", ((u32*) PageBuffer));
			}
		} else {
			LOGDBG("ftl: page %d of first bank is unreadable: %x!\n", i, ret);
		}
	}

	if(!foundSignature || !hasDeviceInfoBBT()) {
		LOG("ftl: no signature or production format.\n");
		return -1;
	}

	return 0;
}
Example #2
0
File: ppp_ip.c Project: Deanzou/ppp
/* -----------------------------------------------------------------------------
attach the PPPx interface ifp to the network protocol IP,
called when the ppp interface is ready for ppp traffic
----------------------------------------------------------------------------- */
errno_t ppp_ip_attach(ifnet_t ifp, protocol_family_t protocol)
{
    int					ret;
    struct ifnet_attach_proto_param   reg;
    struct ppp_if		*wan = (struct ppp_if *)ifnet_softc(ifp);
    
    LOGDBG(ifp, ("ppp_ip_attach: name = %s, unit = %d\n", ifnet_name(ifp), ifnet_unit(ifp)));

    if (wan->ip_attached) 
        return 0;	// already attached

    bzero(&reg, sizeof(struct ifnet_attach_proto_param));
	
	reg.input = ppp_ip_input;
	reg.pre_output = ppp_ip_preoutput;
	reg.ioctl = ppp_ip_ioctl;
	ret = ifnet_attach_protocol(ifp, PF_INET, &reg);
    LOGRETURN(ret, ret, "ppp_ip_attach: ifnet_attach_protocol error = 0x%x\n");
	
    LOGDBG(ifp, ("ppp_i6_attach: ifnet_attach_protocol family = 0x%x\n", protocol));
	ifnet_find_by_name("lo0", &wan->lo_ifp);
	wan->ip_attached = 1;
	
    return 0;
}
Example #3
0
/* -----------------------------------------------------------------------------
Handle a CCP packet.  `rcvd' is 1 if the packet was received,
0 if it is about to be transmitted.
mbuf points to the ccp payload (doesn't include FF03 and 80FD)
----------------------------------------------------------------------------- */
void ppp_comp_ccp(struct ppp_if *wan, mbuf_t m, int rcvd)
{
    u_char 	*p = mbuf_data(m);
    int 	slen;
    
    slen = CCP_LENGTH(p);
    if (slen > mbuf_pkthdr_len(m)) {
        LOGDBG(wan->net, ("ppp_comp_ccp: not enough data in mbuf (expected = %d, got = %d)\n",
		   slen, mbuf_pkthdr_len(m)));
	return;
    }
    
    switch (CCP_CODE(p)) {
    case CCP_CONFREQ:
    case CCP_TERMREQ:
    case CCP_TERMACK:
	/* CCP must be going down - disable compression */
        wan->sc_flags &= ~(rcvd ? SC_COMP_RUN : SC_DECOMP_RUN);
	break;

    case CCP_CONFACK:
	if (wan->sc_flags & SC_CCP_OPEN && !(wan->sc_flags & SC_CCP_UP)
	    && slen >= CCP_HDRLEN + CCP_OPT_MINLEN
	    && slen >= CCP_OPT_LENGTH(p + CCP_HDRLEN) + CCP_HDRLEN) {
	    if (rcvd) {
		/* peer is agreeing to send compressed packets. */
		if (wan->rc_state
		    && (*wan->rcomp->decomp_init)
			(wan->rc_state, p + CCP_HDRLEN, slen - CCP_HDRLEN,
			 ifnet_unit(wan->net), 0, wan->mru, ifnet_flags(wan->net) & IFF_DEBUG)) {
		    wan->sc_flags |= SC_DECOMP_RUN;
		    wan->sc_flags &= ~(SC_DC_ERROR | SC_DC_FERROR);
		}
	    } else {
		/* we're agreeing to send compressed packets. */
		if (wan->xc_state
		    && (*wan->xcomp->comp_init)
			(wan->xc_state, p + CCP_HDRLEN, slen - CCP_HDRLEN,
			 ifnet_unit(wan->net), 0, ifnet_mtu(wan->net), ifnet_flags(wan->net) & IFF_DEBUG)) {
		    wan->sc_flags |= SC_COMP_RUN;
		}
	    }
	}
	break;

    case CCP_RESETACK:
	if (wan->sc_flags & SC_CCP_UP) {
	    if (rcvd) {
		if (wan->rc_state && (wan->sc_flags & SC_DECOMP_RUN)) {
		    (*wan->rcomp->decomp_reset)(wan->rc_state);
		    wan->sc_flags &= ~SC_DC_ERROR;
		}
	    } else {
		if (wan->xc_state && (wan->sc_flags & SC_COMP_RUN))
		    (*wan->xcomp->comp_reset)(wan->xc_state);
	    }
	}
	break;
    }
}
static void lircd_connect(void)
{
  struct sockaddr_un addr;

  if (fd_lirc >= 0) {
    close(fd_lirc);
    fd_lirc = -1;
  }

  if (!lirc_device_name) {
    LOGDBG("no lirc device given");
    return;
  }

  addr.sun_family = AF_UNIX;
  strncpy(addr.sun_path, (char*)lirc_device_name, sizeof(addr.sun_path));
  addr.sun_path[sizeof(addr.sun_path)-1] = 0;

  if ((fd_lirc = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
    LOGERR("lirc error: socket() < 0");
    return;
  }

  if (connect(fd_lirc, (struct sockaddr *)&addr, sizeof(addr))) {
    LOGERR("lirc error: connect(%s) < 0", lirc_device_name);
    close(fd_lirc);
    fd_lirc = -1;
    return;
  }
}
Example #5
0
/*
 * NvsLogin
 * 登录,登录后才能使用相应权限的命令
 */
int YN_Login(char *pDevIp, unsigned short u16DevPort, StAccount *stAccount)
{
    int ret;
    stLoginInfo Login;

    ret = ClientSetCmdByIp(_CmdLogin, stAccount, sizeof(StAccount), pDevIp, u16DevPort);
    if(ret < 0)
    {
        LOGERR("ClientSetCmdByIp error\n");
        return -1;
    }

    strcpy(Login.pDevIP, pDevIp);
    Login.u16DevPort = u16DevPort;
    Login.stUserAccount = *stAccount;
    Login.s32LoginID = s_s32LoginID;

    PushQueueElem(&s_UserLoginInfoQueue, s_s32LoginID, &Login);

    s_s32LoginID++;

    LOGDBG("LoginID=%d\n", s_s32LoginID -1);

    return (s_s32LoginID - 1);
}
int h264_parse_sps(const uint8_t *buf, int len, h264_sps_data_t *sps)
{
  br_state br = BR_INIT(buf, len);
  int profile_idc, pic_order_cnt_type;
  int frame_mbs_only;
  int i, j;

  profile_idc = br_get_u8(&br);
  LOGDBG("H.264 SPS: profile_idc %d", profile_idc);
  /* constraint_set0_flag = br_get_bit(br);    */
  /* constraint_set1_flag = br_get_bit(br);    */
  /* constraint_set2_flag = br_get_bit(br);    */
  /* constraint_set3_flag = br_get_bit(br);    */
  /* reserved             = br_get_bits(br,4); */
  /* level_idc            = br_get_u8(br);     */ 
  br_skip_bits(&br, 16);
  br_skip_ue_golomb(&br);   /* seq_parameter_set_id */
  if (profile_idc >= 100) {
    if (br_get_ue_golomb(&br) == 3) /* chroma_format_idc      */
      br_skip_bit(&br);     /* residual_colour_transform_flag */
    br_skip_ue_golomb(&br); /* bit_depth_luma - 8             */
    br_skip_ue_golomb(&br); /* bit_depth_chroma - 8           */
    br_skip_bit(&br);       /* transform_bypass               */
    if (br_get_bit(&br))    /* seq_scaling_matrix_present     */
      for (i = 0; i < 8; i++)  
	if (br_get_bit(&br)) { /* seq_scaling_list_present    */
	  int last = 8, next = 8, size = (i<6) ? 16 : 64;
	  for (j = 0; j < size; j++) {
	    if (next)
	      next = (last + br_get_se_golomb(&br)) & 0xff;
	    last = next ?: last;
	  }
	}
  }
Example #7
0
/* -----------------------------------------------------------------------------
called from dlil when an ioctl is sent to the interface
----------------------------------------------------------------------------- */
errno_t ppp_ipv6_ioctl(ifnet_t ifp, protocol_family_t protocol,
									 u_long command, void* argument)
{
    struct sockaddr_in6  addr6;
    int 		error = 0;

    switch (command) {

        case SIOCSIFADDR:
        case SIOCAIFADDR:
            LOGDBG(ifp, ("ppp_ipv6_ioctl: cmd = SIOCSIFADDR/SIOCAIFADDR\n"));

	    error = ifaddr_address(argument, (struct sockaddr *)&addr6, sizeof (addr6));
	    if (error != 0) {
                error = EAFNOSUPPORT;
                break;
	    }

            // only an IPv6 address should arrive here
            if (addr6.sin6_family != AF_INET6) {
                error = EAFNOSUPPORT;
                break;
            }
            break;

        default :
            error = EOPNOTSUPP;
    }
    
    return error;
}
Example #8
0
/**
 ** Changement de taille d'une zone 
 **/
void *
smMemRealloc(void *pBlock, size_t newSize)
{
    SM_MALLOC_CHUNK *c;
    void *newBlock;

    /* get a pointer to the old block header */
    c = (SM_MALLOC_CHUNK *)pBlock - 1;
    if (c->next != MALLOC_MAGIC) {
       LOGDBG(("comLib:smMemLib: realloc(something not returned by malloc)\n"));
       return NULL;
    }

    /* alloc new block */
    newBlock = smMemMalloc(newSize);
    if (newBlock == NULL) {
	return NULL;
    }
    if (pBlock != NULL) {
	if (newSize > c->length)
            memcpy(newBlock, pBlock, c->length);
        else
            memcpy(newBlock, pBlock, newSize);
	smMemFree(pBlock);
    }
    return newBlock;
}
Example #9
0
void Decode(mbuf_t *m)
{
    LOGDBG(SEC_DECODE_DBG_BIT, "==========>enter decode()\n");
	if( DECODE_OK != DecodeEthernet(m, GET_PKT_DATA(m), GET_PKT_LEN(m)))
    {
        output_drop_proc(m);
    }

	return;
}
Example #10
0
/**
 ** Allocation d'un device h2
 **/
int
h2devAlloc(const char *name, H2_DEV_TYPE type)
{
    int i;

    if (h2devAttach() == ERROR) {
	return ERROR;
    }
    h2semTake(0, WAIT_FOREVER);

    /* Verifie que le nom n'existe pas */
    if (type != H2_DEV_TYPE_SEM && h2devFindAux(name, type) != ERROR) {
	h2semGive(0);
	errnoSet(S_h2devLib_DUPLICATE_DEVICE_NAME);
	return ERROR;
    }
    /* Recherche un device libre */
    for (i = 0; i < H2_DEV_MAX; i++) {
	if (h2Devs[i].type == H2_DEV_TYPE_NONE) {
	    /* Trouve' */
	    if (snprintf(h2Devs[i].name, H2_DEV_MAX_NAME, "%s", name) 
		>= H2_DEV_MAX_NAME) {
		h2semGive(0);
		LOGDBG(("comLib:h2devAlloc: device name too long\n"));
		errnoSet(S_h2devLib_BAD_PARAMETERS);
		return ERROR;
	    }
	    strncpy(h2Devs[i].name, name, H2_DEV_MAX_NAME);
	    h2Devs[i].type = type;
	    h2Devs[i].uid = getuid();
	    h2semGive(0);
	    LOGDBG(("comLib:h2devAlloc: created device %d\n", i));
	    return i;
	}
    } /* for */

    /* Pas de device libre */
    h2semGive(0);
    errnoSet(S_h2devLib_FULL);
    return ERROR;
}
Example #11
0
bool SCP_TriggerMeasurement() {
	// check the preconditions:
	
	// 1. check whether the device is active
	if (SCP_PD_POUT & SCP_PD_PIN) {
		// the device is in the power down mode, it wasn't activated or the activation has failed
		LOGDBG("SCPt!PD");

		return false;
	}

	// 2. the request can only be issued when the DRDY line is low
	if (SCP_DRDY_PINPUT & SCP_DRDY_PIN) {
		LOGDBG("SCPt!DRDY");

		return false; // a dummy read could be executed here but it's actually user's resposibility
	}
	
	// the measurement is triggered by the low-to-high edge of the TRIG pin
	// the TRIG is set to low during reading of the last measrurement, so it's safe to assume
	// the TRIG is low 
	
	// 3. the request can only be issued when the TRIG is low
	if (SCP_TRIG_POUT & SCP_TRIG_PIN) {
		LOGDBG("SCPt!TRIG");
		
		return false;
	}
	
	//
	// preconditions check passed
	//
	
	// store the current timestamp
	RTC_GetRawTime(&SCP_MeasurementTimestamp);

	// trigger the conversion
	SET(SCP_TRIG_POUT, SCP_TRIG_PIN);
	
	return true;
}
Example #12
0
static bool findDeviceInfoBBT(int bank, void* deviceInfoBBT)
{
	int lowestBlock = NANDGeometry->blocksPerBank - (NANDGeometry->blocksPerBank / 10);
	int block;

	for(block = NANDGeometry->blocksPerBank - 1; block >= lowestBlock; block--) {
		int page;
		int badBlockCount = 0;
		for(page = 0; page < NANDGeometry->pagesPerBlock; page++) {
			int ret;

			if(badBlockCount > 2) {
				LOGDBG("ftl: findDeviceInfoBBT - too many bad pages, skipping block %d\n", block);
				break;
			}

			ret = nand_read_alternate_ecc(bank, (block * NANDGeometry->pagesPerBlock) + page, PageBuffer);
			if(ret != 0) {
				if(ret == 1) {
					LOGDBG("ftl: findDeviceInfoBBT - found 'badBlock' on bank %d, page %d\n", (block * NANDGeometry->pagesPerBlock) + page);
					badBlockCount++;
				}

				LOGDBG("ftl: findDeviceInfoBBT - skipping bank %d, page %d\n", (block * NANDGeometry->pagesPerBlock) + page);
				continue;
			}

			if(memcmp(PageBuffer, "DEVICEINFOBBT\0\0\0", 16) == 0) {
				if(deviceInfoBBT) {
					memcpy(deviceInfoBBT, PageBuffer + 0x38, *((u32*)(PageBuffer + 0x34)));
				}

				return true;
			} else {
				LOGDBG("ftl: did not find signature on bank %d, page %d\n", (block * NANDGeometry->pagesPerBlock) + page);
			}
		}
	}

	return false;
}
Example #13
0
/**
 ** Liberation d'une zone 
 **/
STATUS 
smMemFree(void *ptr)
{
    SM_MALLOC_CHUNK *oc, *c;

    LOGDBG(("comLib:smMemLib: free 0x%x\n", (unsigned)ptr));

    if (ptr == NULL) {
       LOGDBG(("comLib:smMemLib: free(NULL)\n"));
       return ERROR;
    }
    /* get a pointer to the header */
    oc = (SM_MALLOC_CHUNK *)ptr - 1;
    /* test for allocated bloc */
    if (oc->next != MALLOC_MAGIC) {
	/* what to do ? */
       LOGDBG(("comLib:smMemLib: free(something not returned by malloc)\n"));
       return ERROR;
    }
    /* insert free chunk in the free list */
    insert_after(&smMemFreeList, oc);
    /* test if can merge with preceding chunk */
    c = smObjGlobalToLocal(oc->prev);
    if (c != NULL && 
	oc == (SM_MALLOC_CHUNK *)((char *)c + REAL_SIZE(c->length))) {
	/* merge */
	c->length += REAL_SIZE(oc->length);
	remove_chunk(&smMemFreeList, oc);
	oc = c;
   }
    /* test if can merge with following chunk */
    c = smObjGlobalToLocal(oc->next);
    if (c == (SM_MALLOC_CHUNK *)((char *)oc + REAL_SIZE(oc->length))) {
	/* merge (=> oc->next != NULL) */
	oc->length += REAL_SIZE(c->length);
	remove_chunk(&smMemFreeList, c);
    }
    return OK;
}
void cPluginXinelibOutput::MainThreadHook(void)
{
  TRACEF("cPluginXinelibOutput::MainThreadHook");

  if (m_MakePrimary) {
     LOGDBG("Switching primary device to %d", m_MakePrimary);
     cDevice::SetPrimaryDevice(m_MakePrimary);
     m_MakePrimary = 0;
     }

  if (m_Dev) {
    m_Dev->MainThreadHook();
  }
}
static int gnome_sessionmanager_control(DBusGConnection *connection, int enable)
{
  GError *error;
  DBusGProxy *proxy;
  gboolean ret;

  /* Create a proxy object */
  proxy = dbus_g_proxy_new_for_name(connection,
                                    SM_SERVICE, SM_PATH, SM_INTERFACE);
  if (!proxy) {
    LOGDBG("Failed to get a proxy for " SM_SERVICE);
    return 0;
  }

  error = NULL;
  if (enable) {
    ret = dbus_g_proxy_call(proxy, "Uninhibit", &error,
                            G_TYPE_UINT, cookie,
                            G_TYPE_INVALID, G_TYPE_INVALID);
  } else {
    ret = dbus_g_proxy_call(proxy, "Inhibit", &error,
                            G_TYPE_STRING, GS_APPLICATION_NAME,
                            G_TYPE_UINT,   0,
                            G_TYPE_STRING, GS_REASON_FOR_INHIBIT,
                            G_TYPE_UINT,   12,
                            G_TYPE_INVALID,
                            G_TYPE_UINT, &cookie,
                            G_TYPE_INVALID);
  }

  g_object_unref(proxy);

  if (!ret) {
    /* Check if it's a remote exception or a regular GError */
    if (error->domain == DBUS_GERROR &&
        error->code   == DBUS_GERROR_REMOTE_EXCEPTION) {
      LOGMSG(MSG_RemoteMethodException, dbus_g_error_get_name(error), error->message);
    } else {
      LOGMSG(MSG_GError, error->message);
    }
    g_error_free(error);

    return 0;
  }

  LOGMSG(enable ? MSG_GNOMEScreensaverEnabled : MSG_GNOMEScreensaverDisabled);
  return 1;
}
Example #16
0
/**
 ** Allocation d'une zone dans le segment de memoire partagee
 **/
void *
smMemMalloc(size_t nBytes)
{
    void *result;
    
    if (smMemFreeList == NULL) {
	if (smMemAttach() == ERROR) {
	    return NULL;
	}
    }
    result = internal_malloc(nBytes);

    LOGDBG(("comLib:smMemLib: alloc %u -> 0x%lx\n", 
	    nBytes, (unsigned long)result));
    return result;
}
Example #17
0
/* -----------------------------------------------------------------------------
detach the PPPx interface ifp from the network protocol IPv6,
called when the ppp interface stops ip traffic
----------------------------------------------------------------------------- */
void ppp_ipv6_detach(ifnet_t ifp, protocol_family_t protocol)
{
    int 		ret;
    struct ppp_if		*wan = (struct ppp_if *)ifnet_softc(ifp);

    LOGDBG(ifp, ("ppp_ipv6_detach\n"));

    if (!wan->ipv6_attached)
        return;	// already detached

    ret = ifnet_detach_protocol(ifp, PF_INET6);
	if (ret)
        IOLog("ppp_ipv6_detach: ifnet_detach_protocol error = 0x%x\n", ret);

    wan->ipv6_attached = 0;
}
Example #18
0
File: ppp_ip.c Project: Deanzou/ppp
/* -----------------------------------------------------------------------------
called from dlil when an ioctl is sent to the interface
----------------------------------------------------------------------------- */
errno_t ppp_ip_ioctl(ifnet_t ifp, protocol_family_t protocol,
									 u_long command, void* argument)
{
    struct ppp_if		*wan = (struct ppp_if *)ifnet_softc(ifp);
    struct sockaddr_in  addr, dstaddr;
    int 		error = 0;
    
    switch (command) {

        case SIOCSIFADDR:
        case SIOCAIFADDR:
            LOGDBG(ifp, ("ppp_ip_ioctl: cmd = SIOCSIFADDR/SIOCAIFADDR\n"));

	    error = ifaddr_address(argument, (struct sockaddr *)&addr, sizeof (addr));
	    if (error != 0) {
                error = EAFNOSUPPORT;
                break;
	    }

            // only an IPv4 address should arrive here
            if (addr.sin_family != AF_INET) {
                error = EAFNOSUPPORT;
                break;
            }

	    error = ifaddr_dstaddress(argument, (struct sockaddr *)&dstaddr, sizeof (dstaddr));
	    if (error != 0) {
                error = EAFNOSUPPORT;
                break;
	    }

            // only an IPv4 address should arrive here
            if (dstaddr.sin_family != AF_INET) {
                error = EAFNOSUPPORT;
                break;
            }

            wan->ip_src.s_addr = addr.sin_addr.s_addr;
            wan->ip_dst.s_addr = dstaddr.sin_addr.s_addr;
            break;

        default :
            error = EOPNOTSUPP;
    }
    
    return error;
}
static int mce_control(DBusGConnection *connection, int enable)
{
  GError *error;
  DBusGProxy *proxy;
  gboolean ret = 1;

  /* Create a proxy object */
  proxy = dbus_g_proxy_new_for_name(connection,
                                    MCE_SERVICE, MCE_REQUEST_PATH, MCE_REQUEST_IF);
  if (!proxy) {
    LOGDBG("Failed to get a proxy for " SM_SERVICE);
    return 0;
  }

  error = NULL;
  if (enable) {
    ret = dbus_g_proxy_call(proxy, MCE_CANCEL_PREVENT_BLANK_REQ, &error,
                            G_TYPE_INVALID, G_TYPE_INVALID);
  } else {
    ret = dbus_g_proxy_call(proxy, MCE_PREVENT_BLANK_REQ, &error,
                            G_TYPE_INVALID, G_TYPE_INVALID);
  }

  g_object_unref(proxy);

  if (!ret) {
    /* Check if it's a remote exception or a regular GError */
    if (error->domain == DBUS_GERROR &&
        error->code   == DBUS_GERROR_REMOTE_EXCEPTION) {
      LOGMSG(MSG_RemoteMethodException, dbus_g_error_get_name(error), error->message);
    } else {
      LOGMSG(MSG_GError, error->message);
    }
    g_error_free(error);

    return 0;
  }

  LOGMSG(enable ? MSG_MCEScreensaverEnabled : MSG_MCEScreensaverDisabled);
  return 1;
}
cBackgroundWriterI::cBackgroundWriterI(int fd, int Size, int Margin)
  : m_RingBuffer(Size, Margin)
{
  m_fd = fd;
  m_RingBuffer.SetTimeouts(0, 100);

  m_PutPos = 0;
  m_DiscardStart = 0;
  m_DiscardEnd   = 0;

  m_BufferOverflows = 0;

#if defined(TCP_CORK)
  int iCork = 1;
  if (setsockopt(m_fd, IPPROTO_TCP, TCP_CORK, &iCork, sizeof(int))) {
    if (errno != ENOTSOCK)
      LOGERR("cBackgroundWriter: setsockopt(TCP_CORK) failed");
    m_IsSocket = false;
    errno = 0;
  } else {
    m_IsSocket = true;
  }
#elif defined(TCP_NOPUSH)
  int iCork = 1;
  if (setsockopt(m_fd, IPPROTO_TCP, TCP_NOPUSH, &iCork, sizeof(int))) {
    if (errno != ENOTSOCK)
      LOGERR("cBackgroundWriter: setsockopt(TCP_NOPUSH) failed");
    m_IsSocket = false;
    errno = 0;
  } else {
    m_IsSocket = true;
  }
#endif

  LOGDBG("cBackgroundWriterI initialized (buffer %d kb)", Size/1024);
}
Example #21
0
STATUS
gcomInit(const char *procName, int rcvMboxSize, int replyMboxSize)
{
    char replyMboxName[H2_DEV_MAX_NAME];
    int myTaskNum;
    
    /* record error msgs */
    h2recordErrMsgs("gcomInit", "gcomLib", M_gcomLib, 			
		    sizeof(gcomLibH2errMsgs)/sizeof(H2_ERROR), 
		    gcomLibH2errMsgs);

    /* Appeler la routine d'initialisation des mailboxes */
    if (mboxInit(procName) == ERROR) {
	return ERROR;
    }

    /* Nom du mailbox de replique */
    strncpy (replyMboxName, procName, H2_DEV_MAX_NAME - 1);
    strcat (replyMboxName, "R");

    /* Allouer et Initialiser les tableaux */
    myTaskNum = MY_TASK_DEV;
    sendTab[myTaskNum] = (SEND *)calloc(MAX_SEND, sizeof(SEND));
    if (sendTab[myTaskNum] == NULL) {
	errnoSet(S_gcomLib_MALLOC_FAILED);
	return ERROR;
    }

    letterTab[myTaskNum] = (LETTER *)calloc(MAX_LETTER, sizeof(LETTER));
    if (letterTab[myTaskNum] == NULL) {
	free(sendTab[myTaskNum]);
	sendTab[myTaskNum] = NULL;
	errnoSet(S_gcomLib_MALLOC_FAILED);
	return ERROR;
    }

    LOGDBG(("comLib:gcomInit: arrays allocated for mbox %d (`%s')\n",
	    myTaskNum, procName));

    /* Creation mailbox de reception */
    if (rcvMboxSize != 0) {
	if (mboxCreate(procName, rcvMboxSize, 
		       &rcvMboxTab[myTaskNum]) == ERROR) {
		int e = errnoGet();
		free(letterTab[myTaskNum]);
		free(sendTab[myTaskNum]);
		letterTab[myTaskNum] = NULL;
		sendTab[myTaskNum] = NULL;
		errnoSet(e);
		return ERROR;
	}
    }

    /* Creation mailbox de replique */
    if (replyMboxSize != 0) {
	if (mboxCreate(replyMboxName, replyMboxSize, 
		       &replyMboxTab[myTaskNum]) == ERROR) {
		int e = errnoGet();
		mboxDelete(rcvMboxTab[myTaskNum]);
		free(letterTab[myTaskNum]);
		free(sendTab[myTaskNum]);
		letterTab[myTaskNum] = NULL;
		sendTab[myTaskNum] = NULL;
		errnoSet(e);
		return ERROR;
	}
    }
    return OK;
}
Example #22
0
int get_customer_data(const uint8_t uiFieldIndex, void **const pvAdcFieldData )
{

        uint32_t                                        ret = 0xffffffff;
        uint32_t                                        returned_size = 0;
        struct data_buffer                              cmd_data_in[MAX_DATA_BUF_PARAMS];
        struct data_buffer                              cmd_data_out[MAX_DATA_BUF_PARAMS];
        struct acd_read_cmd_from_host		        params;
        struct acd_read_cmd_to_host		        resp;
	void *ptrHandle = NULL;

	//Initialize ACD by connecting using the GUID
	ret = acd_init(&guid, &ptrHandle);
	if (!(ret == EXIT_SUCCESS && ptrHandle))
	{
		LOGERR("Failed to Initialize ACD: 0x%08x\n", ret);
		goto exit;
	}

        /*
         *      Sanity check
         */
        if(!( (ACD_MIN_FIELD_INDEX <= uiFieldIndex) && (ACD_MAX_FIELD_INDEX >= uiFieldIndex )))
        {
                LOGERR( "field index %u is illegal.\n", uiFieldIndex );
                ret = ACD_READ_ERROR_ILLEGAL_INPUT_PARAMETER;
				goto exit;
        }
		if(!(pvAdcFieldData))
        {
                LOGERR( "pvAdcFieldData is invalid\n" );
                ret = ACD_READ_ERROR_ILLEGAL_INPUT_PARAMETER;
				goto exit;
        }
        /*
         *      Initialize the parameters to zero
         */
        memset( &params, 0, sizeof( params ) );
        memset( &resp, 0, sizeof( resp ) );
        memset( cmd_data_in, 0, sizeof( cmd_data_in ) );
        memset( cmd_data_out, 0, sizeof( cmd_data_out ) );
        /*
         *      Populate the parameter data structures
         */
        params.hdr_req.main_opcode = ACD_MAIN_OPCODE;
        params.hdr_req.sub_opcode = OPCODE_IA2CHAABI_ACD_READ;
        params.index = uiFieldIndex;

        /*
         *      Link-up the parameter data structures
         */
        INIT_FROM_HOST_PARAM_BUF( cmd_data_in[FROM_HOST_PARAM_INDEX], &params, sizeof( params ) );
        INIT_TO_HOST_PARAM_BUF( cmd_data_out[TO_HOST_PARAM_INDEX], &resp, sizeof( resp ) );
        /*
         *      Send the message off to FW
         */
        ret = process_cmd( ptrHandle, DX_SEP_HOST_SEP_PROTOCOL_IA_ACCESS_OP_CODE, cmd_data_in, cmd_data_out, 2 );

        if( ACD_READ_SUCCESS != ret )
        {
                LOGERR( "process_cmd failed: error 0x%x\n", ret );
                ret = ACD_READ_SUCCESS - ret;
				goto exit;
        }

        ret = resp.acd_status;

        if( ACD_READ_SUCCESS != ret && ACD_READ_SECURE_DATA_PROVISIONED_AND_WRITE_ONLY != ret)
        {
                LOGERR( "ACD Command failed in FW: 0x%08x\n", ret );
				mei_print_buffer("get_customer_data response", (uint8_t *)&resp, sizeof(resp)); 
               ret = ACD_READ_SUCCESS - ret;
			   goto exit;
        }

	if (ACD_READ_SECURE_DATA_PROVISIONED_AND_WRITE_ONLY == ret)
	{
		LOGDBG( "Read not allowed on this index\n");
	}

        returned_size = resp.bytes_read;

        LOGDBG("read = %d\n", returned_size);

        *pvAdcFieldData = calloc((size_t)returned_size, sizeof(uint8_t));
        if( NULL == *pvAdcFieldData )
        {
                LOGERR( "unable to allocate the read buffer\n" );
                ret = ACD_READ_ERROR_UMIP_READ_FAILURE;
				goto exit;
        }

        memcpy(*pvAdcFieldData, resp.buf, returned_size);
		ret = returned_size;

exit:

	if (ptrHandle != NULL)
	{
		if (acd_deinit(ptrHandle) != 0)
		{
			LOGERR( "Failed to uninitialize ACD");
		}
		ptrHandle = NULL;
	}

        return ret;

}       //  get_customer_data
cTcpWriter::cTcpWriter(int fd, int Size) :
     cBackgroundWriterI(fd, Size, sizeof(stream_tcp_header_t))
{
  LOGDBG("cTcpWriter initialized (buffer %d kb)", Size/1024);
  Start();
}
/*
  *   @mbuf:
  *   @pkt:    start of l2 header
  *   @len:    len of l2 packet
  */
int DecodeEthernet(mbuf_t *mbuf, uint8_t *pkt, uint16_t len)
{
    EthernetHdr *pethh;

    LOGDBG(SEC_ETHERNET_DBG_BIT, "==============>enter DecodeEthernet\n");

    if (unlikely(len < ETHERNET_HEADER_LEN))
    {
        STAT_L2_HEADER_ERR;
        DP_Log_Func(mbuf);
        return DECODE_DROP;
    }

    pethh = (EthernetHdr *)(pkt);

    if((0 == pethh->eth_dst[0]
        && 0 == pethh->eth_dst[1]
        && 0 == pethh->eth_dst[2]
        && 0 == pethh->eth_dst[3]
        && 0 == pethh->eth_dst[4]
        && 0 == pethh->eth_dst[5]) ||
        (0 == pethh->eth_src[0]
        && 0 == pethh->eth_src[1]
        && 0 == pethh->eth_src[2]
        && 0 == pethh->eth_src[3]
        && 0 == pethh->eth_src[4]
        && 0 == pethh->eth_src[5]))
    {
        STAT_L2_HEADER_ERR;
        DP_Log_Func(mbuf);
        return DECODE_DROP;
    }


    mbuf->ethh = (void *)pethh;

    LOGDBG(SEC_ETHERNET_DBG_BIT, "dst mac is %x:%x:%x:%x:%x:%x\n",
        pethh->eth_dst[0],pethh->eth_dst[1],
        pethh->eth_dst[2],pethh->eth_dst[3],
        pethh->eth_dst[4],pethh->eth_dst[5]);

    LOGDBG(SEC_ETHERNET_DBG_BIT, "src mac is %x:%x:%x:%x:%x:%x\n",
        pethh->eth_src[0],pethh->eth_src[1],
        pethh->eth_src[2],pethh->eth_src[3],
        pethh->eth_src[4],pethh->eth_src[5]);

    LOGDBG(SEC_ETHERNET_DBG_BIT, "eth type is 0x%x\n", pethh->eth_type);

    memcpy(mbuf->eth_dst, pethh->eth_dst, 6);
    memcpy(mbuf->eth_src, pethh->eth_src, 6);

    switch (pethh->eth_type) {
        case ETHERNET_TYPE_IP:
        {
            STAT_L2_RECV_OK;
            return DecodeIPV4(mbuf, pkt + ETHERNET_HEADER_LEN, len - ETHERNET_HEADER_LEN);
        }
    #ifdef ROUTE_PROC_ENABLE
        case ETHERNET_TYPE_ARP:
        {
            if(SEC_OK != oct_pow_se2linux(mbuf))
            {
                STAT_L2_ARP_SE2LINUX_FAIL;
                return DECODE_DROP;
            }
            else
            {
                STAT_L2_ARP_SE2LINUX_OK;
                STAT_L2_RECV_OK;
                return DECODE_OK;
            }
        }
    #endif
        case ETHERNET_TYPE_VLAN:
        case ETHERNET_TYPE_8021QINQ:
        {
            STAT_L2_RECV_OK;
            return DecodeVLAN(mbuf, pkt + ETHERNET_HEADER_LEN, len - ETHERNET_HEADER_LEN);
        }
        default:
        {
            LOGDBG(SEC_ETHERNET_DBG_BIT, "ether type %04x not supported", pethh->eth_type);
            STAT_L2_UNSUPPORT;
        #if 0
            output_fw_proc(mbuf);
        #endif
            Decode_unsupport_proto_handle(mbuf);
            return DECODE_OK;
        }
    }

    return DECODE_OK;
}
cRtspRemuxWriter::cRtspRemuxWriter(int fd, int Size) :
     cBackgroundWriterI(fd, Size, 6)
{
  LOGDBG("cRtspRemuxWriter initialized (buffer %d kb)", Size/1024);
  Start();
}
eOSState cMenuXinelib::ProcessHotkey(eKeys Key)
{
  eOSState NewState = osEnd;
  cString  Message;
  time_t   now      = time(NULL);
  bool     OnlyInfo = ((xc.last_hotkey_time < now-3) || xc.last_hotkey != Key);

  switch (Key) {
    case HOTKEY_DVD:
      cPlayerFactory::Launch(m_Dev, "dvd:/");
      break;

    case HOTKEY_DVD_TRACK1:
      cPlayerFactory::Launch(m_Dev, "dvd:/1");
      break;

    case HOTKEY_LOCAL_FE:
      /* off, on */
      {
        int local_frontend = strstra(xc.local_frontend, xc.s_frontends, 0);

#ifndef OLD_TOGGLE_FE
        if (local_frontend==FRONTEND_NONE)
          // no need to show current frontend if there is no output device ...
          OnlyInfo = false;
#endif
        if (!OnlyInfo) {
#ifndef OLD_TOGGLE_FE
          static int orig_frontend = -1;
          if (orig_frontend < 0)
            orig_frontend = local_frontend;

          if (orig_frontend == FRONTEND_NONE) {
            // no frontends were loaded at startup -> loop thru all frontends
            local_frontend++;
          } else {
            // frontend was loaded at startup -> toggle it on/off
            if (local_frontend == FRONTEND_NONE)
              local_frontend = orig_frontend;
            else
              local_frontend = FRONTEND_NONE;
          }
#else
          local_frontend++;
#endif
          if (local_frontend >= FRONTEND_count)
            local_frontend = 0;
          strn0cpy(xc.local_frontend, xc.s_frontends[local_frontend], sizeof(xc.local_frontend));
          m_Dev->ConfigureWindow(
              xc.fullscreen, xc.width, xc.height, xc.modeswitch, xc.modeline,
              xc.display_aspect, xc.scale_video);
        }
        Message = cString::sprintf("%s %s %s", tr("Local Frontend"),
                                   OnlyInfo ? ":" : "->",
                                   xc.s_frontendNames[local_frontend]);
      }
      break;

    case HOTKEY_NEXT_ASPECT:
      /* auto, 4:3, 16:9, ... */
      if (!OnlyInfo) {
        xc.display_aspect = (xc.display_aspect < ASPECT_count-1) ? xc.display_aspect+1 : 0;
        m_Dev->ConfigureWindow(xc.fullscreen, xc.width, xc.height,
                               xc.modeswitch, xc.modeline, xc.display_aspect,
                               xc.scale_video);
      }
      Message = cString::sprintf("%s %s %s", tr("Aspect ratio"),
                                 OnlyInfo ? ":" : "->",
                                 tr(xc.s_aspects[xc.display_aspect]));
      break;

    case HOTKEY_TOGGLE_VO_ASPECT:
      /* auto, square, 4:3, anamorphic or DVB */
      if (!OnlyInfo) {
        xc.vo_aspect_ratio = (xc.vo_aspect_ratio < VO_ASPECT_count-1) ? xc.vo_aspect_ratio + 1 : 0;
        m_Dev->ConfigureVideo(xc.hue, xc.saturation, xc.brightness, xc.sharpness,
                              xc.noise_reduction, xc.contrast, xc.overscan,
                              xc.vo_aspect_ratio);
      }
      Message = cString::sprintf("%s %s %s", tr("Video aspect ratio"),
                                 OnlyInfo ? ":" : "->",
                                 tr(xc.s_vo_aspects[xc.vo_aspect_ratio]));
      break;

    case HOTKEY_TOGGLE_CROP:
      /* off, force, auto */
      if (!OnlyInfo) {
        if (!xc.autocrop) {
          xc.autocrop = 1;
          xc.autocrop_autodetect = 1;
        } else if (xc.autocrop_autodetect) {
          xc.autocrop_autodetect = 0;
        } else {
          xc.autocrop = 0;
        }
        m_Dev->ConfigurePostprocessing("autocrop",
                                       xc.autocrop ? true : false,
                                       xc.AutocropOptions());
      }

      Message = cString::sprintf("%s %s %s", tr("Crop letterbox 4:3 to 16:9"),
                                 OnlyInfo ? ":" : "->",
                                 !xc.autocrop ? tr("Off") : xc.autocrop_autodetect ? tr("automatic") : tr("On"));
      break;

    case HOTKEY_DEINTERLACE:
      {
        /* off, on */
        int off = !strcmp(xc.deinterlace_method, "none");
        if (!OnlyInfo) {
          off = !off;
          if (off)
            strcpy(xc.deinterlace_method, "none");
          else
            strcpy(xc.deinterlace_method, "tvtime");
          m_Dev->ConfigurePostprocessing(xc.deinterlace_method, xc.audio_delay,
                                         compression, xc.audio_equalizer,
                                         xc.audio_surround, xc.speaker_type);
        }
        Message = cString::sprintf("%s %s %s", tr("Deinterlacing"),
                                   OnlyInfo ? ":" : "->",
                                   tr(off ? "Off":"On"));
      }
      break;

    case HOTKEY_UPMIX:
      /* off, on */
      if (!OnlyInfo) {
        xc.audio_upmix = xc.audio_upmix ? 0 : 1;
        m_Dev->ConfigurePostprocessing("upmix", xc.audio_upmix ? true : false, NULL);
      }
      Message = cString::sprintf("%s %s %s",
                                 tr("Upmix stereo to 5.1"),
                                 OnlyInfo ? ":" : "->",
                                 tr(xc.audio_upmix ? "On" : "Off"));
      break;

    case HOTKEY_DOWNMIX:
      /* off, on */
      if (!OnlyInfo) {
        xc.audio_surround = xc.audio_surround ? 0 : 1;
        m_Dev->ConfigurePostprocessing(
            xc.deinterlace_method, xc.audio_delay, xc.audio_compression,
            xc.audio_equalizer, xc.audio_surround, xc.speaker_type);
      }
      Message = cString::sprintf("%s %s %s",
                                 tr("Downmix AC3 to surround"),
                                 OnlyInfo ? ":" : "->",
                                 tr(xc.audio_surround ? "On":"Off"));
      break;

      case HOTKEY_PLAYLIST:
        /* Start replaying playlist or file pointed by
           symlink $(CONFDIR)/plugins/xineliboutput/default_playlist */
        {
          struct stat st;
          cString file = cString::sprintf("%s%s", cPlugin::ConfigDirectory("xineliboutput"), "/default_playlist");
          if (lstat(file, &st) == 0) {
            if (S_ISLNK(st.st_mode)) {
              cString buffer(ReadLink(file), true);
              if (!*buffer || stat(buffer, &st)) {
                Message = tr("Default playlist not found");
              } else {
                LOGDBG("Replaying default playlist: %s", *file);
                cPlayerFactory::Launch(m_Dev, buffer);
              }
            } else {
              Message = tr("Default playlist is not symlink");
            }
          } else {
            Message = tr("Default playlist not defined");
          }
        }
        break;

    case HOTKEY_ADELAY_UP:
      /* audio delay up */
      if (!OnlyInfo) {
        xc.audio_delay++;
        m_Dev->ConfigurePostprocessing(xc.deinterlace_method, xc.audio_delay,
                                       xc.audio_compression, xc.audio_equalizer,
                                       xc.audio_surround, xc.speaker_type);
      }
      Message = cString::sprintf("%s %s %d %s", tr("Delay"),
                                 OnlyInfo ? ":" : "->",
                                 xc.audio_delay, tr("ms"));
      break;

    case HOTKEY_ADELAY_DOWN:
      /* audio delay up */
      if (!OnlyInfo) {
        xc.audio_delay--;
        m_Dev->ConfigurePostprocessing(xc.deinterlace_method, xc.audio_delay,
                                       xc.audio_compression, xc.audio_equalizer,
                                       xc.audio_surround, xc.speaker_type);
      }
      Message = cString::sprintf("%s %s %d %s", tr("Delay"),
                                 OnlyInfo ? ":" : "->",
                                 xc.audio_delay, tr("ms"));
      break;

    default:
      Message = cString::sprintf(tr("xineliboutput: hotkey %s not binded"), cKey::ToString(Key));
      break;
  }

  if (*Message) {
    if (!xc.pending_menu_action &&
        !cRemote::HasKeys() &&
        cRemote::CallPlugin("xineliboutput"))
      xc.pending_menu_action = new cDisplayMessage(Message);
  }

  xc.last_hotkey_time = now;
  xc.last_hotkey = Key;

  return NewState;
}
Example #27
0
/*
 *  alloc a mbuf which can be used to describe the packet
 *  if work is error , return NULL
 *  then free wqe, reurn mbuf
 */
void *
oct_rx_process_work(cvmx_wqe_t *wq, uint8_t src)
{
    void *pkt_virt;
    mbuf_t *m;

    if (wq->word2.s.rcv_error || oct_wqe_get_bufs(wq) > 1){
        /*
              *  Work has error, so drop
              *  and now do not support jumbo packet
              */
        oct_packet_free(wq, wqe_pool);
        if(FROMLINUX == src)
        {
            STAT_RECV_FROMLINUX_ERR;
        }
        else
        {
            STAT_RECV_FROMHWPORT_ERR;
        }

        return NULL;
    }

    pkt_virt = (void *) cvmx_phys_to_ptr(wq->packet_ptr.s.addr);
    if(NULL == pkt_virt)
    {
        STAT_RECV_ADDR_ERR;
        return NULL;
    }

    LOGDBG(SEC_PACKET_DUMP, "Received %u byte packet.\n", oct_wqe_get_len(wq));
    LOGDBG(SEC_PACKET_DUMP, "Processing packet\n");
    if(srv_dp_sync->dp_debugprint & SEC_PACKET_DUMP)
    {
        cvmx_helper_dump_packet(wq);
    }

    m = (mbuf_t *)MBUF_ALLOC();

    memset((void *)m, 0, sizeof(mbuf_t));

    m->magic_flag = MBUF_MAGIC_NUM;
    PKTBUF_SET_HW(m);

    m->packet_ptr.u64 = wq->packet_ptr.u64;

    m->input_port = oct_wqe_get_port(wq);

    m->pkt_totallen = oct_wqe_get_len(wq);
    m->pkt_ptr = pkt_virt;

    m->tag = cvmx_wqe_get_tag(wq);

    m->timestamp = OCT_TIME_SECONDS_SINCE1970;

    oct_fpa_free(wq, wqe_pool, 0);

    if(FROMPORT == src)
    {
        STAT_RECV_PC_ADD;
        STAT_RECV_PB_ADD(m->pkt_totallen);
    }

    if(FROMLINUX == src)
    {
        STAT_RECV_FROMLINUX_OK;
    }
    else
    {
        STAT_RECV_FROMHWPORT_OK;
    }

    return (void *)m;
}
static void *lirc_receiver_thread(void *fe_gen)
{
  frontend_t *fe = (frontend_t*)fe_gen;
  const int   priority = -1;
  int      timeout = -1;
  int      repeat = 0;
  uint64_t FirstTime = time_ms();
  uint64_t LastTime = time_ms();
  char     buf[LIRC_BUFFER_SIZE];
  char     LastKeyName[LIRC_KEY_BUF] = "";

  LOGMSG("lirc forwarding started");

  errno = 0;
  if ((nice(priority) == -1) && errno)
    LOGDBG("LIRC: Can't nice to value: %d", priority);

  lircd_connect();

  while (lirc_device_name && fd_lirc >= 0) {
    fd_set set;
    int ready, ret = -1;
    FD_ZERO(&set);
    FD_SET(fd_lirc, &set);

    pthread_testcancel();
    if (timeout >= 0) {
      struct timeval tv;
      tv.tv_sec  = timeout / 1000;
      tv.tv_usec = (timeout % 1000) * 1000;
      ready = select(FD_SETSIZE, &set, NULL, NULL, &tv) > 0 && FD_ISSET(fd_lirc, &set);
    } else {
      ready = select(FD_SETSIZE, &set, NULL, NULL, NULL) > 0 && FD_ISSET(fd_lirc, &set);
    }

    pthread_testcancel();
    if (ready < 0) {
      LOGMSG("LIRC connection lost ?");
      break;
    }

    if (ready) {

      do {
        errno = 0;
        ret = read(fd_lirc, buf, sizeof(buf));
        pthread_testcancel();
      } while (ret < 0 && errno == EINTR);

      if (ret <= 0 ) {
        /* try reconnecting */
        LOGERR("LIRC connection lost");
        lircd_connect();
        while (lirc_device_name && fd_lirc < 0) {
          pthread_testcancel();
          sleep(RECONNECTDELAY/1000);
          lircd_connect();
        }
        if (fd_lirc >= 0)
          LOGMSG("LIRC reconnected");
	continue;
      }

      if (ret >= MIN_LIRCD_CMD_LEN) {
        unsigned int count;
        char KeyName[LIRC_KEY_BUF];
        LOGDBG("LIRC: %s", buf);

        if (sscanf(buf, "%*x %x %29s", &count, KeyName) != 2) {
          /* '29' in '%29s' is LIRC_KEY_BUF-1! */
          LOGMSG("unparseable lirc command: %s", buf);
          continue;
        }

        if (lirc_repeat_emu)
          if (strcmp(KeyName, LastKeyName) == 0 && elapsed(LastTime) < REPEATDELAY)
            count = repeat + 1;

        if (count == 0) {
          if (strcmp(KeyName, LastKeyName) == 0 && elapsed(FirstTime) < REPEATDELAY)
            continue; /* skip keys coming in too fast */
          if (repeat) {
            alarm(3);
            fe->send_input_event(fe, "LIRC", LastKeyName, 0, 1);
            alarm(0);
          }

          strcpy(LastKeyName, KeyName);
          repeat = 0;
          FirstTime = time_ms();
          timeout = -1;
        }
        else {
          if (elapsed(LastTime) < REPEATFREQ)
            continue; /* repeat function kicks in after a short delay */

          if (elapsed(FirstTime) < REPEATDELAY) {
            if (lirc_repeat_emu)
              LastTime = time_ms();
            continue; /* skip keys coming in too fast */
          }
          repeat = 1;
          timeout = REPEATDELAY;
        }
        LastTime = time_ms();

        if (gui_hotkeys) {
          if (!strcmp(KeyName, "Quit")) {
            fe->send_event(fe, "QUIT");
            break;
          }
          if (!strcmp(KeyName, "PowerOff")) {
            fe->send_event(fe, "POWER_OFF");
            break;
          }
          if (!strcmp(KeyName, "Fullscreen")) {
            if (!repeat)
              fe->send_event(fe, "TOGGLE_FULLSCREEN");
            continue;
          }
          if (!strcmp(KeyName, "Deinterlace")) {
            if (!repeat)
              fe->send_event(fe, "TOGGLE_DEINTERLACE");
            continue;
          }
        }

        alarm(3);
        fe->send_input_event(fe, "LIRC", KeyName, repeat, 0);
        alarm(0);

      }

    }
    if (repeat && (!ready || ret < MIN_LIRCD_CMD_LEN)) { /* the last one was a repeat, so let's generate a release */
      if (elapsed(LastTime) >= REPEATTIMEOUT) {
        alarm(3);
        fe->send_input_event(fe, "LIRC", LastKeyName, 0, 1);
        alarm(0);
        repeat = 0;
        *LastKeyName = 0;
        timeout = -1;
      }
    }
  }


  if (fd_lirc >= 0)
    close(fd_lirc);
  fd_lirc = -1;
  pthread_exit(NULL);
  return NULL; /* never reached */
}
Example #29
0
/* -----------------------------------------------------------------------------
----------------------------------------------------------------------------- */
int ppp_comp_setcompressor(struct ppp_if *wan, struct ppp_option_data *odp)
{
    int 			error = 0;
	u_int32_t		nb;
    struct ppp_comp *cp;
    u_char 			ccp_option[CCP_MAX_OPTION_LENGTH];
    user_addr_t		ptr;
    int				transmit;
    
    if (proc_is64bit(current_proc())) {
        struct ppp_option_data64 *odp64 = (struct ppp_option_data64 *)odp;

        nb = odp64->length;
        ptr = odp64->ptr;
        transmit = odp64->transmit;
    } else {
        struct ppp_option_data32 *odp32 = (struct ppp_option_data32 *)odp;

        nb = odp32->length;
        ptr = CAST_USER_ADDR_T(odp32->ptr);
        transmit = odp32->transmit;
    }
    
    if (nb > sizeof(ccp_option))
        nb = sizeof(ccp_option);

    if (error = copyin(ptr, ccp_option, nb))
        return (error);

    if (ccp_option[1] < 2)	/* preliminary check on the length byte */
        return (EINVAL);

    cp = ppp_comp_find(ccp_option[0]);
    if (cp == 0) {
        LOGDBG(wan->net, ("ppp%d: no compressor for [%x %x %x], %x\n",
                ifnet_unit(wan->net), ccp_option[0], ccp_option[1],
                ccp_option[2], nb));

        return EINVAL;	/* no handler found */
    }

    if (transmit) {
        if (wan->xc_state)
            (*wan->xcomp->comp_free)(wan->xc_state);
        wan->xcomp = cp;
        wan->xc_state = cp->comp_alloc(ccp_option, nb);
        if (!wan->xc_state) {
            error = ENOMEM;
            LOGDBG(wan->net, ("ppp%d: comp_alloc failed\n", ifnet_unit(wan->net)));
        }
        wan->sc_flags &= ~SC_COMP_RUN;
    }
    else {
        if (wan->rc_state)
            (*wan->rcomp->decomp_free)(wan->rc_state);
        wan->rcomp = cp;
        wan->rc_state = cp->decomp_alloc(ccp_option, nb);
        if (!wan->rc_state) {
            error = ENOMEM;
            LOGDBG(wan->net, ("ppp%d: decomp_alloc failed\n", ifnet_unit(wan->net)));
        }
        wan->sc_flags &= ~SC_DECOMP_RUN;
    }
    
    return error;
}
Example #30
0
static void
gcomDispatch (MBOX_ID replyMbox)
{
    MBOX_ID fromId;            /* Mbox qui a origine le message */
    int nbytes;                /* Nombre de bytes dans mbox ou dans message */
    LETTER_HDR hdr;            /* En-tete de la lettre recue */
    LETTER_ID letter;          /* Lettre recue */
    SEND *pSend;               /* Pointeur vers structure du send */
    int sendId;                /* Identificateur de send d'une replique */
    int indice = MY_TASK_DEV;
    
    /* Boucler tant qu'il y aura des repliques */
    while (mboxIoctl (replyMbox, FIO_NBYTES, (char *) &nbytes) == OK &&
	   nbytes != 0) {
        LOGDBG(("comLib:gcomDispatch: %d bytes in mbox %d\n",
		nbytes, replyMbox));

	/* Epier le contenu du mailbox */
	if (mboxSpy (replyMbox, &fromId, &nbytes, (char *) &hdr, 
		     sizeof (LETTER_HDR)) == sizeof (LETTER_HDR) &&
	    (sendId = hdr.sendId) >= 0 && sendId < MAX_SEND) {
	    /* Calculer le pointeur vers la structure donnees send */
	    pSend = &sendTab [indice][sendId];
	    
	    /* Verifier le type de replique */
	    switch (hdr.type) {
	      /* Replique intermediaire */
	      case INTERMED_REPLY:
		
		/* Obtenir la lettre associee */
		letter = pSend->intermedReplyLetter;
		
		/* Si c'est le cas, recevoir cette replique */
		if (pSend->status == WAITING_INTERMED_REPLY &&
		    letter->flagInit == GCOM_FLAG_INIT &&
		    mboxRcv (replyMbox, &fromId, (char *) letter->pHdr,
			     letter->size, 1) > 0) {
		    /* Indiquer l'attente de la replique finale */
		    pSend->status = WAITING_FINAL_REPLY;
		    continue;
		}
		break;
		
		/* Reply final */
	      case FINAL_REPLY:
		
		/* Obtenir la lettre associee */
		letter = pSend->finalReplyLetter;
		
		/* Si c'est le cas, recevoir cette replique */
		if ((pSend->status == WAITING_INTERMED_REPLY ||
		     pSend->status == WAITING_FINAL_REPLY) &&
		    letter->flagInit == GCOM_FLAG_INIT &&
		    mboxRcv (replyMbox, &fromId, (char *) letter->pHdr, 
			     letter->size, 1) > 0) {
		    /* Indiquer que la replique a ete recue et continuer */
		    pSend->status = FINAL_REPLY_OK;
		    continue;
		}
	    } /* case */
	}
      
	/* Jeter la lettre et continuer */
	logMsg("Problem while receiving a reply\n");
	(void) mboxSkip (replyMbox);
    } /* while */
}