/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
*/
/* $Id: ipp-listener.c 146 2006-03-24 00:26:54Z njacobs $ */
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
#include <syslog.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/systeminfo.h>
#include <papi.h>
#include <ipp-listener.h>
#include <uri.h>
/*
* protocol request handlers are inserted below. The handler must be
* declared extern immediately below this comment and then an entry
* must be inserted in the "handlers" table a little further down.
*/
extern ipp_handler_t ipp_print_job;
extern ipp_handler_t ipp_validate_job;
extern ipp_handler_t ipp_create_job;
extern ipp_handler_t ipp_get_jobs;
extern ipp_handler_t ipp_pause_printer;
extern ipp_handler_t ipp_resume_printer;
extern ipp_handler_t ipp_disable_printer;
extern ipp_handler_t ipp_enable_printer;
extern ipp_handler_t ipp_purge_jobs;
extern ipp_handler_t ipp_send_document;
extern ipp_handler_t ipp_cancel_job;
extern ipp_handler_t ipp_get_job_attributes;
extern ipp_handler_t ipp_release_job;
extern ipp_handler_t ipp_hold_job;
extern ipp_handler_t ipp_restart_job;
extern ipp_handler_t ipp_set_job_attributes;
extern ipp_handler_t cups_get_default;
extern ipp_handler_t cups_get_printers;
extern ipp_handler_t cups_get_classes;
extern ipp_handler_t cups_accept_jobs;
extern ipp_handler_t cups_reject_jobs;
extern ipp_handler_t cups_move_job;
/* ARGSUSED0 */
static papi_status_t
{
"status-code", &result);
return ((papi_status_t)result);
}
static struct {
char *name;
} handlers[] = {
/* Printer Operations */
OP_REQUIRED },
OP_REQUIRED },
OP_OPTIONAL },
OP_OPTIONAL },
OP_OPTIONAL },
OP_OPTIONAL },
OP_OPTIONAL },
OP_OPTIONAL },
/* Job Operations */
OP_OPTIONAL },
OP_REQUIRED },
OP_OPTIONAL },
OP_OPTIONAL },
/* Other Operations */
OP_VENDOR },
OP_VENDOR },
OP_VENDOR },
OP_VENDOR },
OP_VENDOR },
};
static int
{
int i;
return (i);
return (-1);
}
static int
{
int i;
return (i);
return (-1);
}
static ipp_handler_t *
{
int id = 0;
int index;
/* get the operation from the request */
"operation-id", &id);
"no operation specified in request");
return (default_handler);
}
/* find the operation in the handler table */
#ifdef DEBUG
if (index == -1)
else
#endif
"operation (0x%4.4x) not implemented by server",
id);
return (default_handler);
}
/* find the configured operations */
"operations", &ops);
"sofware error, no operations configured");
return (default_handler);
}
/* check if the requested operation is configured */
"operation (%s 0x%4.4x) not enabled on server",
return (default_handler);
}
}
static char
{
return (result);
}
static papi_status_t
{
int i;
boolean);
return (result);
}
static papi_status_t
{
int i;
return (result);
}
{
return (PAPI_BAD_ARGUMENT);
}
return (result);
}
void
{
"operations", &group);
int i;
(void) papiAttributeListAddInteger(list,
"operations-supported",
}
}
}
static papi_status_t
{
int i;
return (PAPI_BAD_ARGUMENT);
/* If the response was initialized, start over */
}
/* Add the basic ipp header information to the response */
"version-major", i);
"version-minor", i);
"request-id", i);
/* Add a default operational attributes group to the response */
"attributes-charset", "utf-8");
"attributes-natural-language", "en-us");
"operational-attributes-group", operational);
return (PAPI_OK);
}
/* simplistic check for cyclical service references */
static int
{
char *s = NULL;
/* was there a service_uri? */
return (0);
return (0); /* if it doesnt' resolve, we will fail later */
return (0); /* they don't match */
/* is it in uri form? */
if (uri_from_string(s, &uri) < 0)
return (0);
return (0);
}
/* is it ipp form */
return (0);
}
/* does the host match up */
return (0);
}
/* does the port match our own */
return (0);
}
return (1);
}
static papi_status_t
{
/* Get the operational attributes group from the request */
"operational-attributes-group", &operational);
/* get the user name */
"requesting-user-name", &user);
/* get the printer or service name */
"default-service", &svc_name);
/* get the port that we are listening on */
return (status);
}
return (status);
}
/*
* Trusted Solaris can't be trusting of intermediaries. Pass
* the socket connection to the print service to retrieve the
* sensativity label off of a multi-level port.
*/
{
"peer-socket", &fd);
if (fd != -1)
}
return (status);
}
{
#ifdef DEBUG
#endif
/* verify that the request is "well-formed" */
/* process the request */
#ifdef DEBUG
#endif
}
"status-code", result);
#ifdef DEBUG
#endif
return (result);
}