|
| 1 | +/* |
| 2 | + * app_csm.h |
| 3 | + * |
| 4 | + * Copyright(c) 2016-2019 Nephos/Estinet. |
| 5 | + * |
| 6 | + * This program is free software; you can redistribute it and/or modify it |
| 7 | + * under the terms and conditions of the GNU General Public License, |
| 8 | + * version 2, as published by the Free Software Foundation. |
| 9 | + * |
| 10 | + * This program is distributed in the hope it will be useful, but WITHOUT |
| 11 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 13 | + * more details. |
| 14 | + * |
| 15 | + * You should have received a copy of the GNU General Public License along with |
| 16 | + * this program; if not, see <http://www.gnu.org/licenses/>. |
| 17 | + * |
| 18 | + * The full GNU General Public License is included in this distribution in |
| 19 | + * the file called "COPYING". |
| 20 | + * |
| 21 | + * Maintainer: jianjun, grace Li from nephos |
| 22 | + */ |
| 23 | + |
| 24 | +#ifndef APP_CSM_H_ |
| 25 | +#define APP_CSM_H_ |
| 26 | + |
| 27 | +#include <sys/queue.h> |
| 28 | + |
| 29 | +#include "../include/mlacp_fsm.h" |
| 30 | + |
| 31 | +struct CSM; |
| 32 | + |
| 33 | +enum APP_CONNECTION_STATE |
| 34 | +{ |
| 35 | + APP_NONEXISTENT, |
| 36 | + APP_RESET, |
| 37 | + APP_CONNSENT, |
| 38 | + APP_CONNREC, |
| 39 | + APP_CONNECTING, |
| 40 | + APP_OPERATIONAL |
| 41 | +}; |
| 42 | + |
| 43 | +typedef enum APP_CONNECTION_STATE APP_CONNECTION_STATE_E; |
| 44 | + |
| 45 | +struct AppCSM |
| 46 | +{ |
| 47 | + struct mLACP mlacp; |
| 48 | + APP_CONNECTION_STATE_E current_state; |
| 49 | + |
| 50 | + uint32_t rx_connect_msg_id; |
| 51 | + uint32_t tx_connect_msg_id; |
| 52 | + uint32_t invalid_msg_id; |
| 53 | + |
| 54 | + TAILQ_HEAD(app_msg_list, Msg) app_msg_list; |
| 55 | + |
| 56 | + uint8_t invalid_msg : 1; |
| 57 | + uint8_t nak_msg : 1; |
| 58 | +}; |
| 59 | + |
| 60 | +void app_csm_init(struct CSM*, int all); |
| 61 | +void app_csm_finalize(struct CSM*); |
| 62 | +void app_csm_transit(struct CSM*); |
| 63 | +int app_csm_prepare_iccp_msg(struct CSM*, char*, size_t); |
| 64 | +void app_csm_enqueue_msg(struct CSM*, struct Msg*); |
| 65 | +struct Msg* app_csm_dequeue_msg(struct CSM*); |
| 66 | +void app_csm_correspond_from_msg(struct CSM*, struct Msg*); |
| 67 | +void app_csm_correspond_from_connect_msg(struct CSM*, struct Msg*); |
| 68 | +void app_csm_correspond_from_connect_ack_msg(struct CSM*, struct Msg*); |
| 69 | +int app_csm_prepare_nak_msg(struct CSM*, char*, size_t); |
| 70 | +int app_csm_prepare_connect_msg(struct CSM*, char*, size_t); |
| 71 | +int app_csm_prepare_connect_ack_msg(struct CSM*, char*, size_t); |
| 72 | + |
| 73 | +#endif /* APP_CSM_H_ */ |
0 commit comments