core.c
/*
 * @brief Sets the EID accordingly to the provided policy and creates response.
 * See DSP0236 1.3.0 12.3
 */
@brief Sets the EID accordingly to the provided policy and creates response.
@brief Sets the EID accordingly to the provided policy and creates response .
int mctp_ctrl_cmd_set_endpoint_id(struct mctp *mctp, mctp_eid_t dest_eid,
				  struct mctp_ctrl_cmd_set_eid *request,
				  struct mctp_ctrl_resp_set_eid *response)
{
	struct mctp_bus *bus = find_bus_for_eid(mctp, dest_eid);
	if (!request || !response)
		return -1;
	if (request->eid == MCTP_EID_BROADCAST ||
	    request->eid == MCTP_EID_NULL) {
		response->completion_code = MCTP_CTRL_CC_ERROR_INVALID_DATA;
		response->eid_set = mctp_bus_get_eid(bus);
		return 0;
	}
	switch (request->operation) {
	case 0: 
		if (mctp->n_busses == 1 || bus->eid == 0x0) {
			mctp_bus_set_eid(bus, request->eid);
			response->eid_set = request->eid;
			SET_MCTP_EID_ASSIGNMENT_STATUS(response->status,
						       MCTP_SET_EID_ACCEPTED);
		} else {
			response->eid_set = bus->eid;
			SET_MCTP_EID_ASSIGNMENT_STATUS(response->status,
						       MCTP_SET_EID_REJECTED);
		}
		response->completion_code = MCTP_CTRL_CC_SUCCESS;
		break;
	case 1: 
		mctp_bus_set_eid(bus, request->eid);
		response->completion_code = MCTP_CTRL_CC_SUCCESS;
		response->eid_set = request->eid;
		break;
	default: 
		response->completion_code = MCTP_CTRL_CC_ERROR_INVALID_DATA;
	}
	return 0;
}
int mctp_ctrl_cmd_set_endpoint_id ( struct mctp * mctp , mctp_eid_t dest_eid , struct mctp_ctrl_cmd_set_eid * request , struct mctp_ctrl_resp_set_eid * response ) { struct mctp_bus * bus = find_bus_for_eid ( mctp , dest_eid ) ; if ( ! request || ! response ) return -1 ; if ( request -> eid == MCTP_EID_BROADCAST || request -> eid == MCTP_EID_NULL ) { response -> completion_code = MCTP_CTRL_CC_ERROR_INVALID_DATA ; response -> eid_set = mctp_bus_get_eid ( bus ) ; return 0 ; } switch ( request -> operation ) { case 0 : if ( mctp -> n_busses == 1 || bus -> eid == 0x0 ) { mctp_bus_set_eid ( bus , request -> eid ) ; response -> eid_set = request -> eid ; SET_MCTP_EID_ASSIGNMENT_STATUS ( response -> status , MCTP_SET_EID_ACCEPTED ) ; } else { response -> eid_set = bus -> eid ; SET_MCTP_EID_ASSIGNMENT_STATUS ( response -> status , MCTP_SET_EID_REJECTED ) ; } response -> completion_code = MCTP_CTRL_CC_SUCCESS ; break ; case 1 : mctp_bus_set_eid ( bus , request -> eid ) ; response -> completion_code = MCTP_CTRL_CC_SUCCESS ; response -> eid_set = request -> eid ; break ; default : response -> completion_code = MCTP_CTRL_CC_ERROR_INVALID_DATA ; } return 0 ; }
@brief Sets the EID accordingly to the provided policy and creates response.
@brief Sets the EID accordingly to the provided policy and creates response .
/* Set EID */ /* TODO: Add tracking for bus owner and static reassignment. */ /* Force EID */ /* TODO: Need to figure out for static EID devices */ /* Reset EID and Set Discovered Flag */