Exemplo n.º 1
0
OFDPE
add_group_entry( group_entry *entry ) {
  assert( table != NULL );

  if ( entry == NULL ) {
    return ERROR_INVALID_PARAMETER;
  }

  if ( !valid_group_id( entry->group_id ) ) {
    return ERROR_OFDPE_GROUP_MOD_FAILED_INVALID_GROUP;
  }

  if ( group_exists( entry->group_id ) ) {
    return ERROR_OFDPE_GROUP_MOD_FAILED_GROUP_EXISTS;
  }

  if ( !lock_pipeline() ) {
    return ERROR_LOCK;
  }

  OFDPE ret = validate_group_entry( entry );
  if ( ret == OFDPE_SUCCESS ) {
    append_to_tail( &table->entries, entry );
  }

  if ( !unlock_pipeline() ) {
    return ERROR_UNLOCK;
  }

  return ret;
}
static void
check_name (gchar **primary_text, gchar **secondary_text, gpointer data)
{
    OobsGroup *group = OOBS_GROUP (data);
    GtkWidget *widget;
    const gchar *name;

    widget = gst_dialog_get_widget (tool->main_dialog, "group_settings_name");
    name = gtk_entry_get_text (GTK_ENTRY (widget));

    if (strlen (name) < 1) {
        *primary_text = g_strdup (_("Group name is empty"));
        *secondary_text = g_strdup (_("A group name must be specified."));
    } else if (is_group_root (group) && strcmp (name, "root") != 0) {
        *primary_text = g_strdup (_("Group name of the administrator group user should not be modified"));
        *secondary_text = g_strdup (_("This would leave the system unusable."));
    } else if (!is_valid_name (name)) {
        *primary_text = g_strdup (_("Group name has invalid characters"));
        *secondary_text = g_strdup (_("Please set a valid group name consisting of "
                                      "a lower case letter followed by lower case "
                                      "letters and numbers."));
    } else if (group_settings_dialog_group_is_new () && group_exists (name)) {
        *primary_text = g_strdup_printf (_("Group \"%s\" already exists"), name);
        *secondary_text = g_strdup (_("Please select a different user name."));
    }
}
Exemplo n.º 3
0
static OFDPE
validate_buckets( uint8_t type, bucket_list *buckets ) {
  assert( table != NULL );
  assert( buckets != NULL );

  OFDPE ret = OFDPE_SUCCESS;
  for ( dlist_element *element = get_first_element( buckets ); element != NULL; element = element->next ) {
    if ( element->data == NULL ) {
      continue;
    }
    bucket *bucket = element->data;
    if ( ( table->features.types & GROUP_TYPE_FF ) != 0 && type == OFPGT_FF ) {
      if ( !switch_port_exists( bucket->watch_port ) ) {
        ret = ERROR_OFDPE_GROUP_MOD_FAILED_BAD_WATCH;
        break;
      }
      if ( !group_exists( bucket->watch_group ) ) {
        ret = ERROR_OFDPE_GROUP_MOD_FAILED_BAD_WATCH;
        break;
      }
    }
    ret = validate_action_bucket( bucket );
    if ( ret != OFDPE_SUCCESS ) {
      break;
    }
  }

  return ret;
}
Exemplo n.º 4
0
OFDPE
validate_action_list( action_list *list ) {
  if ( list == NULL ) {
    return true;
  }

  OFDPE ret = OFDPE_SUCCESS;
  for ( dlist_element *element = get_first_element( list ); element != NULL; element = element->next ) {
    if ( element->data == NULL ) {
      continue;
    }
    action *action = element->data;
    if ( action->type == OFPAT_GROUP ) {
      if ( !group_exists( action->group_id ) ) {
        ret = ERROR_OFDPE_BAD_ACTION_BAD_OUT_GROUP;
        break;
      }
    }
    if ( action->type == OFPAT_OUTPUT ) {
      if ( action->port > 0 && action->port <= OFPP_MAX ) {
        if ( !switch_port_exists( action->port ) ) {
          ret = ERROR_OFDPE_BAD_ACTION_BAD_OUT_PORT;
        }
        break;
      }
      else if ( action->port != OFPP_ALL && action->port != OFPP_FLOOD &&
                action->port != OFPP_IN_PORT && action->port != OFPP_CONTROLLER ) {
        ret = ERROR_OFDPE_BAD_ACTION_BAD_OUT_PORT;
        break;
      }
    }
  }

  return ret;
}