Exemplo n.º 1
0
pig_target_addr_ctx *add_target_addr_to_pig_target_addr(pig_target_addr_ctx *addrs, const char *range) {
    pig_target_addr_ctx *head = addrs, *p = NULL;
    if (head == NULL) {
        new_pig_target_addr(head);
        p = head;
    } else {
        p = get_pig_target_addr_tail(head);
        new_pig_target_addr(p->next);
        p = p->next;
    }
    p->type = get_range_type(range);
    switch (p->type) {

        case kAddr:
            p->addr = to_ipv4(range);
            break;

        case kWild:
            p->addr = to_ipv4_mask(range);
            break;

        case kCidr:
            p->addr = to_ipv4_cidr(range, &p->cidr_range);
            break;

        default:
            break;

    }
    p->v = 4;
    p->asize = sizeof(int);
    return head;
}
Exemplo n.º 2
0
Arquivo: main.c Projeto: huap/pig
static pig_target_addr_ctx *parse_targets(const char *targets) {
    pig_target_addr_ctx *addr = NULL;
    const char *tp = NULL;
    char range[0xff];
    size_t r = 0;
    if (targets == NULL) {
        return NULL;
    }
    memset(range, 0, sizeof(range));
    r = 0;
    for (tp = targets; *tp != 0; tp++) {
        if (*tp == ',' || *(tp + 1) == 0) {
            if (*(tp + 1) == 0) {
                range[r] = *tp;
            }
            if (get_range_type(range) == kNone) {
                printf("pig WARNING: the IP range \"%s\" seems invalid... it will be skipped.\n", range);
            } else {
                addr = add_target_addr_to_pig_target_addr(addr, range);
            }
            r = 0;
            memset(range, 0, sizeof(range));
        } else {
            range[r] = *tp;
            r = (r + 1) % sizeof(range);
        }
    }
    return addr;
}
	CError CInterfaceDefinitionLoader::handle_element_value( const string &element_value )
	{
		assert( m_interface_definition && !m_element_path.empty() );

		/* interface info */
		READ_MEMBER( 
			"InterfaceDeclaration.InterfaceInfo.Name", 
			m_interface_definition->m_interface_info->m_name );

		READ_MEMBER( 
			"InterfaceDeclaration.InterfaceInfo.Label", 
			m_interface_definition->m_interface_info->m_label );

		READ_MEMBER( 
			"InterfaceDeclaration.InterfaceInfo.Description", 
			m_interface_definition->m_interface_info->m_description );

		READ_SET_CONTENT( 
			"InterfaceDeclaration.InterfaceInfo.Tags.Tag", 
			m_interface_definition->m_interface_info->m_tags );

		READ_MEMBER( 
			"InterfaceDeclaration.InterfaceInfo.ImplementedInLibIntegra", 
			m_interface_definition->m_interface_info->m_implemented_in_libintegra );

		READ_MEMBER( 
			"InterfaceDeclaration.InterfaceInfo.Author", 
			m_interface_definition->m_interface_info->m_author );

		READ_MEMBER( 
			"InterfaceDeclaration.InterfaceInfo.CreatedDate", 
			m_interface_definition->m_interface_info->m_created_date );

		READ_MEMBER( 
			"InterfaceDeclaration.InterfaceInfo.ModifiedDate", 
			m_interface_definition->m_interface_info->m_modified_date );


		/* endpoint info */
		READ_MEMBER( 
			"InterfaceDeclaration.EndpointInfo.Endpoint.Name", 
			current_endpoint().m_name );

		READ_MEMBER( 
			"InterfaceDeclaration.EndpointInfo.Endpoint.Label", 
			current_endpoint().m_label );

		READ_MEMBER( 
			"InterfaceDeclaration.EndpointInfo.Endpoint.Description", 
			current_endpoint().m_description );

		READ_MEMBER( 
			"InterfaceDeclaration.EndpointInfo.Endpoint.Type", 
			current_endpoint().m_type );

		READ_MEMBER( 
			"InterfaceDeclaration.EndpointInfo.Endpoint.ControlInfo.ControlType", 
			current_endpoint().m_control_info->m_type );

		READ_MEMBER( 
			"InterfaceDeclaration.EndpointInfo.Endpoint.ControlInfo.StateInfo.StateType", 
			current_endpoint().m_control_info->m_state_info->m_type );

		READ_VALUE( 
			"InterfaceDeclaration.EndpointInfo.Endpoint.ControlInfo.StateInfo.Constraint.Range.Minimum",
			current_endpoint().m_control_info->m_state_info->m_constraint->m_value_range->m_minimum,
			get_range_type() );

		READ_VALUE( 
			"InterfaceDeclaration.EndpointInfo.Endpoint.ControlInfo.StateInfo.Constraint.Range.Maximum",
			current_endpoint().m_control_info->m_state_info->m_constraint->m_value_range->m_maximum,
			get_range_type() );

		READ_VALUE_SET_CONTENT( 
			"InterfaceDeclaration.EndpointInfo.Endpoint.ControlInfo.StateInfo.Constraint.AllowedStates.State",
			current_endpoint().m_control_info->m_state_info->m_constraint->m_allowed_states,
			get_state_type() );
	
		READ_VALUE( 
			"InterfaceDeclaration.EndpointInfo.Endpoint.ControlInfo.StateInfo.Default",
			current_endpoint().m_control_info->m_state_info->m_default_value,
			get_state_type() );

		READ_MEMBER(
			"InterfaceDeclaration.EndpointInfo.Endpoint.ControlInfo.StateInfo.Scale.ScaleType",
			current_endpoint().m_control_info->m_state_info->m_value_scale->m_type );

		READ_VALUE( 
			"InterfaceDeclaration.EndpointInfo.Endpoint.ControlInfo.StateInfo.StateLabels.Label.State",
			m_last_state_label_value,
			get_state_type() );

		READ_MEMBER( 
			"InterfaceDeclaration.EndpointInfo.Endpoint.ControlInfo.StateInfo.StateLabels.Label.Text",
			m_last_state_label_key );

		READ_MEMBER(
			"InterfaceDeclaration.EndpointInfo.Endpoint.ControlInfo.StateInfo.IsInputFile",
			current_endpoint().m_control_info->m_state_info->m_is_input_file );

		READ_MEMBER(
			"InterfaceDeclaration.EndpointInfo.Endpoint.ControlInfo.StateInfo.IsSavedToFile",
			current_endpoint().m_control_info->m_state_info->m_is_saved_to_file );

		READ_MEMBER(
			"InterfaceDeclaration.EndpointInfo.Endpoint.ControlInfo.CanBeSource",
			current_endpoint().m_control_info->m_can_be_source );

		READ_MEMBER(
			"InterfaceDeclaration.EndpointInfo.Endpoint.ControlInfo.CanBeTarget",
			current_endpoint().m_control_info->m_can_be_target );

		READ_MEMBER(
			"InterfaceDeclaration.EndpointInfo.Endpoint.ControlInfo.IsSentToHost",
			current_endpoint().m_control_info->m_is_sent_to_host );

		READ_MEMBER(
			"InterfaceDeclaration.EndpointInfo.Endpoint.StreamInfo.StreamType",
			current_endpoint().m_stream_info->m_type );

		READ_MEMBER(
			"InterfaceDeclaration.EndpointInfo.Endpoint.StreamInfo.StreamDirection",
			current_endpoint().m_stream_info->m_direction );


		/* widget info */

		READ_MEMBER( 
			"InterfaceDeclaration.WidgetInfo.Widget.WidgetType",
			current_widget().m_type );

		READ_MEMBER(
			"InterfaceDeclaration.WidgetInfo.Widget.Label",
			current_widget().m_label );

		READ_MEMBER(
			"InterfaceDeclaration.WidgetInfo.Widget.Position.X",
			current_widget().m_position->m_x );

		READ_MEMBER(
			"InterfaceDeclaration.WidgetInfo.Widget.Position.Y",
			current_widget().m_position->m_y );

		READ_MEMBER(
			"InterfaceDeclaration.WidgetInfo.Widget.Position.Width",
			current_widget().m_position->m_width );

		READ_MEMBER(
			"InterfaceDeclaration.WidgetInfo.Widget.Position.Height",
			current_widget().m_position->m_height );

		READ_MEMBER(
			"InterfaceDeclaration.WidgetInfo.Widget.AttributeMappings.AttributeMapping.WidgetAttribute",
			m_last_widget_key );

		READ_MEMBER(
			"InterfaceDeclaration.WidgetInfo.Widget.AttributeMappings.AttributeMapping.Endpoint",
			m_last_widget_value );

		/* implementation info */

		READ_MEMBER( 
			"InterfaceDeclaration.ImplementationInfo.PatchName",
			m_interface_definition->m_implementation_info->m_patch_name );

		INTEGRA_TRACE_ERROR << "unhandled element: " << m_element_path << " for module: " << m_interface_definition->m_interface_info->m_name;
	
		return CError::SUCCESS;

	}