/* * 模块名称:NET 层兄弟模块桩的观测面(net_socket 主机侧单测专用) * 模块功能:声明 ns_peers.c 的记录结构与复位入口。原型层面的约束(必须与真实头逐字 * 一致)在 ns_peers.c 里由"include 真实头 + 直接实现同名函数"保证: * 签名漂移 = 本套编译期红。 * ⚠ 仅供 test/host/net_socket/ 使用,不参与 MCU 构建。 * 创建日期:2026-10-24 */ #ifndef NS_PEERS_H #define NS_PEERS_H #include #include "FreeRTOS.h" #include "net_types.h" typedef struct { /* —— net_listener —— */ int listener_req_calls; int last_req_fd; int last_req_reason; int listener_clear_calls; int last_clear_fd; int listener_tick_calls; int listener_settle_calls; int last_settle_fd; int last_settle_level; int req_armed[NET_MAX_SOCKETS]; /* 登记未清=1(clear/tick 后归 0) */ int req_reason[NET_MAX_SOCKETS]; /* —— net_pending(recv) —— */ int pending_capture_calls; int pending_reg_calls; int pend_register_rc; /* 注入登记结果(默认 NET_PENDING_REGISTERED) */ int last_pend_fd; uint32_t last_pend_to; TaskHandle_t last_pend_caller; int pending_tick_calls; int pending_clear_calls; int last_pend_clear_fd; int pending_cancel_calls; int pending_cancel_all_calls; int last_pend_cancel_err; int pending_settle_calls; int pending_notified; /* 经由桩真实发出通知的次数(必通知契约) */ int pend_active_now[NET_MAX_SOCKETS]; /* —— net_pending(send) —— */ int send_reg_calls; int send_register_rc; int last_snd_fd; int last_snd_sent; int last_snd_len; int send_tick_calls; int send_clear_calls; int send_cancel_calls; int send_cancel_all_calls; int last_snd_cancel_err; int send_notified; /* 会话断开判据被问次数(2026-11-03 起该判据按 type 分流,TCP/UDP 共用一份) */ int state_down_calls; /* —— net_events —— */ int evt_connect_calls; int evt_disconnect_calls; int evt_recv_calls; int evt_send_calls; int evt_timeout_calls; int reconcile_calls; int lost_probe_calls; int lost_probe_hit; /* 1=让探针命中(补 accept) */ int last_probe_state; } ns_peers_obs_t; extern ns_peers_obs_t g_peers; void ns_peers_reset(void); void ns_peers_arm_pending_done(int sockfd, int result); void ns_peers_arm_send_pending_done(int sockfd, int result); /* 由 ns_peers.c 调用,把"桩内部完成的通知"接到假内核的通知面上 */ void ns_peers_note_notify(TaskHandle_t to, uint32_t v); #endif /* NS_PEERS_H */