| /* |
| <:copyright-BRCM:2016:DUAL/GPL:standard |
| |
| Broadcom Proprietary and Confidential.(c) 2016 Broadcom |
| All Rights Reserved |
| |
| Unless you and Broadcom execute a separate written software license |
| agreement governing use of this software, this software is licensed |
| to you under the terms of the GNU General Public License version 2 |
| (the "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, |
| with the following added to such license: |
| |
| As a special exception, the copyright holders of this software give |
| you permission to link this software with independent modules, and |
| to copy and distribute the resulting executable under terms of your |
| choice, provided that you also meet, for each linked independent |
| module, the terms and conditions of the license of that module. |
| An independent module is a module which is not derived from this |
| software. The special exception does not apply to any modifications |
| of the software. |
| |
| Not withstanding the above, under no circumstances may you combine |
| this software in any way with any other Broadcom software provided |
| under a license other than the GPL, without Broadcom's express prior |
| written consent. |
| |
| :> |
| */ |
| |
| #include "dpoe_sec_util.h" |
| #include "bcmolt_api.h" |
| |
| dev_log_id dpoe_sec_log_id[BCMTR_MAX_OLTS]; |
| |
| bcmos_bool dpoe_sec_eapol_unpack(bcmolt_buf *buf, eapol_msg_hdr *eapol) |
| { |
| return |
| bcmolt_buf_read_mac_address(buf, &eapol->da) && |
| bcmolt_buf_read_mac_address(buf, &eapol->sa) && |
| bcmolt_buf_read_u16_be(buf, &eapol->ether_type) && |
| bcmolt_buf_read_u8(buf, &eapol->eapol_version) && |
| bcmolt_buf_read_u8(buf, &eapol->eapol_packet_type) && |
| bcmolt_buf_read_u16_be(buf, &eapol->eapol_length); |
| } |
| |
| bcmos_errno bcmolt_epon_link_encryption_key_set( |
| bcmolt_devid device, |
| bcmolt_epon_link_key *link_key, |
| bcmos_bool up, /* TODO: create explicit up/down type for clarity */ |
| bcmolt_epon_encryption_mode mode, |
| bcmolt_epon_key_choice key_choice, |
| bcmolt_encryption_information_container *key_info) |
| { |
| bcmos_errno rc; |
| bcmolt_epon_link_cfg cfg; |
| |
| BCMOLT_CFG_INIT(&cfg, epon_link, *link_key); |
| BCMOLT_CFG_PROP_GET(&cfg, epon_link, epon_encryption); |
| rc = bcmolt_cfg_get(device, &cfg.hdr); |
| BCMOS_CHECK_RETURN_ERROR(BCM_ERR_OK != rc, rc); |
| |
| if (up) |
| { |
| cfg.data.epon_encryption.upstream_mode = mode; |
| cfg.data.epon_encryption.upstream_key_choice = key_choice; |
| cfg.data.epon_encryption.upstream_encryption_information = *key_info; |
| } |
| else |
| { |
| cfg.data.epon_encryption.downstream_mode = mode; |
| cfg.data.epon_encryption.downstream_key_choice = key_choice; |
| cfg.data.epon_encryption.downstream_encryption_information = *key_info; |
| } |
| |
| return bcmolt_cfg_set(device, &cfg.hdr); |
| } |
| |