/******************************************************************************* Copyright(c) 1999 - 2003 Intel Corporation. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. The full GNU General Public License is included in this distribution in the file called LICENSE. Contact Information: Linux NICS Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 *******************************************************************************/ #include "e100.h" #include "e100_config.h" extern u16 e100_eeprom_read(struct e100_private *, u16); extern int e100_wait_exec_cmplx(struct e100_private *, u32,u8, u8); extern void e100_phy_reset(struct e100_private *bdp); extern void e100_phy_autoneg(struct e100_private *bdp); extern void e100_phy_set_loopback(struct e100_private *bdp); extern void e100_force_speed_duplex(struct e100_private *bdp); static u8 e100_diag_selftest(struct net_device *); static u8 e100_diag_eeprom(struct net_device *); static u8 e100_diag_loopback(struct net_device *); static u8 e100_diag_one_loopback (struct net_device *, u8); static u8 e100_diag_rcv_loopback_pkt(struct e100_private *); static void e100_diag_config_loopback(struct e100_private *, u8, u8, u8 *,u8 *); static u8 e100_diag_loopback_alloc(struct e100_private *); static void e100_diag_loopback_cu_ru_exec(struct e100_private *); static u8 e100_diag_check_pkt(u8 *); static void e100_diag_loopback_free(struct e100_private *); #define LB_PACKET_SIZE 1500 /** * e100_run_diag - main test execution handler - checks mask of requests and calls the diag routines * @dev: atapter's net device data struct * @test_info: array with test request mask also used to store test results * * RETURNS: updated flags field of struct ethtool_test */ u32 e100_run_diag(struct net_device *dev, u64 *test_info, u32 flags) { struct e100_private* bdp = dev->priv; u8 test_result = true; e100_isolate_driver(bdp); if (flags & ETH_TEST_FL_OFFLINE) { u8 fail_mask; fail_mask = e100_diag_selftest(dev); if (fail_mask) { test_result = false; if (fail_mask & REGISTER_TEST_FAIL) test_info [E100_REG_TEST_FAIL] = true; if (fail_mask & ROM_TEST_FAIL) test_info [E100_ROM_TEST_FAIL] = true; if (fail_mask & SELF_TEST_FAIL) test_info [E100_MAC_TEST_FAIL] = true; if (fail_mask & TEST_TIMEOUT) test_info [E100_CHIP_TIMEOUT] = true; } fail_mask = e100_diag_loopback(dev); if (fail_mask) { test_result = false; if (fail_mask & PHY_LOOPBACK) test_info [E100_LPBK_PHY_FAIL] = true; if (fail_mask & MAC_LOOPBACK) test_info [E100_LPBK_MAC_FAIL] = true; } } if (!e100_diag_eeprom(dev)) { test_result = false; test_info [E100_EEPROM_TEST_FAIL] = true; } set_current_state(TASK_UNINTERRUPTIBLE); schedule_timeout(HZ * 2); e100_deisolate_driver(bdp, false); return flags | (test_result ? 0 : ETH_TEST_FL_FAILED); } /** * e100_diag_selftest - run hardware selftest * @dev: atapter's net device data struct */ static u8 e100_diag_selftest(struct net_device *dev) { struct e100_private *bdp = dev->priv; u32 st_timeout, st_result; u8 retval = 0; if (!e100_selftest(bdp, &st_timeout, &st_result)) { if (!st_timeout) { if (st_result & CB_SELFTEST_REGISTER_BIT) retval |= REGISTER_TEST_FAIL; if (st_result & CB_SELFTEST_DIAG_BIT) retval |= SELF_TEST_FAIL; if (st_result & CB_SELFTEST_ROM_BIT) retval |= ROM_TEST_FAIL; } else { retval = TEST_TIMEOUT; } } e100_configure_device(bdp); return retval; } /** * e100_diag_eeprom - validate eeprom checksum correctness * @dev: atapter's net device data struct * */ static u8 e100_diag_eeprom (struct net_device *dev) { struct e100_private *bdp = dev->priv; u16 i, eeprom_sum, eeprom_actual_csm; for (i = 0, eeprom_sum = 0; i < (bdp->eeprom_size - 1); i++) { eeprom_sum += e100_eeprom_read(bdp, i); } eeprom_actual_csm = e100_eeprom_read(bdp, bdp->eeprom_size - 1); if (eeprom_actual_csm == (u16)(EEPROM_SUM - eeprom_sum)) { return true; } return false; } /** * e100_diag_loopback - performs loopback test * @dev: atapter's net device data struct */ static u8 e100_diag_loopback (struct net_device *dev) { u8 rc = 0; printk(KERN_DEBUG "%s: PHY loopback test starts\n", dev->name); e100_sw_reset(dev->priv, PORT_SELECTIVE_RESET); if (!e100_diag_one_loopback(dev, PHY_LOOPBACK)) { rc |= PHY_LOOPBACK; } printk(KERN_DEBUG "%s: PHY loopback test ends\n", dev->name); printk(KERN_DEBUG "%s: MAC loopback test starts\n", dev->name); e100_sw_reset(dev->priv, PORT_SELECTIVE_RESET); if (!e100_diag_one_loopback(dev, MAC_LOOPBACK)) { rc |= MAC_LOOPBACK; } printk(KERN_DEBUG "%s: MAC loopback test ends\n", dev->name); return rc; } /** * e100_diag_loopback - performs loopback test * @dev: atapter's net device data struct * @mode: lopback test type */ static u8 e100_diag_one_loopback (struct net_device *dev, u8 mode) { struct e100_private *bdp = dev->priv; u8 res = false; u8 saved_dynamic_tbd = false; u8 saved_extended_tcb = false; if (!e100_diag_loopback_alloc(bdp)) return false; /* change the config block to standard tcb and the correct loopback */ e100_diag_config_loopback(bdp, true, mode, &saved_extended_tcb, &saved_dynamic_tbd); e100_diag_loopback_cu_ru_exec(bdp); if (e100_diag_rcv_loopb
# This file is dual licensed under the terms of the Apache License, Version
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
# for complete details.

from __future__ import absolute_import, division, print_function

INCLUDES = """
#include <openssl/pkcs7.h>
"""

TYPES = """
typedef struct {
    Cryptography_STACK_OF_X509 *cert;
    Cryptography_STACK_OF_X509_CRL *crl;
    ...;
} PKCS7_SIGNED;

typedef struct {
    Cryptography_STACK_OF_X509 *cert;
    Cryptography_STACK_OF_X509_CRL *crl;
    ...;
} PKCS7_SIGN_ENVELOPE;

typedef ... PKCS7_DIGEST;
typedef ... PKCS7_ENCRYPT;
typedef ... PKCS7_ENVELOPE;

typedef struct {
    ASN1_OBJECT *type;
    union {
        char *ptr;
        ASN1_OCTET_STRING *data;
        PKCS7_SIGNED *sign;
        PKCS7_ENVELOPE *enveloped;
        PKCS7_SIGN_ENVELOPE *signed_and_enveloped;
        PKCS7_DIGEST *digest;
        PKCS7_ENCRYPT *encrypted;
        ASN1_TYPE *other;
     } d;
    ...;
} PKCS7;

static const int PKCS7_BINARY;
static const int PKCS7_DETACHED;
static const int PKCS7_NOATTR;
static const int PKCS7_NOCERTS;
static const int PKCS7_NOCHAIN;
static const int PKCS7_NOINTERN;
static const int PKCS7_NOSIGS;
static const int PKCS7_NOSMIMECAP;
static const int PKCS7_NOVERIFY;
static const int PKCS7_STREAM;
static const int PKCS7_TEXT;
"""

FUNCTIONS = """
PKCS7 *SMIME_read_PKCS7(BIO *, BIO **);
int SMIME_write_PKCS7(BIO *, PKCS7 *, BIO *, int);

void PKCS7_free(PKCS7 *);

PKCS7 *PKCS7_sign(X509 *, EVP_PKEY *, Cryptography_STACK_OF_X509 *,
                  BIO *, int);
int PKCS7_verify(PKCS7 *, Cryptography_STACK_OF_X509 *, X509_STORE *, BIO *,
                 BIO *, int);
Cryptography_STACK_OF_X509 *PKCS7_get0_signers(PKCS7 *,
                                               Cryptography_STACK_OF_X509 *,
                                               int);

PKCS7 *PKCS7_encrypt(Cryptography_STACK_OF_X509 *, BIO *,
                     const EVP_CIPHER *, int);
int PKCS7_decrypt(PKCS7 *, EVP_PKEY *, X509 *, BIO *, int);

BIO *PKCS7_dataInit(PKCS7 *, BIO *);
int PKCS7_type_is_encrypted(PKCS7 *);
int PKCS7_type_is_signed(PKCS7 *);
int PKCS7_type_is_enveloped(PKCS7 *);
int PKCS7_type_is_signedAndEnveloped(PKCS7 *);
int PKCS7_type_is_data(PKCS7 *);
int PKCS7_type_is_digest(PKCS7 *);
"""

CUSTOMIZATIONS = ""