| 3286 | |
| 3287 | #if ENABLE_BONDING |
| 3288 | bool srt::CUDT::interpretGroup(const int32_t groupdata[], size_t data_size SRT_ATR_UNUSED, int hsreq_type_cmd SRT_ATR_UNUSED) |
| 3289 | { |
| 3290 | // `data_size` isn't checked because we believe it's checked earlier. |
| 3291 | // Also this code doesn't predict to get any other format than the official one, |
| 3292 | // so there are only data in two fields. Passing this argument is only left |
| 3293 | // for consistency and possibly changes in future. |
| 3294 | |
| 3295 | // We are granted these two fields do exist |
| 3296 | SRTSOCKET grpid = groupdata[GRPD_GROUPID]; |
| 3297 | uint32_t gd = groupdata[GRPD_GROUPDATA]; |
| 3298 | |
| 3299 | SRT_GROUP_TYPE gtp = SRT_GROUP_TYPE(SrtHSRequest::HS_GROUP_TYPE::unwrap(gd)); |
| 3300 | int link_weight = SrtHSRequest::HS_GROUP_WEIGHT::unwrap(gd); |
| 3301 | uint32_t link_flags = SrtHSRequest::HS_GROUP_FLAGS::unwrap(gd); |
| 3302 | |
| 3303 | if (m_config.iGroupConnect == 0) |
| 3304 | { |
| 3305 | m_RejectReason = SRT_REJ_GROUP; |
| 3306 | LOGC(cnlog.Error, log << CONID() << "HS/GROUP: this socket is not allowed for group connect."); |
| 3307 | return false; |
| 3308 | } |
| 3309 | |
| 3310 | // This is called when the group type has come in the handshake is invalid. |
| 3311 | if (gtp >= SRT_GTYPE_E_END) |
| 3312 | { |
| 3313 | m_RejectReason = SRT_REJ_GROUP; |
| 3314 | LOGC(cnlog.Error, |
| 3315 | log << CONID() << "HS/GROUP: incorrect group type value " << gtp << " (max is " << SRT_GTYPE_E_END << ")"); |
| 3316 | return false; |
| 3317 | } |
| 3318 | |
| 3319 | if ((grpid & SRTGROUP_MASK) == 0) |
| 3320 | { |
| 3321 | m_RejectReason = SRT_REJ_ROGUE; |
| 3322 | LOGC(cnlog.Error, log << CONID() << "HS/GROUP: socket ID passed as a group ID is not a group ID"); |
| 3323 | return false; |
| 3324 | } |
| 3325 | |
| 3326 | // We have the group, now take appropriate action. |
| 3327 | // The redundancy group requires to make a mirror group |
| 3328 | // on this side, and the newly created socket should |
| 3329 | // be made belong to it. |
| 3330 | |
| 3331 | #if ENABLE_HEAVY_LOGGING |
| 3332 | static const char* hs_side_name[] = {"draw", "initiator", "responder"}; |
| 3333 | HLOGC(cnlog.Debug, |
| 3334 | log << CONID() << "interpretGroup: STATE: HsSide=" << hs_side_name[m_SrtHsSide] |
| 3335 | << " HS MSG: " << MessageTypeStr(UMSG_EXT, hsreq_type_cmd) << " $" << grpid << " type=" << gtp |
| 3336 | << " weight=" << link_weight << " flags=0x" << std::hex << link_flags); |
| 3337 | #endif |
| 3338 | |
| 3339 | // XXX Here are two separate possibilities: |
| 3340 | // |
| 3341 | // 1. This is a HS request and this is a newly created socket not yet part of any group. |
| 3342 | // 2. This is a HS response and the group is the mirror group for the group to which the agent belongs; we need to pin the mirror group as peer group |
| 3343 | // |
| 3344 | // These two situations can be only distinguished by the HS side. |
| 3345 | if (m_SrtHsSide == HSD_DRAW) |
nothing calls this directly
no test coverage detected