Exemple #1
0
NTSTATUS rpccli_setup_netlogon_creds(
	struct cli_state *cli,
	enum dcerpc_transport_t transport,
	struct netlogon_creds_cli_context *creds_ctx,
	bool force_reauth,
	struct cli_credentials *cli_creds)
{
	TALLOC_CTX *frame = talloc_stackframe();
	struct netlogon_creds_cli_lck *lck;
	NTSTATUS status;

	status = netlogon_creds_cli_lck(
		creds_ctx, NETLOGON_CREDS_CLI_LCK_EXCLUSIVE,
		frame, &lck);
	if (!NT_STATUS_IS_OK(status)) {
		DBG_WARNING("netlogon_creds_cli_lck failed: %s\n",
			    nt_errstr(status));
		TALLOC_FREE(frame);
		return status;
	}

	status = rpccli_setup_netlogon_creds_locked(
		cli, transport, creds_ctx, force_reauth, cli_creds, NULL);

	TALLOC_FREE(frame);

	return status;
}
Exemple #2
0
/**
 * et131x_tx - The handler to tx a packet on the device
 * @skb: data to be Tx'd
 * @netdev: device on which data is to be Tx'd
 *
 * Returns 0 on success, errno on failure (as defined in errno.h)
 */
int et131x_tx(struct sk_buff *skb, struct net_device *netdev)
{
	int status = 0;

	DBG_TX_ENTER(et131x_dbginfo);

	/* Save the timestamp for the TX timeout watchdog */
	netdev->trans_start = jiffies;

	/* Call the device-specific data Tx routine */
	status = et131x_send_packets(skb, netdev);

	/* Check status and manage the netif queue if necessary */
	if (status != 0) {
		if (status == -ENOMEM) {
			DBG_VERBOSE(et131x_dbginfo,
				    "OUT OF TCBs; STOP NETIF QUEUE\n");

			/* Put the queue to sleep until resources are
			 * available
			 */
			netif_stop_queue(netdev);
			status = NETDEV_TX_BUSY;
		} else {
			DBG_WARNING(et131x_dbginfo,
				    "Misc error; drop packet\n");
			status = NETDEV_TX_OK;
		}
	}

	DBG_TX_LEAVE(et131x_dbginfo);
	return status;
}
String DHT22Sensor::formatValue( int16_t value, uint8_t dataType )
{
    String info;

    if ( INVALID_INT16 == value )
    {
        info = "*";
    }
    else
    {
        info = "";
        info += value/10;
        info += ".";
        info += value%10;
    }

    if ( DATA_TEMPERATURE == dataType )
    {
        info += "C";
    }
    else if ( DATA_HUMIDITY == dataType )
    {
        info += "%";
    }
    else
    {
        info += "?";
        DBG_WARNING(0);
    }

    return info;

}
Exemple #4
0
/*
  handle incoming netlogon mailslot requests
*/
void nbtd_mailslot_netlogon_handler(struct dgram_mailslot_handler *dgmslot,
				    struct nbt_dgram_packet *packet,
				    struct socket_address *src)
{
	NTSTATUS status = NT_STATUS_NO_MEMORY;
	struct nbtd_interface *iface =
		talloc_get_type(dgmslot->private_data, struct nbtd_interface);
	struct nbtd_interface *reply_iface = nbtd_find_reply_iface(
		iface, src->addr, false);
	struct nbt_netlogon_response *response = NULL;
	char *reply_mailslot = NULL;

	if (reply_iface->ip_address == NULL) {
		DBG_WARNING("Could not obtain own IP address for datagram "
			    "socket\n");
		return;
	}

	status = nbtd_mailslot_netlogon_reply(
		iface, packet, src, dgmslot, &response, &reply_mailslot);

	if (NT_STATUS_IS_OK(status)) {
		dgram_mailslot_netlogon_reply(
			reply_iface->dgmsock, packet,
			lpcfg_netbios_name(iface->nbtsrv->task->lp_ctx),
			reply_mailslot, response);
	}

	TALLOC_FREE(response);
	TALLOC_FREE(reply_mailslot);
}
const char * DHT22Sensor::getDataName( uint8_t dataType )
{
    const char *name;

    if ( DATA_TEMPERATURE == dataType )
    {
         name = "TEMP";
    }
    else if ( DATA_HUMIDITY == dataType )
    {
        name = "RH";
    }
    else
    {
        name = "?";
        DBG_WARNING(0);
    }

    return name;
}
Exemple #6
0
/**
 * et131x_ioctl - The I/O Control handler for the driver
 * @netdev: device on which the control request is being made
 * @reqbuf: a pointer to the IOCTL request buffer
 * @cmd: the IOCTL command code
 *
 * Returns 0 on success, errno on failure (as defined in errno.h)
 */
int et131x_ioctl(struct net_device *netdev, struct ifreq *reqbuf, int cmd)
{
	int status = 0;

	DBG_ENTER(et131x_dbginfo);

	switch (cmd) {
	case SIOCGMIIPHY:
	case SIOCGMIIREG:
	case SIOCSMIIREG:
		status = et131x_ioctl_mii(netdev, reqbuf, cmd);
		break;

	default:
		DBG_WARNING(et131x_dbginfo, "Unhandled IOCTL Code: 0x%04x\n",
			    cmd);
		status = -EOPNOTSUPP;
	}

	DBG_LEAVE(et131x_dbginfo);
	return status;
}
int16_t DHT22Sensor::getValue( uint8_t dataType )
{
    int16_t val;

    if ( DATA_TEMPERATURE == dataType )
    {
        val = temperature;
    }
    else if ( DATA_HUMIDITY == dataType )
    {
        val = humidity;
    }
    else
    {
        val = INVALID_INT16;
        DBG_WARNING(0);
    }

    return val;


}
Exemple #8
0
NTSTATUS rpccli_connect_netlogon(
	struct cli_state *cli,
	enum dcerpc_transport_t transport,
	struct netlogon_creds_cli_context *creds_ctx,
	bool force_reauth,
	struct cli_credentials *trust_creds,
	struct rpc_pipe_client **_rpccli)
{
	TALLOC_CTX *frame = talloc_stackframe();
	struct netlogon_creds_CredentialState *creds = NULL;
	enum netlogon_creds_cli_lck_type lck_type;
	enum netr_SchannelType sec_chan_type;
	struct netlogon_creds_cli_lck *lck = NULL;
	uint32_t negotiate_flags;
	uint8_t found_session_key[16] = {0};
	bool found_existing_creds = false;
	bool do_serverauth;
	struct rpc_pipe_client *rpccli;
	NTSTATUS status;
	bool retry = false;

	sec_chan_type = cli_credentials_get_secure_channel_type(trust_creds);
	if (sec_chan_type == SEC_CHAN_NULL) {
		DBG_ERR("secure_channel_type gave SEC_CHAN_NULL\n");
		status = NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
		goto fail;
	}

again:

	/*
	 * See whether we can use existing netlogon_creds or
	 * whether we have to serverauthenticate.
	 */
	status = netlogon_creds_cli_get(creds_ctx, frame, &creds);

	if (NT_STATUS_IS_OK(status)) {
		int cmp = memcmp(found_session_key,
				 creds->session_key,
				 sizeof(found_session_key));
		found_existing_creds = (cmp != 0);

		memcpy(found_session_key,
		       creds->session_key,
		       sizeof(found_session_key));

		TALLOC_FREE(creds);
	}

	lck_type = (force_reauth || !found_existing_creds) ?
		NETLOGON_CREDS_CLI_LCK_EXCLUSIVE :
		NETLOGON_CREDS_CLI_LCK_SHARED;

	status = netlogon_creds_cli_lck(creds_ctx, lck_type, frame, &lck);
	if (!NT_STATUS_IS_OK(status)) {
		DBG_DEBUG("netlogon_creds_cli_lck failed: %s\n",
			  nt_errstr(status));
		goto fail;
	}

	if (!found_existing_creds) {
		/*
		 * Try to find creds under the lock again. Someone
		 * else might have done it for us.
		 */
		status = netlogon_creds_cli_get(creds_ctx, frame, &creds);

		if (NT_STATUS_IS_OK(status)) {
			int cmp = memcmp(found_session_key,
					 creds->session_key,
					 sizeof(found_session_key));
			found_existing_creds = (cmp != 0);

			memcpy(found_session_key, creds->session_key,
			       sizeof(found_session_key));

			TALLOC_FREE(creds);
		}
	}

	do_serverauth = force_reauth || !found_existing_creds;

	if (!do_serverauth) {
		/*
		 * Do the quick schannel bind without a reauth
		 */
		status = cli_rpc_pipe_open_bind_schannel(
			cli, &ndr_table_netlogon, transport, creds_ctx,
			&rpccli);
		if (!retry && NT_STATUS_EQUAL(status, NT_STATUS_NETWORK_ACCESS_DENIED)) {
			DBG_DEBUG("Retrying with serverauthenticate\n");
			TALLOC_FREE(lck);
			retry = true;
			goto again;
		}
		if (!NT_STATUS_IS_OK(status)) {
			DBG_DEBUG("cli_rpc_pipe_open_bind_schannel "
				  "failed: %s\n", nt_errstr(status));
			goto fail;
		}
		goto done;
	}

	if (cli_credentials_is_anonymous(trust_creds)) {
		DBG_WARNING("get_trust_credential for %s only gave anonymous,"
			    "unable to negotiate NETLOGON credentials\n",
			    netlogon_creds_cli_debug_string(
				    creds_ctx, frame));
		status = NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
		goto fail;
	}

	status = rpccli_setup_netlogon_creds_locked(
		cli, transport, creds_ctx, true, trust_creds,
		&negotiate_flags);
	if (!NT_STATUS_IS_OK(status)) {
		DBG_DEBUG("rpccli_setup_netlogon_creds failed for %s, "
			  "unable to setup NETLOGON credentials: %s\n",
			  netlogon_creds_cli_debug_string(
				  creds_ctx, frame),
			  nt_errstr(status));
		goto fail;
	}

	if (!(negotiate_flags & NETLOGON_NEG_AUTHENTICATED_RPC)) {
		if (lp_winbind_sealed_pipes() || lp_require_strong_key()) {
			status = NT_STATUS_DOWNGRADE_DETECTED;
			DBG_WARNING("Unwilling to make connection to %s"
				    "without connection level security, "
				    "must set 'winbind sealed pipes = false'"
				    " and 'require strong key = false' "
				    "to proceed: %s\n",
				    netlogon_creds_cli_debug_string(
					    creds_ctx, frame),
				    nt_errstr(status));
			goto fail;
		}

		status = cli_rpc_pipe_open_noauth_transport(
			cli, transport, &ndr_table_netlogon, &rpccli);
		if (!NT_STATUS_IS_OK(status)) {
			DBG_DEBUG("cli_rpc_pipe_open_noauth_transport "
				  "failed: %s\n", nt_errstr(status));
			goto fail;
		}
		goto done;
	}

	status = cli_rpc_pipe_open_bind_schannel(
		cli, &ndr_table_netlogon, transport, creds_ctx, &rpccli);
	if (!NT_STATUS_IS_OK(status)) {
		DBG_DEBUG("cli_rpc_pipe_open_bind_schannel "
			  "failed: %s\n", nt_errstr(status));
		goto fail;
	}

	status = netlogon_creds_cli_check(creds_ctx, rpccli->binding_handle,
					  NULL);
	if (!NT_STATUS_IS_OK(status)) {
		DBG_WARNING("netlogon_creds_cli_check failed: %s\n",
			    nt_errstr(status));
		goto fail;
	}

done:
	*_rpccli = rpccli;
	status = NT_STATUS_OK;
fail:
	ZERO_STRUCT(found_session_key);
	TALLOC_FREE(lck);
	TALLOC_FREE(frame);
	return status;
}
/******************************************************************************
   ROUTINE:  ConfigMacRegs2
 ******************************************************************************

   DESCRIPTION:
        Used to configure the second part of MAC regs to a known initialized 
        state

   PARAMETERS :
        pAdpater - pointer to our adapter structure

   RETURNS    :
        NONE

 *****************************************************************************/
void ConfigMACRegs2( ET131X_ADAPTER *pAdapter )
{
    INT32         delay = 0;
    PMAC_t        pMac;
    MAC_CFG1_t    cfg1;
    MAC_CFG2_t    cfg2;
    MAC_IF_CTRL_t ifctrl;
    TXMAC_CTL_t   ctl = pAdapter->CSRAddress->txmac.ctl;
    /*-----------------------------------------------------------------------*/

    
    DBG_FUNC( "ConfigMACRegs2" );
    DBG_ENTER( et131x_dbginfo );


    /**************************************************************************
       Let's get our pointer to the MAC regs
     *************************************************************************/
    pMac = &pAdapter->CSRAddress->mac;

    cfg1.value   = pMac->cfg1.value;
    cfg2.value   = pMac->cfg2.value;
    ifctrl.value = pMac->if_ctrl.value; 
    
    if( pAdapter->uiLinkSpeed == TRUEPHY_SPEED_1000MBPS )
    {
        cfg2.bits.if_mode    = 0x2;
        ifctrl.bits.phy_mode = 0x0;
    }
    else
    {
        cfg2.bits.if_mode    = 0x1;
        ifctrl.bits.phy_mode = 0x1;
    }


    /**************************************************************************
       We need to enable Rx/Tx
     *************************************************************************/
    cfg1.bits.rx_enable	    = 0x1;
    cfg1.bits.tx_enable	    = 0x1;


    /**************************************************************************
       Set up flow control
     *************************************************************************/
    cfg1.bits.tx_flow	    = 0x1;

    if( ( pAdapter->FlowControl == RxOnly ) ||
        ( pAdapter->FlowControl == Both ))
    {
        cfg1.bits.rx_flow	    = 0x1;
    }
    else
    {
        cfg1.bits.rx_flow	    = 0x0;
    }


    /**************************************************************************
       Initialize loop back to off
     *************************************************************************/
    cfg1.bits.loop_back	    = 0;

    pAdapter->CSRAddress->mac.cfg1.value = cfg1.value;


    /**************************************************************************
       Now we need to initialize the MAC Configuration 2 register
     *************************************************************************/ 
    cfg2.bits.preamble_len        = 0x7;
    cfg2.bits.huge_frame          = 0x0;
    /* LENGTH FIELD CHECKING bit4: Set this bit to cause the MAC to check the
     * frame’s length field to ensure it matches the actual data field length. Clear this bit if no
     * length field checking is desired. Its default is ‘0’.
     */
    cfg2.bits.len_check           = 0x1;

    if ( pAdapter->RegistryPhyLoopbk == FALSE )
    {
        cfg2.bits.pad_crc         = 0x1;
        cfg2.bits.crc_enable      = 0x1;
    }
    else
    {
        cfg2.bits.pad_crc         = 0;
        cfg2.bits.crc_enable      = 0;
    }


    /**************************************************************************
       1 – full duplex, 0 – half-duplex
     *************************************************************************/
    cfg2.bits.full_duplex	        = pAdapter->uiDuplexMode;
    ifctrl.bits.ghd_mode            = !pAdapter->uiDuplexMode;

    pAdapter->CSRAddress->mac.if_ctrl = ifctrl;
    pAdapter->CSRAddress->mac.cfg2.value = cfg2.value;

    do
    {
        udelay( 10 );
        delay++;
    } while(( !pAdapter->CSRAddress->mac.cfg1.bits.syncd_rx_en ||
              !pAdapter->CSRAddress->mac.cfg1.bits.syncd_tx_en ) && 
              ( delay < 100 ));

    if( delay == 100 )
    {
        DBG_ERROR( et131x_dbginfo,
                   "Syncd bits did not respond correctly cfg1 word 0x%08x\n",
                   pAdapter->CSRAddress->mac.cfg1.value );
    }

    DBG_TRACE( et131x_dbginfo,
               "Speed %d, Dup %d, CFG1 0x%08x, CFG2 0x%08x, if_ctrl 0x%08x\n",
               pAdapter->uiLinkSpeed, pAdapter->uiDuplexMode,
               pAdapter->CSRAddress->mac.cfg1.value,
               pAdapter->CSRAddress->mac.cfg2.value,
               pAdapter->CSRAddress->mac.if_ctrl.value );


    /**************************************************************************
       Enable TXMAC
     *************************************************************************/
    ctl.bits.txmac_en   = 0x1;
    ctl.bits.fc_disable = 0x1;
    pAdapter->CSRAddress->txmac.ctl = ctl;


    /**************************************************************************
       Ready to start the RXDMA/TXDMA engine
     *************************************************************************/
    if( !MP_TEST_FLAG( pAdapter, fMP_ADAPTER_LOWER_POWER ))
    {
        et131x_rx_dma_enable( pAdapter );
        et131x_tx_dma_enable( pAdapter );
    }
    else
    {
        DBG_WARNING( et131x_dbginfo,
                     "Didn't enable Rx/Tx due to low-power mode\n" );
    }


    DBG_LEAVE( et131x_dbginfo );
    return;
}
Exemple #10
0
/**
 * open a database
 */
struct db_context *db_open(TALLOC_CTX *mem_ctx,
			   const char *name,
			   int hash_size, int tdb_flags,
			   int open_flags, mode_t mode,
			   enum dbwrap_lock_order lock_order,
			   uint64_t dbwrap_flags)
{
	struct db_context *result = NULL;
	const char *sockname;

	if (!DBWRAP_LOCK_ORDER_VALID(lock_order)) {
		errno = EINVAL;
		return NULL;
	}

	if (tdb_flags & TDB_CLEAR_IF_FIRST) {
		const char *base;
		bool try_readonly = false;

		base = strrchr_m(name, '/');
		if (base != NULL) {
			base += 1;
		} else {
			base = name;
		}

		if (dbwrap_flags & DBWRAP_FLAG_OPTIMIZE_READONLY_ACCESS) {
			try_readonly = true;
		}

		try_readonly = lp_parm_bool(-1, "dbwrap_optimize_readonly", "*", try_readonly);
		try_readonly = lp_parm_bool(-1, "dbwrap_optimize_readonly", base, try_readonly);

		if (try_readonly) {
			dbwrap_flags |= DBWRAP_FLAG_OPTIMIZE_READONLY_ACCESS;
		} else {
			dbwrap_flags &= ~DBWRAP_FLAG_OPTIMIZE_READONLY_ACCESS;
		}
	}

	if (tdb_flags & TDB_CLEAR_IF_FIRST) {
		const char *base;
		bool try_mutex = true;
		bool require_mutex = false;

		base = strrchr_m(name, '/');
		if (base != NULL) {
			base += 1;
		} else {
			base = name;
		}

		try_mutex = lp_parm_bool(-1, "dbwrap_tdb_mutexes", "*", try_mutex);
		try_mutex = lp_parm_bool(-1, "dbwrap_tdb_mutexes", base, try_mutex);

		if (!lp_use_mmap()) {
			/*
			 * Mutexes require mmap. "use mmap = no" can
			 * be a debugging tool, so let it override the
			 * mutex parameters
			 */
			try_mutex = false;
		}

		if (try_mutex && tdb_runtime_check_for_robust_mutexes()) {
			tdb_flags |= TDB_MUTEX_LOCKING;
		}

		require_mutex = lp_parm_bool(-1, "dbwrap_tdb_require_mutexes",
					   "*", require_mutex);
		require_mutex = lp_parm_bool(-1, "dbwrap_tdb_require_mutexes",
					   base, require_mutex);

		if (require_mutex) {
			tdb_flags |= TDB_MUTEX_LOCKING;
		}
	}

	sockname = lp_ctdbd_socket();

	if (lp_clustering()) {
		const char *partname;

		if (!socket_exist(sockname)) {
			DEBUG(1, ("ctdb socket does not exist - is ctdb not "
				  "running?\n"));
			return NULL;
		}

		/* ctdb only wants the file part of the name */
		partname = strrchr(name, '/');
		if (partname) {
			partname++;
		} else {
			partname = name;
		}
		/* allow ctdb for individual databases to be disabled */
		if (lp_parm_bool(-1, "ctdb", partname, True)) {
			struct messaging_context *msg_ctx;
			struct ctdbd_connection *conn;

			conn = messaging_ctdb_connection();
			if (conn == NULL) {
				DBG_WARNING("No ctdb connection\n");
				errno = EIO;
				return NULL;
			}
			msg_ctx = server_messaging_context();

			result = db_open_ctdb(mem_ctx, msg_ctx, partname,
					      hash_size,
					      tdb_flags, open_flags, mode,
					      lock_order, dbwrap_flags);
			if (result == NULL) {
				DEBUG(0,("failed to attach to ctdb %s\n",
					 partname));
				if (errno == 0) {
					errno = EIO;
				}
				return NULL;
			}
		}
	}

	if (result == NULL) {
		struct loadparm_context *lp_ctx = loadparm_init_s3(mem_ctx, loadparm_s3_helpers());

		if (hash_size == 0) {
			hash_size = lpcfg_tdb_hash_size(lp_ctx, name);
		}
		tdb_flags = lpcfg_tdb_flags(lp_ctx, tdb_flags);

		result = dbwrap_local_open(
			mem_ctx,
			name,
			hash_size,
			tdb_flags,
			open_flags,
			mode,
			lock_order,
			dbwrap_flags);
		talloc_unlink(mem_ctx, lp_ctx);
	}
	return result;
}
/*******************************************************************************
 *	wl_process_probe_response()
 *******************************************************************************
 *
 *  DESCRIPTION:
 *
 *      Process the probe responses retunred by the device as a result of an
 *      active scan.
 *
 *  PARAMETERS:
 *
 *      lp - a pointer to the device's private structure
 *
 *  RETURNS:
 *
 *      N/A
 *
 ******************************************************************************/
void wl_process_probe_response( struct wl_private *lp )
{
    PROBE_RESP  *probe_rsp;
    hcf_8       *wpa_ie = NULL;
    hcf_16      wpa_ie_len = 0;
    /*------------------------------------------------------------------------*/


    DBG_FUNC( "wl_process_probe_response" );
    DBG_ENTER( DbgInfo );


    if( lp != NULL ) {
        probe_rsp = (PROBE_RESP *)&lp->ProbeResp;

        wl_endian_translate_event( (ltv_t *)probe_rsp );

        DBG_TRACE( DbgInfo, "(%s) =========================\n", lp->dev->name );
        DBG_TRACE( DbgInfo, "(%s) length      : 0x%04x.\n",  lp->dev->name,
                probe_rsp->length );

        if( probe_rsp->length > 1 ) {
            DBG_TRACE( DbgInfo, "(%s) infoType    : 0x%04x.\n", lp->dev->name,
                    probe_rsp->infoType );

            DBG_TRACE( DbgInfo, "(%s) signal      : 0x%02x.\n", lp->dev->name,
                    probe_rsp->signal );

            DBG_TRACE( DbgInfo, "(%s) silence     : 0x%02x.\n", lp->dev->name,
                    probe_rsp->silence );

            DBG_TRACE( DbgInfo, "(%s) rxFlow      : 0x%02x.\n", lp->dev->name,
                    probe_rsp->rxFlow );

            DBG_TRACE( DbgInfo, "(%s) rate        : 0x%02x.\n", lp->dev->name,
                    probe_rsp->rate );

            DBG_TRACE( DbgInfo, "(%s) frame cntl  : 0x%04x.\n", lp->dev->name,
                    probe_rsp->frameControl );

            DBG_TRACE( DbgInfo, "(%s) durID       : 0x%04x.\n", lp->dev->name,
                    probe_rsp->durID );

		DBG_TRACE(DbgInfo, "(%s) address1    : %pM\n", lp->dev->name,
			probe_rsp->address1);

		DBG_TRACE(DbgInfo, "(%s) address2    : %pM\n", lp->dev->name,
			probe_rsp->address2);

		DBG_TRACE(DbgInfo, "(%s) BSSID       : %pM\n", lp->dev->name,
			probe_rsp->BSSID);

            DBG_TRACE( DbgInfo, "(%s) sequence    : 0x%04x.\n", lp->dev->name,
                    probe_rsp->sequence );

		DBG_TRACE(DbgInfo, "(%s) address4    : %pM\n", lp->dev->name,
			probe_rsp->address4);

            DBG_TRACE( DbgInfo, "(%s) datalength  : 0x%04x.\n", lp->dev->name,
                    probe_rsp->dataLength );

		DBG_TRACE(DbgInfo, "(%s) DA          : %pM\n", lp->dev->name,
			probe_rsp->DA);

		DBG_TRACE(DbgInfo, "(%s) SA          : %pM\n", lp->dev->name,
			probe_rsp->SA);

#ifdef WARP

            DBG_TRACE( DbgInfo, "(%s) channel     : %d\n", lp->dev->name,
                    probe_rsp->channel );

            DBG_TRACE( DbgInfo, "(%s) band        : %d\n", lp->dev->name,
                    probe_rsp->band );
#else
            DBG_TRACE( DbgInfo, "(%s) lenType     : 0x%04x.\n", lp->dev->name,
                    probe_rsp->lenType );
#endif  // WARP

            DBG_TRACE( DbgInfo, "(%s) timeStamp   : %d.%d.%d.%d.%d.%d.%d.%d\n",
                    lp->dev->name,
                    probe_rsp->timeStamp[0],
                    probe_rsp->timeStamp[1],
                    probe_rsp->timeStamp[2],
                    probe_rsp->timeStamp[3],
                    probe_rsp->timeStamp[4],
                    probe_rsp->timeStamp[5],
                    probe_rsp->timeStamp[6],
                    probe_rsp->timeStamp[7]);

            DBG_TRACE( DbgInfo, "(%s) beaconInt   : 0x%04x.\n", lp->dev->name,
                    probe_rsp->beaconInterval );

            DBG_TRACE( DbgInfo, "(%s) capability  : 0x%04x.\n", lp->dev->name,
                    probe_rsp->capability );

            DBG_TRACE( DbgInfo, "(%s) SSID len    : 0x%04x.\n", lp->dev->name,
                    probe_rsp->rawData[1] );


            if( probe_rsp->rawData[1] > 0 ) {
                char ssid[HCF_MAX_NAME_LEN];

                memset( ssid, 0, sizeof( ssid ));
                strncpy( ssid, &probe_rsp->rawData[2],
                            probe_rsp->rawData[1] );

                DBG_TRACE( DbgInfo, "(%s) SSID        : %s\n",
                            lp->dev->name, ssid );
            }


            /* Parse out the WPA-IE, if one exists */
            wpa_ie = wl_parse_wpa_ie( probe_rsp, &wpa_ie_len );
            if( wpa_ie != NULL ) {
                DBG_TRACE( DbgInfo, "(%s) WPA-IE      : %s\n",
                lp->dev->name, wl_print_wpa_ie( wpa_ie, wpa_ie_len ));
            }

            DBG_TRACE( DbgInfo, "(%s) flags       : 0x%04x.\n",
                        lp->dev->name, probe_rsp->flags );
        }

        DBG_TRACE( DbgInfo, "\n" );


        /* If probe response length is 1, then the scan is complete */
        if( probe_rsp->length == 1 ) {
            DBG_TRACE( DbgInfo, "SCAN COMPLETE\n" );
            lp->probe_results.num_aps = lp->probe_num_aps;
            lp->probe_results.scan_complete = TRUE;

            /* Reset the counter for the next scan request */
            lp->probe_num_aps = 0;

            /* Send a wireless extensions event that the scan completed */
            wl_wext_event_scan_complete( lp->dev );
        } else {
            /* Only copy to the table if the entry is unique; APs sometimes
                respond more than once to a probe */
            if( lp->probe_num_aps == 0 ) {
                /* Copy the info to the ScanResult structure in the private
                adapter struct */
                memcpy( &( lp->probe_results.ProbeTable[lp->probe_num_aps] ),
                        probe_rsp, sizeof( PROBE_RESP ));

                /* Increment the number of APs detected */
                lp->probe_num_aps++;
            } else {
                int count;
                int unique = 1;

                for( count = 0; count < lp->probe_num_aps; count++ ) {
                    if( memcmp( &( probe_rsp->BSSID ),
                        lp->probe_results.ProbeTable[count].BSSID,
                        ETH_ALEN ) == 0 ) {
                        unique = 0;
                    }
                }

                if( unique ) {
                    /* Copy the info to the ScanResult structure in the
                    private adapter struct. Only copy if there's room in the
                    table */
                    if( lp->probe_num_aps < MAX_NAPS )
                    {
                        memcpy( &( lp->probe_results.ProbeTable[lp->probe_num_aps] ),
                                probe_rsp, sizeof( PROBE_RESP ));
                    }
                    else
                    {
                        DBG_WARNING( DbgInfo, "Num of scan results exceeds storage, truncating\n" );
                    }

                    /* Increment the number of APs detected. Note I do this
                        here even when I don't copy the probe response to the
                        buffer in order to detect the overflow condition */
                    lp->probe_num_aps++;
                }
            }
        }
    }

    DBG_LEAVE( DbgInfo );
    return;
} // wl_process_probe_response
Exemple #12
0
bool netsamlogon_cache_store(const char *username, struct netr_SamInfo3 *info3)
{
    uint8_t dummy = 0;
    TDB_DATA data = { .dptr = &dummy, .dsize = sizeof(dummy) };
    char keystr[DOM_SID_STR_BUFLEN];
    bool result = false;
    struct dom_sid	user_sid;
    TALLOC_CTX *tmp_ctx = talloc_stackframe();
    DATA_BLOB blob;
    enum ndr_err_code ndr_err;
    struct netsamlogoncache_entry r;
    int ret;

    if (!info3) {
        return false;
    }

    if (!netsamlogon_cache_init()) {
        DEBUG(0,("netsamlogon_cache_store: cannot open %s for write!\n",
                 NETSAMLOGON_TDB));
        return false;
    }

    /*
     * First write a record with just the domain sid for
     * netsamlogon_cache_domain_known. Use TDB_INSERT to avoid
     * overwriting potentially other data. We're just interested
     * in the existence of that record.
     */
    dom_sid_string_buf(info3->base.domain_sid, keystr, sizeof(keystr));

    ret = tdb_store_bystring(netsamlogon_tdb, keystr, data, TDB_INSERT);

    if ((ret == -1) && (tdb_error(netsamlogon_tdb) != TDB_ERR_EXISTS)) {
        DBG_WARNING("Could not store domain marker for %s: %s\n",
                    keystr, tdb_errorstr(netsamlogon_tdb));
        TALLOC_FREE(tmp_ctx);
        return false;
    }

    sid_compose(&user_sid, info3->base.domain_sid, info3->base.rid);

    /* Prepare key as DOMAIN-SID/USER-RID string */
    dom_sid_string_buf(&user_sid, keystr, sizeof(keystr));

    DEBUG(10,("netsamlogon_cache_store: SID [%s]\n", keystr));

    /* Prepare data */

    if (info3->base.full_name.string == NULL) {
        struct netr_SamInfo3 *cached_info3;
        const char *full_name = NULL;

        cached_info3 = netsamlogon_cache_get(tmp_ctx, &user_sid);
        if (cached_info3 != NULL) {
            full_name = cached_info3->base.full_name.string;
        }

        if (full_name != NULL) {
            info3->base.full_name.string = talloc_strdup(info3, full_name);
        }
    }

    /* only Samba fills in the username, not sure why NT doesn't */
    /* so we fill it in since winbindd_getpwnam() makes use of it */

    if (!info3->base.account_name.string) {
        info3->base.account_name.string = talloc_strdup(info3, username);
    }

    r.timestamp = time(NULL);
    r.info3 = *info3;

    if (DEBUGLEVEL >= 10) {
        NDR_PRINT_DEBUG(netsamlogoncache_entry, &r);
    }

    ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, &r,
                                   (ndr_push_flags_fn_t)ndr_push_netsamlogoncache_entry);
    if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
        DEBUG(0,("netsamlogon_cache_store: failed to push entry to cache\n"));
        TALLOC_FREE(tmp_ctx);
        return false;
    }

    data.dsize = blob.length;
    data.dptr = blob.data;

    if (tdb_store_bystring(netsamlogon_tdb, keystr, data, TDB_REPLACE) == 0) {
        result = true;
    }

    TALLOC_FREE(tmp_ctx);

    return result;
}

/***********************************************************************
 Retrieves a netr_SamInfo3 structure from a tdb.  Caller must
 free the user_info struct (talloced memory)
***********************************************************************/

struct netr_SamInfo3 *netsamlogon_cache_get(TALLOC_CTX *mem_ctx, const struct dom_sid *user_sid)
{
    struct netr_SamInfo3 *info3 = NULL;
    TDB_DATA data;
    char keystr[DOM_SID_STR_BUFLEN];
    enum ndr_err_code ndr_err;
    DATA_BLOB blob;
    struct netsamlogoncache_entry r;

    if (!netsamlogon_cache_init()) {
        DEBUG(0,("netsamlogon_cache_get: cannot open %s for write!\n",
                 NETSAMLOGON_TDB));
        return NULL;
    }

    /* Prepare key as DOMAIN-SID/USER-RID string */
    dom_sid_string_buf(user_sid, keystr, sizeof(keystr));
    DEBUG(10,("netsamlogon_cache_get: SID [%s]\n", keystr));
    data = tdb_fetch_bystring( netsamlogon_tdb, keystr );

    if (!data.dptr) {
        return NULL;
    }

    info3 = talloc_zero(mem_ctx, struct netr_SamInfo3);
    if (!info3) {
        goto done;
    }

    blob = data_blob_const(data.dptr, data.dsize);

    ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, &r,
                                   (ndr_pull_flags_fn_t)ndr_pull_netsamlogoncache_entry);

    if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
        DEBUG(0,("netsamlogon_cache_get: failed to pull entry from cache\n"));
        tdb_delete_bystring(netsamlogon_tdb, keystr);
        TALLOC_FREE(info3);
        goto done;
    }

    if (DEBUGLEVEL >= 10) {
        NDR_PRINT_DEBUG(netsamlogoncache_entry, &r);
    }

    info3 = (struct netr_SamInfo3 *)talloc_memdup(mem_ctx, &r.info3,
            sizeof(r.info3));

done:
    SAFE_FREE(data.dptr);

    return info3;
}

bool netsamlogon_cache_have(const struct dom_sid *sid)
{
    char keystr[DOM_SID_STR_BUFLEN];
    bool ok;

    if (!netsamlogon_cache_init()) {
        DBG_WARNING("Cannot open %s\n", NETSAMLOGON_TDB);
        return false;
    }

    dom_sid_string_buf(sid, keystr, sizeof(keystr));

    ok = tdb_exists(netsamlogon_tdb, string_term_tdb_data(keystr));
    return ok;
}
Exemple #13
0
/**
 * et131x_multicast - The handler to configure multicasting on the interface
 * @netdev: a pointer to a net_device struct representing the device
 */
void et131x_multicast(struct net_device *netdev)
{
	struct et131x_adapter *adapter = netdev_priv(netdev);
	uint32_t PacketFilter = 0;
	uint32_t count;
	unsigned long lockflags;
	struct dev_mc_list *mclist = netdev->mc_list;

	DBG_ENTER(et131x_dbginfo);

	spin_lock_irqsave(&adapter->Lock, lockflags);

	/* Before we modify the platform-independent filter flags, store them
	 * locally. This allows us to determine if anything's changed and if
	 * we even need to bother the hardware
	 */
	PacketFilter = adapter->PacketFilter;

	/* Clear the 'multicast' flag locally; becuase we only have a single
	 * flag to check multicast, and multiple multicast addresses can be
	 * set, this is the easiest way to determine if more than one
	 * multicast address is being set.
	 */
	PacketFilter &= ~ET131X_PACKET_TYPE_MULTICAST;

	/* Check the net_device flags and set the device independent flags
	 * accordingly
	 */
	DBG_VERBOSE(et131x_dbginfo,
		    "MULTICAST ADDR COUNT: %d\n", netdev->mc_count);

	if (netdev->flags & IFF_PROMISC) {
		DBG_VERBOSE(et131x_dbginfo, "Request: PROMISCUOUS MODE ON\n");
		adapter->PacketFilter |= ET131X_PACKET_TYPE_PROMISCUOUS;
	} else {
		DBG_VERBOSE(et131x_dbginfo, "Request: PROMISCUOUS MODE OFF\n");
		adapter->PacketFilter &= ~ET131X_PACKET_TYPE_PROMISCUOUS;
	}

	if (netdev->flags & IFF_ALLMULTI) {
		DBG_VERBOSE(et131x_dbginfo, "Request: ACCEPT ALL MULTICAST\n");
		adapter->PacketFilter |= ET131X_PACKET_TYPE_ALL_MULTICAST;
	}

	if (netdev->mc_count > NIC_MAX_MCAST_LIST) {
		DBG_WARNING(et131x_dbginfo,
			    "ACCEPT ALL MULTICAST for now, as there's more Multicast "
			    "addresses than the HW supports\n");

		adapter->PacketFilter |= ET131X_PACKET_TYPE_ALL_MULTICAST;
	}

	if (netdev->mc_count < 1) {
		DBG_VERBOSE(et131x_dbginfo, "Request: REJECT ALL MULTICAST\n");
		adapter->PacketFilter &= ~ET131X_PACKET_TYPE_ALL_MULTICAST;
		adapter->PacketFilter &= ~ET131X_PACKET_TYPE_MULTICAST;
	} else {
		DBG_VERBOSE(et131x_dbginfo,
			    "Request: SET MULTICAST FILTER(S)\n");
		adapter->PacketFilter |= ET131X_PACKET_TYPE_MULTICAST;
	}

	/* Set values in the private adapter struct */
	adapter->MCAddressCount = netdev->mc_count;

	if (netdev->mc_count) {
		if (mclist->dmi_addrlen != ETH_ALEN) {
			DBG_WARNING(et131x_dbginfo,
				    "Multicast addrs are not ETH_ALEN in size\n");
		} else {
			count = netdev->mc_count - 1;
			memcpy(adapter->MCList[count], mclist->dmi_addr,
			       ETH_ALEN);
		}
	}

	/* Are the new flags different from the previous ones? If not, then no
	 * action is required
	 *
	 * NOTE - This block will always update the MCList with the hardware,
	 *        even if the addresses aren't the same.
	 */
	if (PacketFilter != adapter->PacketFilter) {
		/* Call the device's filter function */
		DBG_VERBOSE(et131x_dbginfo, "UPDATE REQUIRED, FLAGS changed\n");

		et131x_set_packet_filter(adapter);
	} else {
		DBG_VERBOSE(et131x_dbginfo,
			    "NO UPDATE REQUIRED, FLAGS didn't change\n");
	}

	spin_unlock_irqrestore(&adapter->Lock, lockflags);

	DBG_LEAVE(et131x_dbginfo);
}
static krb5_error_code kpasswd_set_password(struct kdc_server *kdc,
					    TALLOC_CTX *mem_ctx,
					    struct auth_session_info *session_info,
					    DATA_BLOB *decoded_data,
					    DATA_BLOB *kpasswd_reply,
					    const char **error_string)
{
	krb5_context context = kdc->smb_krb5_context->krb5_context;
	krb5_data k_dec_data;
	krb5_data *k_clear_data;
	krb5_principal target_principal;
	krb5_error_code code;
	DATA_BLOB password;
	char *target_realm = NULL;
	char *target_name = NULL;
	char *target_principal_string = NULL;
	bool is_service_principal = false;
	bool ok;
	size_t num_components;
	enum samPwdChangeReason reject_reason = SAM_PWD_CHANGE_NO_ERROR;
	struct samr_DomInfo1 *dominfo = NULL;
	NTSTATUS status;

	k_dec_data.length = decoded_data->length;
	k_dec_data.data   = (char *)decoded_data->data;

	code = decode_krb5_setpw_req(&k_dec_data,
				     &k_clear_data,
				     &target_principal);
	if (code != 0) {
		DBG_WARNING("decode_krb5_setpw_req failed: %s\n",
			    error_message(code));
		ok = kpasswd_make_error_reply(mem_ctx,
					      KRB5_KPASSWD_MALFORMED,
					      "Failed to decode packet",
					      kpasswd_reply);
		if (!ok) {
			*error_string = "Failed to create reply";
			return KRB5_KPASSWD_HARDERROR;
		}
		return 0;
	}

	ok = convert_string_talloc_handle(mem_ctx,
					  lpcfg_iconv_handle(kdc->task->lp_ctx),
					  CH_UTF8,
					  CH_UTF16,
					  (const char *)k_clear_data->data,
					  k_clear_data->length,
					  (void **)&password.data,
					  &password.length);
	krb5_free_data(context, k_clear_data);
	if (!ok) {
		DBG_WARNING("String conversion failed\n");
		*error_string = "String conversion failed";
		return KRB5_KPASSWD_HARDERROR;
	}

	target_realm = smb_krb5_principal_get_realm(context, target_principal);
	code = krb5_unparse_name_flags(context,
				       target_principal,
				       KRB5_PRINCIPAL_UNPARSE_NO_REALM,
				       &target_name);
	if (code != 0) {
		DBG_WARNING("Failed to parse principal\n");
		*error_string = "String conversion failed";
		return KRB5_KPASSWD_HARDERROR;
	}

	if ((target_name != NULL && target_realm == NULL) ||
	    (target_name == NULL && target_realm != NULL)) {
		krb5_free_principal(context, target_principal);
		SAFE_FREE(target_realm);
		SAFE_FREE(target_name);

		ok = kpasswd_make_error_reply(mem_ctx,
					      KRB5_KPASSWD_MALFORMED,
					      "Realm and principal must be "
					      "both present, or neither "
					      "present",
					      kpasswd_reply);
		if (!ok) {
			*error_string = "Failed to create reply";
			return KRB5_KPASSWD_HARDERROR;
		}
		return 0;
	}

	if (target_name != NULL && target_realm != NULL) {
		SAFE_FREE(target_realm);
		SAFE_FREE(target_name);
	} else {
		krb5_free_principal(context, target_principal);
		SAFE_FREE(target_realm);
		SAFE_FREE(target_name);

		return kpasswd_change_password(kdc,
					       mem_ctx,
					       session_info,
					       &password,
					       kpasswd_reply,
					       error_string);
	}

	num_components = krb5_princ_size(context, target_principal);
	if (num_components >= 2) {
		is_service_principal = true;
		code = krb5_unparse_name_flags(context,
					       target_principal,
					       KRB5_PRINCIPAL_UNPARSE_SHORT,
					       &target_principal_string);
	} else {
		code = krb5_unparse_name(context,
					 target_principal,
					 &target_principal_string);
	}
	krb5_free_principal(context, target_principal);
	if (code != 0) {
		ok = kpasswd_make_error_reply(mem_ctx,
					      KRB5_KPASSWD_MALFORMED,
					      "Failed to parse principal",
					      kpasswd_reply);
		if (!ok) {
			*error_string = "Failed to create reply";
			return KRB5_KPASSWD_HARDERROR;
		}
	}

	status = kpasswd_samdb_set_password(mem_ctx,
					    kdc->task->event_ctx,
					    kdc->task->lp_ctx,
					    session_info,
					    is_service_principal,
					    target_principal_string,
					    &password,
					    &reject_reason,
					    &dominfo);
	if (!NT_STATUS_IS_OK(status)) {
		DBG_ERR("kpasswd_samdb_set_password failed - %s\n",
			nt_errstr(status));
	}

	ok = kpasswd_make_pwchange_reply(mem_ctx,
					 status,
					 reject_reason,
					 dominfo,
					 kpasswd_reply);
	if (!ok) {
		*error_string = "Failed to create reply";
		return KRB5_KPASSWD_HARDERROR;
	}

	return 0;
}
/*******************************************************************************
 *	translate_option()
 *******************************************************************************
 *
 *  DESCRIPTION:
 *
 *      This function takes a line read in from the config file and parses out
 *   the key/value pairs. It then determines which key has been parsed and sets
 *   the card's configuration based on the value given.
 *
 *  PARAMETERS:
 *
 *      buffer - a buffer containing a line to translate
 *      config - a pointer to the device's private adapter structure
 *
 *  RETURNS:
 *
 *      N/A
 *
 ******************************************************************************/
void translate_option(char *buffer, struct wl_private *lp)
{
	unsigned int value_convert = 0;
	int string_length = 0;
	char *key = NULL;
	char *value = NULL;
	u_char mac_value[ETH_ALEN];
	/*------------------------------------------------------------------------*/

	DBG_FUNC("translate_option");

	if (buffer == NULL || lp == NULL) {
		DBG_ERROR(DbgInfo, "Config file buffer and/or wavelan buffer ptr NULL\n");
		return;
	}

	ParseConfigLine(buffer, &key, &value);

	if (key == NULL || value == NULL)
		return;

	/* Determine which key it is and perform the appropriate action */

	/* Configuration parameters used in all scenarios */
#if DBG
	/* handle DebugFlag as early as possible so it starts its influence as early
	 * as possible
	 */
	if (strcmp(key, PARM_NAME_DEBUG_FLAG) == 0) {
		if (DebugFlag == ~0) {			/* if DebugFlag is not specified on the command line */
			if (DbgInfo->DebugFlag == 0) {	/* if pc_debug did not set DebugFlag (i.e.pc_debug is
											 * not specified or specified outside the 4-8 range
											 */
				DbgInfo->DebugFlag |= DBG_DEFAULTS;
			}
		} else {
			DbgInfo->DebugFlag = simple_strtoul(value, NULL, 0); /* ;?DebugFlag; */
		}
		DbgInfo->DebugFlag = simple_strtoul(value, NULL, 0); /* ;?Delete ASAP */
	}
#endif /* DBG */
	if (strcmp(key, PARM_NAME_AUTH_KEY_MGMT_SUITE) == 0) {
		DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_AUTH_KEY_MGMT_SUITE, value);

		value_convert = simple_strtoul(value, NULL, 0);
		if ((value_convert >= PARM_MIN_AUTH_KEY_MGMT_SUITE) || (value_convert <= PARM_MAX_AUTH_KEY_MGMT_SUITE))
			lp->AuthKeyMgmtSuite = value_convert;
		else
			DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_AUTH_KEY_MGMT_SUITE);
	} else if (strcmp(key, PARM_NAME_BRSC_2GHZ) == 0) {
		DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_BRSC_2GHZ, value);

		value_convert = simple_strtoul(value, NULL, 0);
		if ((value_convert >= PARM_MIN_BRSC) || (value_convert <= PARM_MAX_BRSC))
			lp->brsc[0] = value_convert;
		else
			DBG_WARNING(DbgInfo, "%s invaid; will be ignored\n", PARM_NAME_BRSC_2GHZ);
	} else if (strcmp(key, PARM_NAME_BRSC_5GHZ) == 0) {
		DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_BRSC_5GHZ, value);

		value_convert = simple_strtoul(value, NULL, 0);
		if ((value_convert >= PARM_MIN_BRSC) || (value_convert <= PARM_MAX_BRSC))
			lp->brsc[1] = value_convert;
		else
			DBG_WARNING(DbgInfo, "%s invaid; will be ignored\n", PARM_NAME_BRSC_5GHZ);
	} else if ((strcmp(key, PARM_NAME_DESIRED_SSID) == 0) || (strcmp(key, PARM_NAME_OWN_SSID) == 0)) {
		DBG_TRACE(DbgInfo, "SSID, value: %s\n", value);

		memset(lp->NetworkName, 0, (PARM_MAX_NAME_LEN + 1));

		/* Make sure the value isn't too long */
		string_length = strlen(value);
		if (string_length > PARM_MAX_NAME_LEN) {
			DBG_WARNING(DbgInfo, "SSID too long; will be truncated\n");
			string_length = PARM_MAX_NAME_LEN;
		}

		memcpy(lp->NetworkName, value, string_length);
	}
#if 0
	else if (strcmp(key, PARM_NAME_DOWNLOAD_FIRMWARE) == 0) {
		DBG_TRACE(DbgInfo, "DOWNLOAD_FIRMWARE, value: %s\n", value);
		memset(lp->fw_image_filename, 0, (MAX_LINE_SIZE + 1));
		/* Make sure the value isn't too long */
		string_length = strlen(value);
		if (string_length > MAX_LINE_SIZE)
			DBG_WARNING(DbgInfo, "F/W image file name too long; will be ignored\n");
		else
			memcpy(lp->fw_image_filename, value, string_length);
	}
#endif
	else if (strcmp(key, PARM_NAME_ENABLE_ENCRYPTION) == 0) {
		DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_ENABLE_ENCRYPTION, value);

		value_convert = simple_strtoul(value, NULL, 0);
		if ((value_convert >= PARM_MIN_ENABLE_ENCRYPTION) && (value_convert <= PARM_MAX_ENABLE_ENCRYPTION))
			lp->EnableEncryption = value_convert;
		else
			DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_ENABLE_ENCRYPTION);
	} else if (strcmp(key, PARM_NAME_ENCRYPTION) == 0) {
		DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_ENCRYPTION, value);

		memset(lp->szEncryption, 0, sizeof(lp->szEncryption));

		/* Make sure the value isn't too long */
		string_length = strlen(value);
		if (string_length > sizeof(lp->szEncryption)) {
			DBG_WARNING(DbgInfo, "%s too long; will be truncated\n", PARM_NAME_ENCRYPTION);
			string_length = sizeof(lp->szEncryption);
		}

		memcpy(lp->szEncryption, value, string_length);
	} else if (strcmp(key, PARM_NAME_KEY1) == 0) {
		DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_KEY1, value);

		if (is_valid_key_string(value)) {
			memset(lp->DefaultKeys.key[0].key, 0, MAX_KEY_SIZE);

			key_string2key(value, &lp->DefaultKeys.key[0]);
		} else {
			 DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_KEY1);
		}
	} else if (strcmp(key, PARM_NAME_KEY2) == 0) {
		DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_KEY2, value);

		if (is_valid_key_string(value)) {
			memset(lp->DefaultKeys.key[1].key, 0, MAX_KEY_SIZE);

			key_string2key(value, &lp->DefaultKeys.key[1]);
		} else {
			 DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_KEY2);
		}
	} else if (strcmp(key, PARM_NAME_KEY3) == 0) {
		DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_KEY3, value);

		if (is_valid_key_string(value)) {
			memset(lp->DefaultKeys.key[2].key, 0, MAX_KEY_SIZE);

			key_string2key(value, &lp->DefaultKeys.key[2]);
		} else {
			 DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_KEY3);
		}
	} else if (strcmp(key, PARM_NAME_KEY4) == 0) {
		DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_KEY4, value);

		if (is_valid_key_string(value)) {
			memset(lp->DefaultKeys.key[3].key, 0, MAX_KEY_SIZE);

			key_string2key(value, &lp->DefaultKeys.key[3]);
		} else {
			 DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_KEY4);
		}
	}
	/* New Parameters for WARP */
	else if (strcmp(key, PARM_NAME_LOAD_BALANCING) == 0) {
		DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_LOAD_BALANCING, value);
		lp->loadBalancing = parse_yes_no(value);
	} else if (strcmp(key, PARM_NAME_MEDIUM_DISTRIBUTION) == 0) {
		DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_MEDIUM_DISTRIBUTION, value);
		lp->mediumDistribution = parse_yes_no(value);
	} else if (strcmp(key, PARM_NAME_MICROWAVE_ROBUSTNESS) == 0) {
		DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_MICROWAVE_ROBUSTNESS, value);
		lp->MicrowaveRobustness = parse_yes_no(value);
	} else if (strcmp(key, PARM_NAME_MULTICAST_RATE) == 0) {
		DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_MULTICAST_RATE, value);

		value_convert = simple_strtoul(value, NULL, 0);

		if ((value_convert >= PARM_MIN_MULTICAST_RATE) && (value_convert <= PARM_MAX_MULTICAST_RATE))
			lp->MulticastRate[0] = value_convert;
		else
			DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_MULTICAST_RATE);
	} else if (strcmp(key, PARM_NAME_OWN_CHANNEL) == 0) {
		DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_OWN_CHANNEL, value);

		value_convert = simple_strtoul(value, NULL, 0);
		if (wl_is_a_valid_chan(value_convert)) {
			if (value_convert > 14)
				value_convert = value_convert | 0x100;
			lp->Channel = value_convert;
		} else {
			DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_OWN_CHANNEL);
		}
	} else if (strcmp(key, PARM_NAME_OWN_NAME) == 0) {
		DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_OWN_NAME, value);

		memset(lp->StationName, 0, (PARM_MAX_NAME_LEN + 1));

		/* Make sure the value isn't too long */
		string_length = strlen(value);
		if (string_length > PARM_MAX_NAME_LEN) {
			DBG_WARNING(DbgInfo, "%s too long; will be truncated\n", PARM_NAME_OWN_NAME);
			string_length = PARM_MAX_NAME_LEN;
		}

		memcpy(lp->StationName, value, string_length);
	} else if (strcmp(key, PARM_NAME_RTS_THRESHOLD) == 0) {
		DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_RTS_THRESHOLD, value);

		value_convert = simple_strtoul(value, NULL, 0);
		if ((value_convert >= PARM_MIN_RTS_THRESHOLD) && (value_convert <= PARM_MAX_RTS_THRESHOLD))
			lp->RTSThreshold = value_convert;
		else
			DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_RTS_THRESHOLD);
	} else if (strcmp(key, PARM_NAME_SRSC_2GHZ) == 0) {
		DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_SRSC_2GHZ, value);

		value_convert = simple_strtoul(value, NULL, 0);
		if ((value_convert >= PARM_MIN_SRSC) || (value_convert <= PARM_MAX_SRSC))
			lp->srsc[0] = value_convert;
		else
			DBG_WARNING(DbgInfo, "%s invaid; will be ignored\n", PARM_NAME_SRSC_2GHZ);
	} else if (strcmp(key, PARM_NAME_SRSC_5GHZ) == 0) {
		DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_SRSC_5GHZ, value);

		value_convert = simple_strtoul(value, NULL, 0);
		if ((value_convert >= PARM_MIN_SRSC) || (value_convert <= PARM_MAX_SRSC))
			lp->srsc[1] = value_convert;
		else
			DBG_WARNING(DbgInfo, "%s invaid; will be ignored\n", PARM_NAME_SRSC_5GHZ);
	} else if (strcmp(key, PARM_NAME_SYSTEM_SCALE) == 0) {
		DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_SYSTEM_SCALE, value);

		value_convert = simple_strtoul(value, NULL, 0);
		if ((value_convert >= PARM_MIN_SYSTEM_SCALE) && (value_convert <= PARM_MAX_SYSTEM_SCALE))
			lp->DistanceBetweenAPs = value_convert;
		else
			DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_SYSTEM_SCALE);
	} else if (strcmp(key, PARM_NAME_TX_KEY) == 0) {
		DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_TX_KEY, value);

		value_convert = simple_strtoul(value, NULL, 0);
		if ((value_convert >= PARM_MIN_TX_KEY) && (value_convert <= PARM_MAX_TX_KEY))
			lp->TransmitKeyID = simple_strtoul(value, NULL, 0);
		else
			DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_TX_KEY);
	} else if (strcmp(key, PARM_NAME_TX_RATE) == 0) {
		DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_TX_RATE, value);

		value_convert = simple_strtoul(value, NULL, 0);
		if ((value_convert >= PARM_MIN_TX_RATE) && (value_convert <= PARM_MAX_TX_RATE))
			lp->TxRateControl[0] = value_convert;
		else
			DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_TX_RATE);
	} else if (strcmp(key, PARM_NAME_TX_POW_LEVEL) == 0) {
		DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_TX_POW_LEVEL, value);

		value_convert = simple_strtoul(value, NULL, 0);
		if ((value_convert >= PARM_MIN_TX_POW_LEVEL) || (value_convert <= PARM_MAX_TX_POW_LEVEL))
			lp->txPowLevel = value_convert;
		else
			DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_TX_POW_LEVEL);
	}

	/* Need to add? : Country code, Short/Long retry */

	/* Configuration parameters specific to STA mode */
#if 1 /* ;? (HCF_TYPE) & HCF_TYPE_STA */
/* ;?seems reasonable that even an AP-only driver could afford this small additional footprint */
	if (CNV_INT_TO_LITTLE(lp->hcfCtx.IFB_FWIdentity.comp_id) == COMP_ID_FW_STA) {
					/* ;?should we return an error status in AP mode */
		if (strcmp(key, PARM_NAME_PORT_TYPE) == 0) {
			DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_PORT_TYPE, value);

			value_convert = simple_strtoul(value, NULL, 0);
			if ((value_convert == PARM_MIN_PORT_TYPE) || (value_convert == PARM_MAX_PORT_TYPE))
				lp->PortType = value_convert;
			else
				DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_PORT_TYPE);
		} else if (strcmp(key, PARM_NAME_PM_ENABLED) == 0) {
			DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_PM_ENABLED, value);
			value_convert = simple_strtoul(value, NULL, 0);
	/* ;? how about wl_main.c containing
	 * VALID_PARAM(PARM_PM_ENABLED <= WVLAN_PM_STATE_STANDARD ||
	 *					 (PARM_PM_ENABLED & 0x7FFF) <= WVLAN_PM_STATE_STANDARD);
	 */
			if ((value_convert & 0x7FFF) <= PARM_MAX_PM_ENABLED) {
				lp->PMEnabled = value_convert;
			} else {
				DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_PM_ENABLED);
				/* ;?this is a data entry error, hence not a DBG_WARNING */
			}
		} else if (strcmp(key, PARM_NAME_CREATE_IBSS) == 0) {
			DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_CREATE_IBSS, value);
			lp->CreateIBSS = parse_yes_no(value);
		} else if (strcmp(key, PARM_NAME_MULTICAST_RX) == 0) {
			DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_MULTICAST_RX, value);
			lp->MulticastReceive = parse_yes_no(value);
		} else if (strcmp(key, PARM_NAME_MAX_SLEEP) == 0) {
			DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_MAX_SLEEP, value);

			value_convert = simple_strtoul(value, NULL, 0);
			if ((value_convert >= 0) && (value_convert <= 65535))
				lp->MaxSleepDuration = value_convert;
			else
				DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_MAX_SLEEP);
		} else if (strcmp(key, PARM_NAME_NETWORK_ADDR) == 0) {
			DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_NETWORK_ADDR, value);

			if (parse_mac_address(value, mac_value) == ETH_ALEN)
				memcpy(lp->MACAddress, mac_value, ETH_ALEN);
			else
				DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_NETWORK_ADDR);
		} else if (strcmp(key, PARM_NAME_AUTHENTICATION) == 0) {
			DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_AUTHENTICATION, value);

			value_convert = simple_strtoul(value, NULL, 0);
			if ((value_convert >= PARM_MIN_AUTHENTICATION) && (value_convert <= PARM_MAX_AUTHENTICATION))
				lp->authentication = value_convert;
			else
				DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_AUTHENTICATION);
		} else if (strcmp(key, PARM_NAME_OWN_ATIM_WINDOW) == 0) {
			DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_OWN_ATIM_WINDOW, value);

			value_convert = simple_strtoul(value, NULL, 0);
			if ((value_convert >= PARM_MIN_OWN_ATIM_WINDOW) && (value_convert <= PARM_MAX_OWN_ATIM_WINDOW))
				lp->atimWindow = value_convert;
			else
				DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_OWN_ATIM_WINDOW);
		} else if (strcmp(key, PARM_NAME_PM_HOLDOVER_DURATION) == 0) {
			DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_PM_HOLDOVER_DURATION, value);

			value_convert = simple_strtoul(value, NULL, 0);
			if ((value_convert >= PARM_MIN_PM_HOLDOVER_DURATION) && (value_convert <= PARM_MAX_PM_HOLDOVER_DURATION))
				lp->holdoverDuration = value_convert;
			else
				DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_PM_HOLDOVER_DURATION);
		} else if (strcmp(key, PARM_NAME_PROMISCUOUS_MODE) == 0) {
			DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_PROMISCUOUS_MODE, value);
			lp->promiscuousMode = parse_yes_no(value);
		} else if (strcmp(key, PARM_NAME_CONNECTION_CONTROL) == 0) {
			DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_CONNECTION_CONTROL, value);

			value_convert = simple_strtoul(value, NULL, 0);
			if ((value_convert >= PARM_MIN_CONNECTION_CONTROL) && (value_convert <= PARM_MAX_CONNECTION_CONTROL))
				lp->connectionControl = value_convert;
			else
				DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_CONNECTION_CONTROL);
		}

		/* Need to add? : Probe Data Rate */
	}
#endif  /* (HCF_TYPE) & HCF_TYPE_STA */

	/* Configuration parameters specific to AP mode */
#if 1 /* ;? (HCF_TYPE) & HCF_TYPE_AP */
		/* ;?should we restore this to allow smaller memory footprint */
	if (CNV_INT_TO_LITTLE(lp->hcfCtx.IFB_FWIdentity.comp_id) == COMP_ID_FW_AP) {
		if (strcmp(key, PARM_NAME_OWN_DTIM_PERIOD) == 0) {
			DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_OWN_DTIM_PERIOD, value);

			value_convert = simple_strtoul(value, NULL, 0);
			if (value_convert >= PARM_MIN_OWN_DTIM_PERIOD)
				lp->DTIMPeriod = value_convert;
			else
				DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_OWN_DTIM_PERIOD);
		} else if (strcmp(key, PARM_NAME_REJECT_ANY) == 0) {
			DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_REJECT_ANY, value);
			lp->RejectAny = parse_yes_no(value);
		} else if (strcmp(key, PARM_NAME_EXCLUDE_UNENCRYPTED) == 0) {
			DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_EXCLUDE_UNENCRYPTED, value);
			lp->ExcludeUnencrypted = parse_yes_no(value);
		} else if (strcmp(key, PARM_NAME_MULTICAST_PM_BUFFERING) == 0) {
			DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_MULTICAST_PM_BUFFERING, value);
			lp->ExcludeUnencrypted = parse_yes_no(value);
		} else if (strcmp(key, PARM_NAME_INTRA_BSS_RELAY) == 0) {
			DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_INTRA_BSS_RELAY, value);
			lp->ExcludeUnencrypted = parse_yes_no(value);
		} else if (strcmp(key, PARM_NAME_OWN_BEACON_INTERVAL) == 0) {
			DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_OWN_BEACON_INTERVAL, value);

			value_convert = simple_strtoul(value, NULL, 0);
			if (value_convert >= PARM_MIN_OWN_BEACON_INTERVAL)
				lp->ownBeaconInterval = value_convert;
			else
				DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_OWN_BEACON_INTERVAL);
		} else if (strcmp(key, PARM_NAME_COEXISTENCE) == 0) {
			DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_COEXISTENCE, value);

			value_convert = simple_strtoul(value, NULL, 0);
			if (value_convert >= PARM_MIN_COEXISTENCE)
				lp->coexistence = value_convert;
			else
				DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_COEXISTENCE);
		}

#ifdef USE_WDS
		else if (strcmp(key, PARM_NAME_RTS_THRESHOLD1) == 0) {
			DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_RTS_THRESHOLD1, value);

			value_convert = simple_strtoul(value, NULL, 0);
			if ((value_convert >= PARM_MIN_RTS_THRESHOLD) && (value_convert <= PARM_MAX_RTS_THRESHOLD))
				lp->wds_port[0].rtsThreshold = value_convert;
			else
				DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_RTS_THRESHOLD1);
		} else if (strcmp(key, PARM_NAME_RTS_THRESHOLD2) == 0) {
			DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_RTS_THRESHOLD2, value);

			value_convert = simple_strtoul(value, NULL, 0);
			if ((value_convert >= PARM_MIN_RTS_THRESHOLD) && (value_convert <= PARM_MAX_RTS_THRESHOLD))
				lp->wds_port[1].rtsThreshold = value_convert;
			else
				DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_RTS_THRESHOLD2);
		} else if (strcmp(key, PARM_NAME_RTS_THRESHOLD3) == 0) {
			DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_RTS_THRESHOLD3, value);

			value_convert = simple_strtoul(value, NULL, 0);
			if ((value_convert >= PARM_MIN_RTS_THRESHOLD) && (value_convert <= PARM_MAX_RTS_THRESHOLD))
				lp->wds_port[2].rtsThreshold = value_convert;
			else
				DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_RTS_THRESHOLD3);
		} else if (strcmp(key, PARM_NAME_RTS_THRESHOLD4) == 0) {
			DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_RTS_THRESHOLD4, value);

			value_convert = simple_strtoul(value, NULL, 0);
			if ((value_convert >= PARM_MIN_RTS_THRESHOLD) && (value_convert <= PARM_MAX_RTS_THRESHOLD))
				lp->wds_port[3].rtsThreshold = value_convert;
			else
				DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_RTS_THRESHOLD4);
		} else if (strcmp(key, PARM_NAME_RTS_THRESHOLD5) == 0) {
			DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_RTS_THRESHOLD5, value);

			value_convert = simple_strtoul(value, NULL, 0);
			if ((value_convert >= PARM_MIN_RTS_THRESHOLD) && (value_convert <= PARM_MAX_RTS_THRESHOLD))
				lp->wds_port[4].rtsThreshold = value_convert;
			else
				DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_RTS_THRESHOLD5);
		} else if (strcmp(key, PARM_NAME_RTS_THRESHOLD6) == 0) {
			DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_RTS_THRESHOLD6, value);

			value_convert = simple_strtoul(value, NULL, 0);
			if ((value_convert >= PARM_MIN_RTS_THRESHOLD) && (value_convert <= PARM_MAX_RTS_THRESHOLD))
				lp->wds_port[5].rtsThreshold = value_convert;
			else
				DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_RTS_THRESHOLD6);
		} else if (strcmp(key, PARM_NAME_TX_RATE1) == 0) {
			DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_TX_RATE1, value);

			value_convert = simple_strtoul(value, NULL, 0);
			if ((value_convert >= PARM_MIN_TX_RATE) && (value_convert <= PARM_MAX_TX_RATE))
				lp->wds_port[0].txRateCntl = value_convert;
			else
				DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_TX_RATE1);
		} else if (strcmp(key, PARM_NAME_TX_RATE2) == 0) {
			DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_TX_RATE2, value);

			value_convert = simple_strtoul(value, NULL, 0);
			if ((value_convert >= PARM_MIN_TX_RATE) && (value_convert <= PARM_MAX_TX_RATE))
				lp->wds_port[1].txRateCntl = value_convert;
			else
				DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_TX_RATE2);
		} else if (strcmp(key, PARM_NAME_TX_RATE3) == 0) {
			DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_TX_RATE3, value);

			value_convert = simple_strtoul(value, NULL, 0);
			if ((value_convert >= PARM_MIN_TX_RATE) && (value_convert <= PARM_MAX_TX_RATE))
				lp->wds_port[2].txRateCntl = value_convert;
			else
				DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_TX_RATE3);
		} else if (strcmp(key, PARM_NAME_TX_RATE4) == 0) {
			DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_TX_RATE4, value);

			value_convert = simple_strtoul(value, NULL, 0);
			if ((value_convert >= PARM_MIN_TX_RATE) && (value_convert <= PARM_MAX_TX_RATE))
				lp->wds_port[3].txRateCntl = value_convert;
			else
				DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_TX_RATE4);
		} else if (strcmp(key, PARM_NAME_TX_RATE5) == 0) {
			DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_TX_RATE5, value);

			value_convert = simple_strtoul(value, NULL, 0);
			if ((value_convert >= PARM_MIN_TX_RATE) && (value_convert <= PARM_MAX_TX_RATE))
				lp->wds_port[4].txRateCntl = value_convert;
			else
				DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_TX_RATE5);
		} else if (strcmp(key, PARM_NAME_TX_RATE6) == 0) {
			DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_TX_RATE6, value);

			value_convert = simple_strtoul(value, NULL, 0);
			if ((value_convert >= PARM_MIN_TX_RATE) && (value_convert <= PARM_MAX_TX_RATE))
				lp->wds_port[5].txRateCntl = value_convert;
			else
				DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_TX_RATE6);
		} else if (strcmp(key, PARM_NAME_WDS_ADDRESS1) == 0) {
			DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_WDS_ADDRESS1, value);

			if (parse_mac_address(value, mac_value) == ETH_ALEN)
				memcpy(lp->wds_port[0].wdsAddress, mac_value, ETH_ALEN);
			else
				DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_WDS_ADDRESS1);
		} else if (strcmp(key, PARM_NAME_WDS_ADDRESS2) == 0) {
			DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_WDS_ADDRESS2, value);

			if (parse_mac_address(value, mac_value) == ETH_ALEN)
				memcpy(lp->wds_port[1].wdsAddress, mac_value, ETH_ALEN);
			else
				DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_WDS_ADDRESS2);
		} else if (strcmp(key, PARM_NAME_WDS_ADDRESS3) == 0) {
			DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_WDS_ADDRESS3, value);

			if (parse_mac_address(value, mac_value) == ETH_ALEN)
				memcpy(lp->wds_port[2].wdsAddress, mac_value, ETH_ALEN);
			else
				DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_WDS_ADDRESS3);
		} else if (strcmp(key, PARM_NAME_WDS_ADDRESS4) == 0) {
			DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_WDS_ADDRESS4, value);

			if (parse_mac_address(value, mac_value) == ETH_ALEN)
				memcpy(lp->wds_port[3].wdsAddress, mac_value, ETH_ALEN);
			else
				DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_WDS_ADDRESS4);
		} else if (strcmp(key, PARM_NAME_WDS_ADDRESS5) == 0) {
			DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_WDS_ADDRESS5, value);

			if (parse_mac_address(value, mac_value) == ETH_ALEN)
				memcpy(lp->wds_port[4].wdsAddress, mac_value, ETH_ALEN);
			else
				DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_WDS_ADDRESS5);
		} else if (strcmp(key, PARM_NAME_WDS_ADDRESS6) == 0) {
			DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_WDS_ADDRESS6, value);

			if (parse_mac_address(value, mac_value) == ETH_ALEN)
				memcpy(lp->wds_port[5].wdsAddress, mac_value, ETH_ALEN);
			else
				DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_WDS_ADDRESS6);
		}
#endif  /* USE_WDS */
	}
#endif  /* (HCF_TYPE) & HCF_TYPE_AP */

	return;
} /* translate_option */
Exemple #16
0
/**
 * et131x_set_mac_addr - handler to change the MAC address for the device
 * @netdev: device whose MAC is to be changed
 * @new_mac: the desired MAC address
 *
 * Returns 0 on success, errno on failure (as defined in errno.h)
 *
 * IMPLEMENTED BY : blux http://berndlux.de 22.01.2007 21:14
 */
int et131x_set_mac_addr(struct net_device *netdev, void *new_mac)
{
	int result = 0;
	struct et131x_adapter *adapter = netdev_priv(netdev);
	struct sockaddr *address = new_mac;

	DBG_ENTER(et131x_dbginfo);
	// begin blux
	// DBG_VERBOSE( et131x_dbginfo, "Function not implemented!!\n" );

	if (adapter == NULL) {
		DBG_LEAVE(et131x_dbginfo);
		return -ENODEV;
	}

	/* Make sure the requested MAC is valid */
	if (!is_valid_ether_addr(address->sa_data)) {
		DBG_LEAVE(et131x_dbginfo);
		return -EINVAL;
	}

	/* Stop the netif queue */
	netif_stop_queue(netdev);

	/* Stop the Tx and Rx DMA engines */
	et131x_rx_dma_disable(adapter);
	et131x_tx_dma_disable(adapter);

	/* Disable device interrupts */
	et131x_disable_interrupts(adapter);
	et131x_handle_send_interrupt(adapter);
	et131x_handle_recv_interrupt(adapter);

	/* Set the new MAC */
	// netdev->set_mac_address  = &new_mac;
	// netdev->mtu = new_mtu;

	memcpy(netdev->dev_addr, address->sa_data, netdev->addr_len);

	printk("%s: Setting MAC address to %02x:%02x:%02x:%02x:%02x:%02x\n",
	       netdev->name, netdev->dev_addr[0], netdev->dev_addr[1],
	       netdev->dev_addr[2], netdev->dev_addr[3], netdev->dev_addr[4],
	       netdev->dev_addr[5]);

	/* Free Rx DMA memory */
	et131x_adapter_memory_free(adapter);

	/* Set the config parameter for Jumbo Packet support */
	// adapter->RegistryJumboPacket = new_mtu + 14;
	// blux: not needet here, w'll change the MAC

	et131x_soft_reset(adapter);

	/* Alloc and init Rx DMA memory */
	result = et131x_adapter_memory_alloc(adapter);
	if (result != 0) {
		DBG_WARNING(et131x_dbginfo,
			    "Change MAC failed; couldn't re-alloc DMA memory\n");
		return result;
	}

	et131x_init_send(adapter);

	et131x_setup_hardware_properties(adapter);
	// memcpy( netdev->dev_addr, adapter->CurrentAddress, ETH_ALEN );
	// blux: no, do not override our nice address

	/* Init the device with the new settings */
	et131x_adapter_setup(adapter);

	/* Enable interrupts */
	if (MP_TEST_FLAG(adapter, fMP_ADAPTER_INTERRUPT_IN_USE)) {
		et131x_enable_interrupts(adapter);
	}

	/* Restart the Tx and Rx DMA engines */
	et131x_rx_dma_enable(adapter);
	et131x_tx_dma_enable(adapter);

	/* Restart the netif queue */
	netif_wake_queue(netdev);

	DBG_LEAVE(et131x_dbginfo);
	return result;
}
Exemple #17
0
/**
 * et131x_change_mtu - The handler called to change the MTU for the device
 * @netdev: device whose MTU is to be changed
 * @new_mtu: the desired MTU
 *
 * Returns 0 on success, errno on failure (as defined in errno.h)
 */
int et131x_change_mtu(struct net_device *netdev, int new_mtu)
{
	int result = 0;
	struct et131x_adapter *adapter = netdev_priv(netdev);

	DBG_ENTER(et131x_dbginfo);

	/* Make sure the requested MTU is valid */
	if (new_mtu == 0 || new_mtu > 9216) {
		DBG_LEAVE(et131x_dbginfo);
		return -EINVAL;
	}

	/* Stop the netif queue */
	netif_stop_queue(netdev);

	/* Stop the Tx and Rx DMA engines */
	et131x_rx_dma_disable(adapter);
	et131x_tx_dma_disable(adapter);

	/* Disable device interrupts */
	et131x_disable_interrupts(adapter);
	et131x_handle_send_interrupt(adapter);
	et131x_handle_recv_interrupt(adapter);

	/* Set the new MTU */
	netdev->mtu = new_mtu;

	/* Free Rx DMA memory */
	et131x_adapter_memory_free(adapter);

	/* Set the config parameter for Jumbo Packet support */
	adapter->RegistryJumboPacket = new_mtu + 14;
	et131x_soft_reset(adapter);

	/* Alloc and init Rx DMA memory */
	result = et131x_adapter_memory_alloc(adapter);
	if (result != 0) {
		DBG_WARNING(et131x_dbginfo,
			    "Change MTU failed; couldn't re-alloc DMA memory\n");
		return result;
	}

	et131x_init_send(adapter);

	et131x_setup_hardware_properties(adapter);
	memcpy(netdev->dev_addr, adapter->CurrentAddress, ETH_ALEN);

	/* Init the device with the new settings */
	et131x_adapter_setup(adapter);

	/* Enable interrupts */
	if (MP_TEST_FLAG(adapter, fMP_ADAPTER_INTERRUPT_IN_USE)) {
		et131x_enable_interrupts(adapter);
	}

	/* Restart the Tx and Rx DMA engines */
	et131x_rx_dma_enable(adapter);
	et131x_tx_dma_enable(adapter);

	/* Restart the netif queue */
	netif_wake_queue(netdev);

	DBG_LEAVE(et131x_dbginfo);
	return result;
}
Exemple #18
0
/**
 * et131x_tx_timeout - Timeout handler
 * @netdev: a pointer to a net_device struct representing the device
 *
 * The handler called when a Tx request times out. The timeout period is
 * specified by the 'tx_timeo" element in the net_device structure (see
 * et131x_alloc_device() to see how this value is set).
 */
void et131x_tx_timeout(struct net_device *netdev)
{
	struct et131x_adapter *pAdapter = netdev_priv(netdev);
	PMP_TCB pMpTcb;
	unsigned long lockflags;

	DBG_WARNING(et131x_dbginfo, "TX TIMEOUT\n");

	/* Just skip this part if the adapter is doing link detection */
	if (MP_TEST_FLAG(pAdapter, fMP_ADAPTER_LINK_DETECTION)) {
		DBG_ERROR(et131x_dbginfo, "Still doing link detection\n");
		return;
	}

	/* Any nonrecoverable hardware error?
	 * Checks adapter->flags for any failure in phy reading
	 */
	if (MP_TEST_FLAG(pAdapter, fMP_ADAPTER_NON_RECOVER_ERROR)) {
		DBG_WARNING(et131x_dbginfo, "Non recoverable error - remove\n");
		return;
	}

	/* Hardware failure? */
	if (MP_TEST_FLAG(pAdapter, fMP_ADAPTER_HARDWARE_ERROR)) {
		DBG_WARNING(et131x_dbginfo, "hardware error - reset\n");
		return;
	}

	/* Is send stuck? */
	spin_lock_irqsave(&pAdapter->TCBSendQLock, lockflags);

	pMpTcb = pAdapter->TxRing.CurrSendHead;

	if (pMpTcb != NULL) {
		pMpTcb->Count++;

		if (pMpTcb->Count > NIC_SEND_HANG_THRESHOLD) {
#ifdef CONFIG_ET131X_DEBUG
			TX_STATUS_BLOCK_t txDmaComplete =
			    *(pAdapter->TxRing.pTxStatusVa);
			PTX_DESC_ENTRY_t pDesc =
			    pAdapter->TxRing.pTxDescRingVa +
			    pMpTcb->WrIndex.bits.val;
#endif
			TX_DESC_ENTRY_t StuckDescriptors[10];

			if (pMpTcb->WrIndex.bits.val > 7) {
				memcpy(StuckDescriptors,
				       pAdapter->TxRing.pTxDescRingVa +
				       pMpTcb->WrIndex.bits.val - 6,
				       sizeof(TX_DESC_ENTRY_t) * 10);
			}

			spin_unlock_irqrestore(&pAdapter->TCBSendQLock,
					       lockflags);

			DBG_WARNING(et131x_dbginfo,
				    "Send stuck - reset.  pMpTcb->WrIndex %x, Flags 0x%08x\n",
				    pMpTcb->WrIndex.bits.val,
				    pMpTcb->Flags);

			DBG_WARNING(et131x_dbginfo,
				    "pDesc 0x%08x, 0x%08x, 0x%08x, 0x%08x\n",
				    pDesc->DataBufferPtrHigh,
				    pDesc->DataBufferPtrLow, pDesc->word2.value,
				    pDesc->word3.value);

			DBG_WARNING(et131x_dbginfo,
				    "WbStatus 0x%08x\n", txDmaComplete.value);

#ifdef CONFIG_ET131X_DEBUG
			DumpDeviceBlock(DBG_WARNING_ON, pAdapter, 0);
			DumpDeviceBlock(DBG_WARNING_ON, pAdapter, 1);
			DumpDeviceBlock(DBG_WARNING_ON, pAdapter, 3);
			DumpDeviceBlock(DBG_WARNING_ON, pAdapter, 5);
#endif
			et131x_close(netdev);
			et131x_open(netdev);

			return;
		}
	}

	spin_unlock_irqrestore(&pAdapter->TCBSendQLock, lockflags);
}
Exemple #19
0
/* struct smbd_smb2_read_state destructor. Send the SMB2_READ data. */
static int smb2_sendfile_send_data(struct smbd_smb2_read_state *state)
{
	struct lock_struct lock;
	uint32_t in_length = state->in_length;
	uint64_t in_offset = state->in_offset;
	files_struct *fsp = state->fsp;
	const DATA_BLOB *hdr = state->smb2req->queue_entry.sendfile_header;
	NTSTATUS *pstatus = state->smb2req->queue_entry.sendfile_status;
	struct smbXsrv_connection *xconn = state->smb2req->xconn;
	ssize_t nread;
	ssize_t ret;
	int saved_errno;

	nread = SMB_VFS_SENDFILE(xconn->transport.sock,
				 fsp,
				 hdr,
				 in_offset,
				 in_length);
	DEBUG(10,("smb2_sendfile_send_data: SMB_VFS_SENDFILE returned %d on file %s\n",
		(int)nread,
		fsp_str_dbg(fsp) ));

	if (nread == -1) {
		saved_errno = errno;

		/*
		 * Returning ENOSYS means no data at all was sent.
		   Do this as a normal read. */
		if (errno == ENOSYS) {
			goto normal_read;
		}

		if (errno == ENOTSUP) {
			set_use_sendfile(SNUM(fsp->conn), false);
			DBG_WARNING("Disabling sendfile use as sendfile is "
				    "not supported by the system\n");
			goto normal_read;
		}

		if (errno == EINTR) {
			/*
			 * Special hack for broken Linux with no working sendfile. If we
			 * return EINTR we sent the header but not the rest of the data.
			 * Fake this up by doing read/write calls.
			 */
			set_use_sendfile(SNUM(fsp->conn), false);
			nread = fake_sendfile(xconn, fsp, in_offset, in_length);
			if (nread == -1) {
				saved_errno = errno;
				DEBUG(0,("smb2_sendfile_send_data: fake_sendfile "
					 "failed for file %s (%s) for client %s. "
					 "Terminating\n",
					 fsp_str_dbg(fsp), strerror(saved_errno),
					 smbXsrv_connection_dbg(xconn)));
				*pstatus = map_nt_error_from_unix_common(saved_errno);
				return 0;
			}
			goto out;
		}

		DEBUG(0,("smb2_sendfile_send_data: sendfile failed for file "
			 "%s (%s) for client %s. Terminating\n",
			 fsp_str_dbg(fsp), strerror(saved_errno),
			 smbXsrv_connection_dbg(xconn)));
		*pstatus = map_nt_error_from_unix_common(saved_errno);
		return 0;
	} else if (nread == 0) {
		/*
		 * Some sendfile implementations return 0 to indicate
		 * that there was a short read, but nothing was
		 * actually written to the socket.  In this case,
		 * fallback to the normal read path so the header gets
		 * the correct byte count.
		 */
		DEBUG(3, ("send_file_readX: sendfile sent zero bytes "
			"falling back to the normal read: %s\n",
			fsp_str_dbg(fsp)));
		goto normal_read;
	}

	/*
	 * We got a short read
	 */
	goto out;

normal_read:
	/* Send out the header. */
	ret = write_data(xconn->transport.sock,
			 (const char *)hdr->data, hdr->length);
	if (ret != hdr->length) {
		saved_errno = errno;
		DEBUG(0,("smb2_sendfile_send_data: write_data failed for file "
			 "%s (%s) for client %s. Terminating\n",
			 fsp_str_dbg(fsp), strerror(saved_errno),
			 smbXsrv_connection_dbg(xconn)));
		*pstatus = map_nt_error_from_unix_common(saved_errno);
		return 0;
	}
	nread = fake_sendfile(xconn, fsp, in_offset, in_length);
	if (nread == -1) {
		saved_errno = errno;
		DEBUG(0,("smb2_sendfile_send_data: fake_sendfile "
			 "failed for file %s (%s) for client %s. "
			 "Terminating\n",
			 fsp_str_dbg(fsp), strerror(saved_errno),
			 smbXsrv_connection_dbg(xconn)));
		*pstatus = map_nt_error_from_unix_common(saved_errno);
		return 0;
	}

  out:

	if (nread < in_length) {
		ret = sendfile_short_send(xconn, fsp, nread,
					  hdr->length, in_length);
		if (ret == -1) {
			saved_errno = errno;
			DEBUG(0,("%s: sendfile_short_send "
				 "failed for file %s (%s) for client %s. "
				 "Terminating\n",
				 __func__,
				 fsp_str_dbg(fsp), strerror(saved_errno),
				 smbXsrv_connection_dbg(xconn)));
			*pstatus = map_nt_error_from_unix_common(saved_errno);
			return 0;
		}
	}

	init_strict_lock_struct(fsp,
				fsp->op->global->open_persistent_id,
				in_offset,
				in_length,
				READ_LOCK,
				&lock);

	SMB_VFS_STRICT_UNLOCK(fsp->conn, fsp, &lock);

	*pstatus = NT_STATUS_OK;
	return 0;
}
Exemple #20
0
/*
 * called to create a new server task
 */
static void prefork_new_task(
	struct tevent_context *ev,
	struct loadparm_context *lp_ctx,
	const char *service_name,
	void (*new_task_fn)(struct tevent_context *,
			    struct loadparm_context *lp_ctx,
			    struct server_id , void *, void *),
	void *private_data,
	const struct service_details *service_details,
	int from_parent_fd)
{
	pid_t pid;
	struct tfork* t = NULL;
	int i, num_children;

	struct tevent_context *ev2;

	t = tfork_create();
	if (t == NULL) {
		smb_panic("failure in tfork\n");
	}

	pid = tfork_child_pid(t);
	if (pid != 0) {
		struct tevent_fd *fde = NULL;
		int fd = tfork_event_fd(t);

		/* Register a pipe handler that gets called when the prefork
		 * master process terminates.
		 */
		fde = tevent_add_fd(ev, ev, fd, TEVENT_FD_READ,
				    prefork_child_pipe_handler, t);
		if (fde == NULL) {
			smb_panic("Failed to add child pipe handler, "
				  "after fork");
		}
		tevent_fd_set_auto_close(fde);
		return;
	}

	pid = getpid();
	setproctitle("task[%s] pre-fork master", service_name);

	/*
	 * this will free all the listening sockets and all state that
	 * is not associated with this new connection
	 */
	if (tevent_re_initialise(ev) != 0) {
		smb_panic("Failed to re-initialise tevent after fork");
	}
	prefork_reload_after_fork();
	setup_handlers(ev, from_parent_fd);

	if (service_details->inhibit_pre_fork) {
		new_task_fn(ev, lp_ctx, cluster_id(pid, 0), private_data, NULL);
		/* The task does not support pre-fork */
		tevent_loop_wait(ev);
		TALLOC_FREE(ev);
		exit(0);
	}

	/*
	 * This is now the child code. We need a completely new event_context
	 * to work with
	 */
	ev2 = s4_event_context_init(NULL);

	/* setup this new connection: process will bind to it's sockets etc
	 *
	 * While we can use ev for the child, which has been re-initialised
	 * above we must run the new task under ev2 otherwise the children would
	 * be listening on the sockets.  Also we don't want the top level
	 * process accepting and handling requests, it's responsible for
	 * monitoring and controlling the child work processes.
	 */
	new_task_fn(ev2, lp_ctx, cluster_id(pid, 0), private_data, NULL);

	{
		int default_children;
		default_children = lpcfg_prefork_children(lp_ctx);
		num_children = lpcfg_parm_int(lp_ctx, NULL, "prefork children",
			                      service_name, default_children);
	}
	if (num_children == 0) {
		DBG_WARNING("Number of pre-fork children for %s is zero, "
			    "NO worker processes will be started for %s\n",
			    service_name, service_name);
	}
	DBG_NOTICE("Forking %d %s worker processes\n",
		   num_children, service_name);
	/* We are now free to spawn some worker processes */
	for (i=0; i < num_children; i++) {
		struct tfork* w = NULL;

		w = tfork_create();
		if (w == NULL) {
			smb_panic("failure in tfork\n");
		}

		pid = tfork_child_pid(w);
		if (pid != 0) {
			struct tevent_fd *fde = NULL;
			int fd = tfork_event_fd(w);

			fde = tevent_add_fd(ev, ev, fd, TEVENT_FD_READ,
					    prefork_child_pipe_handler, w);
			if (fde == NULL) {
				smb_panic("Failed to add child pipe handler, "
					  "after fork");
			}
			tevent_fd_set_auto_close(fde);
		} else {
			/* tfork uses malloc */
			free(w);

			TALLOC_FREE(ev);
			setproctitle("task[%s] pre-forked worker",
				     service_name);
			prefork_reload_after_fork();
			setup_handlers(ev2, from_parent_fd);
			tevent_loop_wait(ev2);
			talloc_free(ev2);
			exit(0);
		}
	}

	/* Don't listen on the sockets we just gave to the children */
	tevent_loop_wait(ev);
	TALLOC_FREE(ev);
	/* We need to keep ev2 until we're finished for the messaging to work */
	TALLOC_FREE(ev2);
	exit(0);

}
Exemple #21
0
/**
 * ConfigMacRegs2 - Initialize the second part of MAC regs
 * @pAdpater: pointer to our adapter structure
 */
void ConfigMACRegs2(struct et131x_adapter *pAdapter)
{
	int32_t delay = 0;
	struct _MAC_t __iomem *pMac = &pAdapter->CSRAddress->mac;
	MAC_CFG1_t cfg1;
	MAC_CFG2_t cfg2;
	MAC_IF_CTRL_t ifctrl;
	TXMAC_CTL_t ctl;

	DBG_ENTER(et131x_dbginfo);

	ctl.value = readl(&pAdapter->CSRAddress->txmac.ctl.value);
	cfg1.value = readl(&pMac->cfg1.value);
	cfg2.value = readl(&pMac->cfg2.value);
	ifctrl.value = readl(&pMac->if_ctrl.value);

	if (pAdapter->uiLinkSpeed == TRUEPHY_SPEED_1000MBPS) {
		cfg2.bits.if_mode = 0x2;
		ifctrl.bits.phy_mode = 0x0;
	} else {
		cfg2.bits.if_mode = 0x1;
		ifctrl.bits.phy_mode = 0x1;
	}

	/* We need to enable Rx/Tx */
	cfg1.bits.rx_enable = 0x1;
	cfg1.bits.tx_enable = 0x1;

	/* Set up flow control */
	cfg1.bits.tx_flow = 0x1;

	if ((pAdapter->FlowControl == RxOnly) ||
	    (pAdapter->FlowControl == Both)) {
		cfg1.bits.rx_flow = 0x1;
	} else {
		cfg1.bits.rx_flow = 0x0;
	}

	/* Initialize loop back to off */
	cfg1.bits.loop_back = 0;

	writel(cfg1.value, &pMac->cfg1.value);

	/* Now we need to initialize the MAC Configuration 2 register */
	cfg2.bits.preamble_len = 0x7;
	cfg2.bits.huge_frame = 0x0;
	/* LENGTH FIELD CHECKING bit4: Set this bit to cause the MAC to check
	 * the frame's length field to ensure it matches the actual data
	 * field length. Clear this bit if no length field checking is
	 * desired. Its default is 0.
	 */
	cfg2.bits.len_check = 0x1;

	if (pAdapter->RegistryPhyLoopbk == false) {
		cfg2.bits.pad_crc = 0x1;
		cfg2.bits.crc_enable = 0x1;
	} else {
		cfg2.bits.pad_crc = 0;
		cfg2.bits.crc_enable = 0;
	}

	/* 1 - full duplex, 0 - half-duplex */
	cfg2.bits.full_duplex = pAdapter->uiDuplexMode;
	ifctrl.bits.ghd_mode = !pAdapter->uiDuplexMode;

	writel(ifctrl.value, &pMac->if_ctrl.value);
	writel(cfg2.value, &pMac->cfg2.value);

	do {
		udelay(10);
		delay++;
		cfg1.value = readl(&pMac->cfg1.value);
	} while ((!cfg1.bits.syncd_rx_en ||
		  !cfg1.bits.syncd_tx_en) &&
		 delay < 100);

	if (delay == 100) {
		DBG_ERROR(et131x_dbginfo,
			  "Syncd bits did not respond correctly cfg1 word 0x%08x\n",
			  cfg1.value);
	}

	DBG_TRACE(et131x_dbginfo,
		  "Speed %d, Dup %d, CFG1 0x%08x, CFG2 0x%08x, if_ctrl 0x%08x\n",
		  pAdapter->uiLinkSpeed, pAdapter->uiDuplexMode,
		  readl(&pMac->cfg1.value), readl(&pMac->cfg2.value),
		  readl(&pMac->if_ctrl.value));

	/* Enable TXMAC */
	ctl.bits.txmac_en = 0x1;
	ctl.bits.fc_disable = 0x1;
	writel(ctl.value, &pAdapter->CSRAddress->txmac.ctl.value);

	/* Ready to start the RXDMA/TXDMA engine */
	if (!MP_TEST_FLAG(pAdapter, fMP_ADAPTER_LOWER_POWER)) {
		et131x_rx_dma_enable(pAdapter);
		et131x_tx_dma_enable(pAdapter);
	} else {
		DBG_WARNING(et131x_dbginfo,
			    "Didn't enable Rx/Tx due to low-power mode\n");
	}

	DBG_LEAVE(et131x_dbginfo);
}
Exemple #22
0
/* Query display info for a realm. This is the basic user list fn */
static NTSTATUS query_user_list(struct winbindd_domain *domain,
			       TALLOC_CTX *mem_ctx,
			       uint32_t **prids)
{
	ADS_STRUCT *ads = NULL;
	const char *attrs[] = { "sAMAccountType", "objectSid", NULL };
	int count;
	uint32_t *rids = NULL;
	ADS_STATUS rc;
	LDAPMessage *res = NULL;
	LDAPMessage *msg = NULL;
	NTSTATUS status = NT_STATUS_UNSUCCESSFUL;

	DEBUG(3,("ads: query_user_list\n"));

	if ( !winbindd_can_contact_domain( domain ) ) {
		DEBUG(10,("query_user_list: No incoming trust for domain %s\n",
			  domain->name));		
		return NT_STATUS_OK;
	}

	ads = ads_cached_connection(domain);

	if (!ads) {
		domain->last_status = NT_STATUS_SERVER_DISABLED;
		goto done;
	}

	rc = ads_search_retry(ads, &res, "(objectCategory=user)", attrs);
	if (!ADS_ERR_OK(rc)) {
		DEBUG(1,("query_user_list ads_search: %s\n", ads_errstr(rc)));
		status = ads_ntstatus(rc);
		goto done;
	} else if (!res) {
		DEBUG(1,("query_user_list ads_search returned NULL res\n"));
		goto done;
	}

	count = ads_count_replies(ads, res);
	if (count == 0) {
		DEBUG(1,("query_user_list: No users found\n"));
		goto done;
	}

	rids = talloc_zero_array(mem_ctx, uint32_t, count);
	if (rids == NULL) {
		status = NT_STATUS_NO_MEMORY;
		goto done;
	}

	count = 0;

	for (msg = ads_first_entry(ads, res); msg; msg = ads_next_entry(ads, msg)) {
		struct dom_sid user_sid;
		uint32_t atype;
		bool ok;

		ok = ads_pull_uint32(ads, msg, "sAMAccountType", &atype);
		if (!ok) {
			DBG_INFO("Object lacks sAMAccountType attribute\n");
			continue;
		}
		if (ds_atype_map(atype) != SID_NAME_USER) {
			DBG_INFO("Not a user account? atype=0x%x\n", atype);
			continue;
		}

		if (!ads_pull_sid(ads, msg, "objectSid", &user_sid)) {
			char *dn = ads_get_dn(ads, talloc_tos(), msg);
			DBG_INFO("No sid for %s !?\n", dn);
			TALLOC_FREE(dn);
			continue;
		}

		if (!dom_sid_in_domain(&domain->sid, &user_sid)) {
			fstring sidstr, domstr;
			DBG_WARNING("Got sid %s in domain %s\n",
				    sid_to_fstring(sidstr, &user_sid),
				    sid_to_fstring(domstr, &domain->sid));
			continue;
		}

		sid_split_rid(&user_sid, &rids[count]);
		count += 1;
	}

	rids = talloc_realloc(mem_ctx, rids, uint32_t, count);
	if (prids != NULL) {
		*prids = rids;
	}

	status = NT_STATUS_OK;

	DBG_NOTICE("ads query_user_list gave %d entries\n", count);

done:
	return status;
}
Exemple #23
0
static NTSTATUS make_connection_snum(struct smbXsrv_connection *xconn,
					connection_struct *conn,
					int snum, struct user_struct *vuser,
					const char *pdev)
{
	struct smbd_server_connection *sconn = xconn->client->sconn;
	struct smb_filename *smb_fname_cpath = NULL;
	fstring dev;
	int ret;
	bool on_err_call_dis_hook = false;
	uid_t effuid;
	gid_t effgid;
	NTSTATUS status;

	fstrcpy(dev, pdev);

	status = share_sanity_checks(sconn->remote_address,
				       sconn->remote_hostname,
				       snum,
				       dev);
	if (NT_STATUS_IS_ERR(status)) {
		goto err_root_exit;
	}

	conn->params->service = snum;

	status = create_connection_session_info(sconn,
		conn, snum, vuser->session_info,
		&conn->session_info);

	if (!NT_STATUS_IS_OK(status)) {
		DEBUG(1, ("create_connection_session_info failed: %s\n",
			  nt_errstr(status)));
		goto err_root_exit;
	}

	if (lp_guest_only(snum)) {
		conn->force_user = true;
	}

	conn->num_files_open = 0;
	conn->lastused = conn->lastused_count = time(NULL);
	conn->printer = (strncmp(dev,"LPT",3) == 0);
	conn->ipc = ( (strncmp(dev,"IPC",3) == 0) ||
		      ( lp_enable_asu_support() && strequal(dev,"ADMIN$")) );

	/* Case options for the share. */
	if (lp_case_sensitive(snum) == Auto) {
		/* We will be setting this per packet. Set to be case
		 * insensitive for now. */
		conn->case_sensitive = False;
	} else {
		conn->case_sensitive = (bool)lp_case_sensitive(snum);
	}

	conn->case_preserve = lp_preserve_case(snum);
	conn->short_case_preserve = lp_short_preserve_case(snum);

	conn->encrypt_level = lp_smb_encrypt(snum);

	conn->veto_list = NULL;
	conn->hide_list = NULL;
	conn->veto_oplock_list = NULL;
	conn->aio_write_behind_list = NULL;

	conn->read_only = lp_read_only(SNUM(conn));

	status = set_conn_force_user_group(conn, snum);
	if (!NT_STATUS_IS_OK(status)) {
		goto err_root_exit;
	}

	conn->vuid = vuser->vuid;

	{
		char *s = talloc_sub_advanced(talloc_tos(),
					lp_servicename(talloc_tos(), SNUM(conn)),
					conn->session_info->unix_info->unix_name,
					conn->connectpath,
					conn->session_info->unix_token->gid,
					conn->session_info->unix_info->sanitized_username,
					conn->session_info->info->domain_name,
					lp_path(talloc_tos(), snum));
		if (!s) {
			status = NT_STATUS_NO_MEMORY;
			goto err_root_exit;
		}

		if (!set_conn_connectpath(conn,s)) {
			TALLOC_FREE(s);
			status = NT_STATUS_NO_MEMORY;
			goto err_root_exit;
		}
		DEBUG(3,("Connect path is '%s' for service [%s]\n",s,
			 lp_servicename(talloc_tos(), snum)));
		TALLOC_FREE(s);
	}

	/*
	 * Set up the share security descriptor.
	 * NOTE - we use the *INCOMING USER* session_info
	 * here, as does (indirectly) change_to_user(),
	 * which can be called on any incoming packet.
	 * This way we set up the share access based
	 * on the authenticated user, not the forced
	 * user. See bug:
	 *
	 * https://bugzilla.samba.org/show_bug.cgi?id=9878
	 */

	status = check_user_share_access(conn,
					vuser->session_info,
					&conn->share_access,
					&conn->read_only);
	if (!NT_STATUS_IS_OK(status)) {
		goto err_root_exit;
	}

	/* Initialise VFS function pointers */

	if (!smbd_vfs_init(conn)) {
		DEBUG(0, ("vfs_init failed for service %s\n",
			  lp_servicename(talloc_tos(), snum)));
		status = NT_STATUS_BAD_NETWORK_NAME;
		goto err_root_exit;
	}

/* ROOT Activities: */
	/* explicitly check widelinks here so that we can correctly warn
	 * in the logs. */
	widelinks_warning(snum);

	/*
	 * Enforce the max connections parameter.
	 */

	if ((lp_max_connections(snum) > 0)
	    && (count_current_connections(lp_servicename(talloc_tos(), SNUM(conn)), True) >=
		lp_max_connections(snum))) {

		DEBUG(1, ("Max connections (%d) exceeded for %s\n",
			  lp_max_connections(snum),
			  lp_servicename(talloc_tos(), snum)));
		status = NT_STATUS_INSUFFICIENT_RESOURCES;
		goto err_root_exit;
	}

	/* Invoke VFS make connection hook - this must be the first
	   filesystem operation that we do. */

	if (SMB_VFS_CONNECT(conn, lp_servicename(talloc_tos(), snum),
			    conn->session_info->unix_info->unix_name) < 0) {
		DBG_WARNING("SMB_VFS_CONNECT for service '%s' at '%s' failed: %s\n",
			    lp_servicename(talloc_tos(), snum), conn->connectpath,
			    strerror(errno));
		status = NT_STATUS_UNSUCCESSFUL;
		goto err_root_exit;
	}

	/* Any error exit after here needs to call the disconnect hook. */
	on_err_call_dis_hook = true;

	if ((!conn->printer) && (!conn->ipc) &&
	    lp_change_notify()) {
		if (sconn->notify_ctx == NULL) {
			sconn->notify_ctx = notify_init(
				sconn, sconn->msg_ctx, sconn->ev_ctx);
			status = messaging_register(
				sconn->msg_ctx, sconn,
				MSG_SMB_NOTIFY_CANCEL_DELETED,
				smbd_notify_cancel_deleted);
		}
		if (sconn->sys_notify_ctx == NULL) {
			sconn->sys_notify_ctx = sys_notify_context_create(
				sconn, sconn->ev_ctx);
		}
	}

	if (lp_kernel_oplocks(snum)) {
		init_kernel_oplocks(conn->sconn);
	}

	/*
	 * Fix compatibility issue pointed out by Volker.
	 * We pass the conn->connectpath to the preexec
	 * scripts as a parameter, so attempt to canonicalize
	 * it here before calling the preexec scripts.
	 * We ignore errors here, as it is possible that
	 * the conn->connectpath doesn't exist yet and
	 * the preexec scripts will create them.
	 */

	(void)canonicalize_connect_path(conn);

	/* Preexecs are done here as they might make the dir we are to ChDir
	 * to below */
	/* execute any "root preexec = " line */
	if (*lp_root_preexec(talloc_tos(), snum)) {
		char *cmd = talloc_sub_advanced(talloc_tos(),
					lp_servicename(talloc_tos(), SNUM(conn)),
					conn->session_info->unix_info->unix_name,
					conn->connectpath,
					conn->session_info->unix_token->gid,
					conn->session_info->unix_info->sanitized_username,
					conn->session_info->info->domain_name,
					lp_root_preexec(talloc_tos(), snum));
		DEBUG(5,("cmd=%s\n",cmd));
		ret = smbrun(cmd,NULL);
		TALLOC_FREE(cmd);
		if (ret != 0 && lp_root_preexec_close(snum)) {
			DEBUG(1,("root preexec gave %d - failing "
				 "connection\n", ret));
			status = NT_STATUS_ACCESS_DENIED;
			goto err_root_exit;
		}
	}

/* USER Activites: */
	if (!change_to_user(conn, conn->vuid)) {
		/* No point continuing if they fail the basic checks */
		DEBUG(0,("Can't become connected user!\n"));
		status = NT_STATUS_LOGON_FAILURE;
		goto err_root_exit;
	}

	effuid = geteuid();
	effgid = getegid();

	/* Remember that a different vuid can connect later without these
	 * checks... */

	/* Preexecs are done here as they might make the dir we are to ChDir
	 * to below */

	/* execute any "preexec = " line */
	if (*lp_preexec(talloc_tos(), snum)) {
		char *cmd = talloc_sub_advanced(talloc_tos(),
					lp_servicename(talloc_tos(), SNUM(conn)),
					conn->session_info->unix_info->unix_name,
					conn->connectpath,
					conn->session_info->unix_token->gid,
					conn->session_info->unix_info->sanitized_username,
					conn->session_info->info->domain_name,
					lp_preexec(talloc_tos(), snum));
		ret = smbrun(cmd,NULL);
		TALLOC_FREE(cmd);
		if (ret != 0 && lp_preexec_close(snum)) {
			DEBUG(1,("preexec gave %d - failing connection\n",
				 ret));
			status = NT_STATUS_ACCESS_DENIED;
			goto err_root_exit;
		}
	}

#ifdef WITH_FAKE_KASERVER
	if (lp_afs_share(snum)) {
		afs_login(conn);
	}
#endif

	/*
	 * we've finished with the user stuff - go back to root
	 * so the SMB_VFS_STAT call will only fail on path errors,
	 * not permission problems.
	 */
	change_to_root_user();
/* ROOT Activites: */

	/*
	 * If widelinks are disallowed we need to canonicalise the connect
	 * path here to ensure we don't have any symlinks in the
	 * connectpath. We will be checking all paths on this connection are
	 * below this directory. We must do this after the VFS init as we
	 * depend on the realpath() pointer in the vfs table. JRA.
	 */
	if (!lp_widelinks(snum)) {
		if (!canonicalize_connect_path(conn)) {
			DEBUG(0, ("canonicalize_connect_path failed "
			"for service %s, path %s\n",
				lp_servicename(talloc_tos(), snum),
				conn->connectpath));
			status = NT_STATUS_BAD_NETWORK_NAME;
			goto err_root_exit;
		}
	}

	/* Add veto/hide lists */
	if (!IS_IPC(conn) && !IS_PRINT(conn)) {
		set_namearray( &conn->veto_list,
			       lp_veto_files(talloc_tos(), snum));
		set_namearray( &conn->hide_list,
			       lp_hide_files(talloc_tos(), snum));
		set_namearray( &conn->veto_oplock_list,
			       lp_veto_oplock_files(talloc_tos(), snum));
		set_namearray( &conn->aio_write_behind_list,
				lp_aio_write_behind(talloc_tos(), snum));
	}
	smb_fname_cpath = synthetic_smb_fname(talloc_tos(), conn->connectpath,
					      NULL, NULL);
	if (smb_fname_cpath == NULL) {
		status = NT_STATUS_NO_MEMORY;
		goto err_root_exit;
	}

	/* win2000 does not check the permissions on the directory
	   during the tree connect, instead relying on permission
	   check during individual operations. To match this behaviour
	   I have disabled this chdir check (tridge) */
	/* the alternative is just to check the directory exists */

	if ((ret = SMB_VFS_STAT(conn, smb_fname_cpath)) != 0 ||
	    !S_ISDIR(smb_fname_cpath->st.st_ex_mode)) {
		if (ret == 0 && !S_ISDIR(smb_fname_cpath->st.st_ex_mode)) {
			DEBUG(0,("'%s' is not a directory, when connecting to "
				 "[%s]\n", conn->connectpath,
				 lp_servicename(talloc_tos(), snum)));
		} else {
			DEBUG(0,("'%s' does not exist or permission denied "
				 "when connecting to [%s] Error was %s\n",
				 conn->connectpath,
				 lp_servicename(talloc_tos(), snum),
				 strerror(errno) ));
		}
		status = NT_STATUS_BAD_NETWORK_NAME;
		goto err_root_exit;
	}
	conn->base_share_dev = smb_fname_cpath->st.st_ex_dev;

	talloc_free(conn->origpath);
	conn->origpath = talloc_strdup(conn, conn->connectpath);

	/* Figure out the characteristics of the underlying filesystem. This
	 * assumes that all the filesystem mounted withing a share path have
	 * the same characteristics, which is likely but not guaranteed.
	 */

	conn->fs_capabilities = SMB_VFS_FS_CAPABILITIES(conn, &conn->ts_res);

	/*
	 * Print out the 'connected as' stuff here as we need
	 * to know the effective uid and gid we will be using
	 * (at least initially).
	 */

	if( DEBUGLVL( IS_IPC(conn) ? 3 : 2 ) ) {
		dbgtext( "%s (%s) ", get_remote_machine_name(),
			 tsocket_address_string(conn->sconn->remote_address,
						talloc_tos()) );
		dbgtext( "%s", srv_is_signing_active(xconn) ? "signed " : "");
		dbgtext( "connect to service %s ",
			 lp_servicename(talloc_tos(), snum) );
		dbgtext( "initially as user %s ",
			 conn->session_info->unix_info->unix_name );
		dbgtext( "(uid=%d, gid=%d) ", (int)effuid, (int)effgid );
		dbgtext( "(pid %d)\n", (int)getpid() );
	}

	return status;

  err_root_exit:

	TALLOC_FREE(smb_fname_cpath);
	/* We must exit this function as root. */
	if (geteuid() != 0) {
		change_to_root_user();
	}
	if (on_err_call_dis_hook) {
		/* Call VFS disconnect hook */
		SMB_VFS_DISCONNECT(conn);
	}
	return status;
}
krb5_error_code kpasswd_handle_request(struct kdc_server *kdc,
				       TALLOC_CTX *mem_ctx,
				       struct gensec_security *gensec_security,
				       uint16_t verno,
				       DATA_BLOB *decoded_data,
				       DATA_BLOB *kpasswd_reply,
				       const char **error_string)
{
	struct auth_session_info *session_info;
	NTSTATUS status;

	status = gensec_session_info(gensec_security,
				     mem_ctx,
				     &session_info);
	if (!NT_STATUS_IS_OK(status)) {
		*error_string = talloc_asprintf(mem_ctx,
						"gensec_session_info failed - "
						"%s",
						nt_errstr(status));
		return KRB5_KPASSWD_HARDERROR;
	}

	switch(verno) {
	case 1: {
		DATA_BLOB password;
		bool ok;

		ok = convert_string_talloc_handle(mem_ctx,
						  lpcfg_iconv_handle(kdc->task->lp_ctx),
						  CH_UTF8,
						  CH_UTF16,
						  (const char *)decoded_data->data,
						  decoded_data->length,
						  (void **)&password.data,
						  &password.length);
		if (!ok) {
			*error_string = "String conversion failed!";
			DBG_WARNING("%s\n", *error_string);
			return KRB5_KPASSWD_HARDERROR;
		}

		return kpasswd_change_password(kdc,
					       mem_ctx,
					       session_info,
					       &password,
					       kpasswd_reply,
					       error_string);
	}
	case RFC3244_VERSION: {
		return kpasswd_set_password(kdc,
					    mem_ctx,
					    session_info,
					    decoded_data,
					    kpasswd_reply,
					    error_string);
	}
	default:
		return KRB5_KPASSWD_BAD_VERSION;
	}

	return 0;
}