static int ippctl_action_destroy( char *aname, ipp_flags_t flags) { ipp_action_id_t aid; int ipp_rc; int rc; /* * Look up the action id and destroy the action. */ aid = ipp_action_lookup(aname); FREE_TEXT(aname); ipp_rc = ipp_action_destroy(aid, flags); /* * Add an nvlist containing the kernel return code to the * set of nvlists to pass back to libipp. */ if ((rc = ippctl_set_rc(ipp_rc)) != 0) return (rc); /* * There's no more information to pass back. */ return (0); }
static int ippctl_action_mod( char *aname) { ipp_mod_id_t mid; ipp_action_id_t aid; char *modname; nvlist_t *nvlp; int ipp_rc; int rc; /* * Look up the action id and get the id of the module that * implements the action. If that succeeds then look up the * name of the module. */ aid = ipp_action_lookup(aname); FREE_TEXT(aname); if ((ipp_rc = ipp_action_mod(aid, &mid)) == 0) ipp_rc = ipp_mod_name(mid, &modname); /* * Add an nvlist containing the kernel return code to the * set of nvlists to pass back to libipp. */ if ((rc = ippctl_set_rc(ipp_rc)) != 0) return (rc); /* * If everything succeeded add an nvlist containing the * module name to the set of nvlists to pass back to libipp. */ if (ipp_rc == 0) { if ((rc = nvlist_alloc(&nvlp, NV_UNIQUE_NAME, KM_SLEEP)) != 0) return (rc); if ((rc = ippctl_attach_modname(nvlp, modname)) != 0) { nvlist_free(nvlp); return (rc); } FREE_TEXT(modname); rc = ippctl_callback(nvlp, NULL); nvlist_free(nvlp); } else rc = 0; return (rc); }
static int ippctl_action_create( char *modname, char *aname, nvlist_t *nvlp, ipp_flags_t flags) { int ipp_rc; int rc; ipp_mod_id_t mid; ipp_action_id_t aid; /* * Look up the module id from the name and create the new * action. */ mid = ipp_mod_lookup(modname); FREE_TEXT(modname); ipp_rc = ipp_action_create(mid, aname, &nvlp, flags, &aid); FREE_TEXT(aname); /* * Add an nvlist containing the kernel return code to the * set of nvlists to pass back to libipp. */ if ((rc = ippctl_set_rc(ipp_rc)) != 0) { if (nvlp != NULL) { nvlist_free(nvlp); if (ipp_action_destroy(aid, 0) != 0) { cmn_err(CE_PANIC, "ippctl: unrecoverable error (aid = %d)", aid); /*NOTREACHED*/ } } return (rc); } /* * If the module passed back an nvlist, add this as * well. */ if (nvlp != NULL) { rc = ippctl_callback(nvlp, NULL); nvlist_free(nvlp); } else rc = 0; return (rc); }
static int ippctl_action_modify( char *aname, nvlist_t *nvlp, ipp_flags_t flags) { ipp_action_id_t aid; int ipp_rc; int rc; /* * Look up the action id and modify the action. */ aid = ipp_action_lookup(aname); FREE_TEXT(aname); ipp_rc = ipp_action_modify(aid, &nvlp, flags); /* * Add an nvlist containing the kernel return code to the * set of nvlists to pass back to libipp. */ if ((rc = ippctl_set_rc(ipp_rc)) != 0) { if (nvlp != NULL) nvlist_free(nvlp); return (rc); } /* * If the module passed back an nvlist, add this as * well. */ if (nvlp != NULL) { rc = ippctl_callback(nvlp, NULL); nvlist_free(nvlp); } else rc = 0; return (rc); }
static int ippctl_action_info( char *aname, ipp_flags_t flags) { ipp_action_id_t aid; int ipp_rc; int rc; /* * Look up the action and call the information retrieval * entry point. * * NOTE: The callback function that is passed in packs and * stores each of the nvlists it is called with in the array * that will be passed back to libipp. */ aid = ipp_action_lookup(aname); FREE_TEXT(aname); ipp_rc = ipp_action_info(aid, ippctl_callback, NULL, flags); /* * Add an nvlist containing the kernel return code to the * set of nvlists to pass back to libipp. */ if ((rc = ippctl_set_rc(ipp_rc)) != 0) return (rc); /* * There's no more information to pass back. */ return (0); }
static int ippctl_mod_list_actions( char *modname) { ipp_mod_id_t mid; nvlist_t *nvlp; int ipp_rc; int rc = 0; ipp_action_id_t *aid_array; char **aname_array = NULL; int nelt; int length; int i; /* * Get the module id. */ mid = ipp_mod_lookup(modname); FREE_TEXT(modname); /* * Get a list of all the action ids for the module. If that succeeds, * translate the ids into names. * * NOTE: This translation may fail if an action is * destroyed during this operation. If this occurs, EAGAIN * will be passed back to libipp note that a transient * problem occured. */ if ((ipp_rc = ipp_mod_list_actions(mid, &aid_array, &nelt)) == 0) { /* * It is possible that there are no actions defined. * (This is unlikely though as the module would normally * be auto-unloaded fairly quickly) */ if (nelt > 0) { length = nelt * sizeof (char *); aname_array = kmem_zalloc(length, KM_SLEEP); for (i = 0; i < nelt; i++) { if (ipp_action_name(aid_array[i], &aname_array[i]) != 0) { kmem_free(aid_array, nelt * sizeof (ipp_action_id_t)); FREE_TEXT_ARRAY(aname_array, nelt); ipp_rc = EAGAIN; goto done; } } kmem_free(aid_array, nelt * sizeof (ipp_action_id_t)); if ((rc = nvlist_alloc(&nvlp, NV_UNIQUE_NAME, KM_SLEEP)) != 0) { FREE_TEXT_ARRAY(aname_array, nelt); return (rc); } if ((rc = ippctl_attach_aname_array(nvlp, aname_array, nelt)) != 0) { FREE_TEXT_ARRAY(aname_array, nelt); nvlist_free(nvlp); return (rc); } FREE_TEXT_ARRAY(aname_array, nelt); if ((rc = ippctl_callback(nvlp, NULL)) != 0) { nvlist_free(nvlp); return (rc); } nvlist_free(nvlp); } } done: /* * Add an nvlist containing the kernel return code to the * set of nvlists to pass back to libipp. */ if ((rc = ippctl_set_rc(ipp_rc)) != 0) return (rc); return (0); }
static int ippctl_list_mods( void) { nvlist_t *nvlp; int ipp_rc; int rc = 0; ipp_mod_id_t *mid_array; char **modname_array = NULL; int nelt; int length; int i; /* * Get a list of all the module ids. If that succeeds, * translate the ids into names. * * NOTE: This translation may fail if a module is * unloaded during this operation. If this occurs, EAGAIN * will be passed back to libipp note that a transient * problem occured. */ if ((ipp_rc = ipp_list_mods(&mid_array, &nelt)) == 0) { /* * It is possible that there are no modules * registered. */ if (nelt > 0) { length = nelt * sizeof (char *); modname_array = kmem_zalloc(length, KM_SLEEP); for (i = 0; i < nelt; i++) { if (ipp_mod_name(mid_array[i], &modname_array[i]) != 0) { kmem_free(mid_array, nelt * sizeof (ipp_mod_id_t)); FREE_TEXT_ARRAY(modname_array, nelt); ipp_rc = EAGAIN; goto done; } } kmem_free(mid_array, nelt * sizeof (ipp_mod_id_t)); if ((rc = nvlist_alloc(&nvlp, NV_UNIQUE_NAME, KM_SLEEP)) != 0) { FREE_TEXT_ARRAY(modname_array, nelt); return (rc); } if ((rc = ippctl_attach_modname_array(nvlp, modname_array, nelt)) != 0) { FREE_TEXT_ARRAY(modname_array, nelt); nvlist_free(nvlp); return (rc); } FREE_TEXT_ARRAY(modname_array, nelt); if ((rc = ippctl_callback(nvlp, NULL)) != 0) { nvlist_free(nvlp); return (rc); } nvlist_free(nvlp); } } done: /* * Add an nvlist containing the kernel return code to the * set of nvlists to pass back to libipp. */ if ((rc = ippctl_set_rc(ipp_rc)) != 0) return (rc); return (0); }