Exemplo n.º 1
0
static int cli_lacp_getpartnerinterface(void *c_sys, int argc, cli_args_t *args)
{
	short unsigned int *pusportpriority;
	unsigned char *pucstate;
	short unsigned int *puskey;
	unsigned char *pucsystemid;
	long unsigned int *pulmaclen;
	int port = port_to_num(args[0].value);

#if 0
	LACP_GetAggPortPartnerPortPriority(port, pusportpriority);
	usleep(10000);
	LACP_GetAggPortPartnerState(port, pucstate);
	usleep(10000);
	LACP_GetAggPortPartnerOperKey(port, puskey);
	usleep(10000);
	LACP_GetAggPortPartnerSystemId(port, pucsystemid, pulmaclen);
	return 0;
#endif

#if 1
	processFlag_dislacp = 1;
	LACP_GetAggPortPartnerPortPriority(port, pusportpriority);
	struct json_object *new_obj1 = NULL;
	new_obj1 = json_tokener_parse(msg_lacp->msg);
	struct json_object *obj1 = json_object_object_get(new_obj1, "PortPartnerPortPriority");
	printf("  PortPartnerPortPriority        :%d\n", json_object_get_int(obj1));
	json_object_put(obj1);
	json_object_put(new_obj1);	
	processFlag_dislacp = 1;
	LACP_GetAggPortPartnerState(port, pucstate);
	struct json_object *new_obj2 = NULL;
	new_obj2 = json_tokener_parse(msg_lacp->msg);
	struct json_object *obj2 = json_object_object_get(new_obj2, "PortPartnerState");
	printf("  PortPartnerState               :%d\n", json_object_get_int(obj2));
	json_object_put(obj2);
	json_object_put(new_obj2);	
	processFlag_dislacp = 1;
	LACP_GetAggPortPartnerOperKey(port, puskey);
	struct json_object *new_obj3 = NULL;
	new_obj3 = json_tokener_parse(msg_lacp->msg);
	struct json_object *obj3 = json_object_object_get(new_obj3, "PortPartnerOperKey");
	printf("  PortPartnerOperKey             :%d\n", json_object_get_int(obj3));
	json_object_put(obj3);
	json_object_put(new_obj3);	
	processFlag_dislacp = 1;
	LACP_GetAggPortPartnerSystemId(port, pucsystemid, pulmaclen);
	struct json_object *new_obj4 = NULL;
	new_obj4 = json_tokener_parse(msg_lacp->msg);
	struct json_object *obj4 = json_object_object_get(new_obj4, "PortPartnerSystemId");

	printf("  PortPartnerSystemId            :%d\n", json_object_get_int(obj4));
	json_object_put(obj4);
	json_object_put(new_obj4);	
	processFlag_dislacp = 0;
	return 0;
#endif
}
Exemplo n.º 2
0
static int cli_fe_show_port_detail(void *c_sys, int argc, cli_args_t *args)
{
	int port = port_to_num(args[0].value);
	char *portname[5] = {0};
	portname[0] = aIF_getPortName(FE, port);
	if(portname[0])
	{
		return swSpanningTree_show_port_detail(portname, 1);
	}
	else
		return -1;
}
Exemplo n.º 3
0
static int cli_fe_show_port_status_for_msti(void *c_sys, int argc, cli_args_t *args)
{
	int port = port_to_num(args[1].value);
	char *portname = NULL;
	portname = aIF_getPortName(FE, port);
	if(portname)
	{
		return swSpanningTree_show_port_status_for_msti(portname, atoi(args[0].value));
	}
	else
		return -1;
}
Exemplo n.º 4
0
void get_port_interrupt(const ComType com, const GetPortInterrupt *data) {
	const uint8_t port_num = port_to_num(data->port);

	if(port_num > 1) {
		BA->com_return_error(data, sizeof(GetPortInterruptReturn), MESSAGE_ERROR_CODE_INVALID_PARAMETER, com);
		return;
	}

	GetPortInterruptReturn gpir;

	gpir.header         = data->header;
	gpir.header.length  = sizeof(GetPortInterruptReturn);
	gpir.interrupt_mask = BC->current_gpinten[port_num];

	BA->send_blocking_with_timeout(&gpir, sizeof(GetPortInterruptReturn), com);
}
Exemplo n.º 5
0
void get_port(const ComType com, const GetPort *data) {
	const uint8_t port_num = port_to_num(data->port);

	if(port_num > 1) {
		BA->com_return_error(data, sizeof(GetPortReturn), MESSAGE_ERROR_CODE_INVALID_PARAMETER, com);
		return;
	}

	GetPortReturn gpr;

	gpr.header        = data->header;
	gpr.header.length = sizeof(GetPortReturn);
	gpr.value_mask    = io_read_gpio(port_num);

	BA->send_blocking_with_timeout(&gpr, sizeof(GetPortReturn), com);
}
Exemplo n.º 6
0
void get_port_monoflop(const ComType com, const GetPortMonoflop *data) {
	const uint8_t port_num = port_to_num(data->port);

	if(port_num > 1 || data->pin >= NUM_PINS_PER_PORT) {
		BA->com_return_error(data, sizeof(GetPortMonoflopReturn), MESSAGE_ERROR_CODE_INVALID_PARAMETER, com);
		return;
	}

	GetPortMonoflopReturn gpmr;

	gpmr.header         = data->header;
	gpmr.header.length  = sizeof(GetPortMonoflopReturn);
	gpmr.value          = (io_read_gpio(port_num) & (1 << data->pin)) ? 1 : 0;
	gpmr.time           = BC->time[data->pin][port_num];
	gpmr.time_remaining = BC->time_remaining[data->pin][port_num];

	BA->send_blocking_with_timeout(&gpmr, sizeof(GetPortMonoflopReturn), com);
}
Exemplo n.º 7
0
void set_port_interrupt(const ComType com, const SetPortInterrupt *data) {
	const uint8_t port_num = port_to_num(data->port);

	uint8_t mask = data->interrupt_mask;

	if(port_num > 1) {
		BA->com_return_error(data, sizeof(MessageHeader), MESSAGE_ERROR_CODE_INVALID_PARAMETER, com);
		return;
	}

	BC->current_gpinten[port_num] = data->interrupt_mask;

	if(port_num == 0) {
		mask |= MASK_EDGE_COUNT;
	}
	io_write(I2C_INTERNAL_ADDRESS_GPINTEN_A + port_num, mask);
	BA->com_return_setter(com, data);
}
Exemplo n.º 8
0
void get_port_configuration(const ComType com, const GetPortConfiguration *data) {
	const uint8_t port_num = port_to_num(data->port);

	if(port_num > 1) {
		BA->com_return_error(data, sizeof(GetPortConfigurationReturn), MESSAGE_ERROR_CODE_INVALID_PARAMETER, com);
		return;
	}

	GetPortConfigurationReturn gpcr;

	gpcr.header         = data->header;
	gpcr.header.length  = sizeof(GetPortConfigurationReturn);

	gpcr.direction_mask = BC->current_iodir[port_num];
	gpcr.value_mask     = (  BC->current_iodir[port_num]  & BC->current_gppu[port_num]) |
	                      ((~BC->current_iodir[port_num]) & BC->current_olat[port_num]);

	BA->send_blocking_with_timeout(&gpcr, sizeof(GetPortConfigurationReturn), com);
}
Exemplo n.º 9
0
void set_port(const ComType com, const SetPort *data) {
	// set_port sets output latches, values are measured on port if port
	// is configured as output
	const uint8_t port_num = port_to_num(data->port);

	if(port_num > 1) {
		BA->com_return_error(data, sizeof(MessageHeader), MESSAGE_ERROR_CODE_INVALID_PARAMETER, com);
		return;
	}

	for(uint8_t i = 0; i < NUM_PINS_PER_PORT; i++) {
		 BC->time_remaining[i][port_num] = 0;
	}

	BC->current_olat[port_num] = data->value_mask;
	io_write(I2C_INTERNAL_ADDRESS_OLAT_A + port_num, BC->current_olat[port_num]);

	BA->com_return_setter(com, data);
}
Exemplo n.º 10
0
void set_port_configuration(const ComType com, const SetPortConfiguration *data) {
	const uint8_t port_num = port_to_num(data->port);

	if(port_num > 1) {
		BA->com_return_error(data, sizeof(MessageHeader), MESSAGE_ERROR_CODE_INVALID_PARAMETER, com);
		return;
	}

	if(data->direction == 'i' || data->direction == 'I') {
		BC->current_iodir[port_num] |= data->selection_mask;
		io_write(I2C_INTERNAL_ADDRESS_IODIR_A + port_num, BC->current_iodir[port_num]);

		if(data->value) {
			BC->current_gppu[port_num] |= data->selection_mask;
		} else {
			BC->current_gppu[port_num] &= ~(data->selection_mask);
		}
		io_write(I2C_INTERNAL_ADDRESS_GPPU_A + port_num, BC->current_gppu[port_num]);
	} else if(data->direction == 'o' || data->direction == 'O') {
		if(data->value) {
			BC->current_olat[port_num] |= data->selection_mask;
		} else {
			BC->current_olat[port_num] &= ~(data->selection_mask);
		}
		io_write(I2C_INTERNAL_ADDRESS_OLAT_A + port_num, BC->current_olat[port_num]);

		BC->current_iodir[port_num] &= ~(data->selection_mask);
		io_write(I2C_INTERNAL_ADDRESS_IODIR_A + port_num, BC->current_iodir[port_num]);
	} else {
		BA->com_return_error(data, sizeof(MessageHeader), MESSAGE_ERROR_CODE_INVALID_PARAMETER, com);
		return;
	}

	for(uint8_t i = 0; i < NUM_PINS_PER_PORT; i++) {
		if(data->selection_mask & (1 << i)) {
			BC->time_remaining[i][port_num] = 0;
		}
	}

	BA->com_return_setter(com, data);
}
Exemplo n.º 11
0
void set_selected_values(const ComType com, const SetSelectedValues *data) {
	const uint8_t port_num = port_to_num(data->port);

	if(port_num > 1) {
		BA->com_return_error(data, sizeof(MessageHeader), MESSAGE_ERROR_CODE_INVALID_PARAMETER, com);
		return;
	}

	for(uint8_t i = 0; i < NUM_PINS_PER_PORT; i++) {
		if(data->selection_mask & (1 << i)) {
			BC->time_remaining[i][port_num] = 0;
			if(data->value_mask & (1 << i)) {
				BC->current_olat[port_num] |= 1 << i;
			} else {
				BC->current_olat[port_num] &= ~(1 << i);
			}
		}
	}

	io_write(I2C_INTERNAL_ADDRESS_OLAT_A + port_num, BC->current_olat[port_num]);

	BA->com_return_setter(com, data);
}
Exemplo n.º 12
0
static int cli_lacp_getinterface(void *c_sys, int argc, cli_args_t *args)
{
	unsigned int *pulaggid;
	short unsigned int *pusportpriority;
	unsigned char *pucsystemid;
	long unsigned int *pulmaclen;
	char *puctimeoutstate;
	unsigned int *pulkey;
	short unsigned int *puskey;
	char *pucmode;
	unsigned int *pulaggregateorindividual;
	int port = port_to_num(args[0].value);

#if 0
	LACP_GetAggPortSelectedAggID(port, pulaggid);
	usleep(10000);
	LACP_GetAggPortAttachedAggID(port, pulaggid);
	usleep(10000);
	LACP_GetAggPortActorPortPriority(port, pusportpriority);
	usleep(10000);
	LACP_GetPortLacpAdminKey(port, pulkey);	
	usleep(10000);
	LACP_GetPortLacpMode(port, pucmode);	
	usleep(10000);
	LACP_GetAggPortActorSystemId(port, pucsystemid, pulmaclen);
	usleep(10000);
	LACP_GetAggPortTimeOutState(port, puctimeoutstate);
	usleep(10000);
	LACP_GetAggPortActorOperKey(port, puskey);
	return 0;
#endif

#if 1
	processFlag_dislacp = 1;
	LACP_GetAggPortSelectedAggID(port, pulaggid);
	struct json_object *new_obj1 = NULL;
	new_obj1 = json_tokener_parse(msg_lacp->msg);
	struct json_object *obj1 = json_object_object_get(new_obj1, "PortSelectedAggID");
	printf("  PortSelectedAggID        :%d\n", json_object_get_int(obj1));
	json_object_put(obj1);
	json_object_put(new_obj1);	

	processFlag_dislacp = 1;
	LACP_GetAggPortAttachedAggID(port, pulaggid);
	struct json_object *new_obj2 = NULL;
	new_obj2 = json_tokener_parse(msg_lacp->msg);
	struct json_object *obj2 = json_object_object_get(new_obj2, "PortAttachedAggID");

	printf("  PortAttachedAggID        :%d\n", json_object_get_int(obj2));
	json_object_put(obj2);
	json_object_put(new_obj2);	

	processFlag_dislacp = 1;
	LACP_GetAggPortActorPortPriority(port, pusportpriority);
	struct json_object *new_obj3 = NULL;
	new_obj3 = json_tokener_parse(msg_lacp->msg);
	struct json_object *obj3 = json_object_object_get(new_obj3, "PortActorPortPriority");

	printf("  PortActorPortPriority    :%d\n", json_object_get_int(obj3));
	json_object_put(obj3);
	json_object_put(new_obj3);	

	//	LACP_GetAggPortActorSystemId(port, pucsystemid, pulmaclen);

	//	LACP_GetAggPortTimeOutState(port, puctimeoutstate);

	processFlag_dislacp = 1;
	LACP_GetPortLacpAdminKey(port, pulkey);	
	struct json_object *new_obj4 = NULL;
	new_obj4 = json_tokener_parse(msg_lacp->msg);
	struct json_object *obj4 = json_object_object_get(new_obj4, "PortLacpAdminKey");

	printf("  PortLacpAdminKey         :%d\n", json_object_get_int(obj4));
	json_object_put(obj4);
	json_object_put(new_obj4);	

	//	LACP_GetAggPortActorOperKey(port, puskey);

	processFlag_dislacp = 1;
	LACP_GetPortLacpMode(port, pucmode);	
	struct json_object *new_obj5 = NULL;
	new_obj5 = json_tokener_parse(msg_lacp->msg);
	struct json_object *obj5 = json_object_object_get(new_obj5, "PortLacpMode");

	if(json_object_get_int(obj5) == 0)
		printf("  PortLacpMode             :passive\n");
	else{
		printf("  PortLacpMode             :active\n");}
	json_object_put(obj5);
	json_object_put(new_obj5);	

	//	LACP_GetAggPortAggregateOrIndividual(port, pulaggregateorindividual);

	processFlag_dislacp = 0;
	return 0;
#endif
}
Exemplo n.º 13
0
static int cli_swport_getportstatic(void *c_sys, int argc, cli_args_t *args)
{
	int port = port_to_num(args[0].value);
	return swPort_getPortStastic(port);
}
Exemplo n.º 14
0
static int cli_lacp_delstaticlag(void *c_sys, int argc, cli_args_t *args)
{
	int port = port_to_num(args[1].value);	
	int ret = LACP_SetStaticLag(0, port);
	return ret;
}