No code seems to use it anymore.
Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
lib/rpcIn/Makefile \
lib/rpcOut/Makefile \
lib/rpcVmx/Makefile \
- lib/SLPv2Parser/Makefile \
lib/slashProc/Makefile \
lib/string/Makefile \
lib/stubs/Makefile \
if USE_SLASH_PROC
SUBDIRS += slashProc
endif
-SUBDIRS += SLPv2Parser
SUBDIRS += string
SUBDIRS += stubs
SUBDIRS += syncDriver
+++ /dev/null
-################################################################################
-### Copyright 2007 VMware, Inc. All rights reserved.
-###
-### This program is free software; you can redistribute it and/or modify
-### it under the terms of version 2 of the GNU General Public License as
-### published by the Free Software Foundation.
-###
-### This program is distributed in the hope that it will be useful,
-### but WITHOUT ANY WARRANTY; without even the implied warranty of
-### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-### GNU General Public License for more details.
-###
-### You should have received a copy of the GNU General Public License
-### along with this program; if not, write to the Free Software
-### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-################################################################################
-
-noinst_LTLIBRARIES = libSLPv2Parser.la
-
-libSLPv2Parser_la_SOURCES =
-libSLPv2Parser_la_SOURCES += SLPv2MsgParser.c
-libSLPv2Parser_la_SOURCES += SLPv2Match.c
-libSLPv2Parser_la_SOURCES += SLPv2MsgAssembler.c
+++ /dev/null
-/*********************************************************
- * Copyright (C) 2005 VMware, Inc. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation version 2.1 and no later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- *********************************************************/
-
-#include <string.h>
-#include <stdlib.h>
-#ifdef WIN32
-#include <Winsock2.h>
-#else
-#include <sys/types.h>
-#include <netinet/in.h>
-#endif
-
-#include "vmware.h"
-#include "util.h"
-#include "str.h"
-#include "SLPv2.h"
-#include "SLPv2Private.h"
-
-
-/*
- *-----------------------------------------------------------------------------
- *
- * SLPv2MsgParserMatchStringInList -
- *
- * Returns TRUE if attribute is contained in list, where list
- * is a comma separated list of attributes.
- *
- * Results:
- * Returns TRUE upon match.
- *
- * Side effects:
- * None
- *
- *-----------------------------------------------------------------------------
- */
-
-Bool
-SLPv2MsgParserMatchStringInList(char *list, // IN
- char *attribute) // IN
-{
- char *start;
- char *end;
- size_t length;
-
- /*
- * If there is no attribute to match against, it's a match.
- */
- if (NULL == list || NULL == attribute || 0 == strlen(attribute)) {
- return TRUE;
- }
-
- /*
- * Look at every attribute in the list that is followed by a comma.
- */
- start = list;
- end = Str_Strchr(start, ',');
- length = (NULL != end) ? (end - start) : strlen(start);
-
- while (end != NULL) {
- if (0 == Str_Strncasecmp(start, attribute, length)) {
- return TRUE;
- }
-
- start = end + 1;
- end = Str_Strchr(start, ',');
- length = (NULL != end) ? (end - start) : strlen(start);
- }
-
- /*
- * At this point we're at the last item in list.
- */
- if (0 == Str_Strncasecmp(start, attribute, length)) {
- return TRUE;
- }
-
- return FALSE;
-}
-
-
-/*
- *-----------------------------------------------------------------------------
- *
- * SLPv2MsgParser_ServiceRequestMatch -
- *
- * Returns TRUE if the packet matches the SLPv2 request parameters
- * passed to this function.
- *
- * Results:
- * Returns TRUE upon match.
- *
- * Side effects:
- * None
- *
- *-----------------------------------------------------------------------------
- */
-
-Bool
-SLPv2MsgParser_ServiceRequestMatch(struct SLPv2_Parse *parse, // IN
- char *myIpsList, // UN
- char *myServiceType, // IN
- char *myScope, // IN
- char *myPredicate, // IN
- uint16 *xid) // OUT
-{
- ASSERT(NULL != parse);
-
- if (SLPV2_SERVICEREQUEST != parse->header->functionId) {
- return FALSE;
- }
-
- /*
- * TODO: ip address matching.
- */
-
- if (! SLPv2MsgParserMatchStringInList(parse->serviceRequest.serviceType,
- myServiceType)) {
- return FALSE;
- }
-
- if (! SLPv2MsgParserMatchStringInList(parse->serviceRequest.scope,
- myScope)) {
- return FALSE;
- }
-
- // TODO: implement LDAPv3 predicate match
-
- if (NULL != xid) {
- *xid = Portable_ntohs(parse->header->xid);
- }
-
- return TRUE;
-}
-
-
-/*
- *-----------------------------------------------------------------------------
- *
- * SLPv2MsgParser_ServiceReplyMatch -
- *
- * Returns TRUE if the packet matches the SLPv2 parameters
- * passed to this function.
- *
- * Results:
- * Returns TRUE upon match.
- *
- * Side effects:
- * None
- *
- *-----------------------------------------------------------------------------
- */
-
-Bool
-SLPv2MsgParser_ServiceReplyMatch(struct SLPv2_Parse *parse, // IN
- int *urlCount, // OUT
- char ***urlArray, // OUT
- uint16 *xid) // OUT
-{
- ASSERT(NULL != parse);
-
- if (SLPV2_SERVICEREPLY != parse->header->functionId) {
- return FALSE;
- }
-
- if (NULL != urlCount) {
- *urlCount = parse->serviceReply.urlCount;
- }
-
- if (NULL != urlArray) {
- int i;
- *urlArray = Util_SafeMalloc(sizeof(char *)*parse->serviceReply.urlCount);
-
- for (i = 0; i < parse->serviceReply.urlCount; i++) {
- *urlArray[i] = Util_SafeStrdup(parse->serviceReply.url[i]);
- }
- }
-
- if (NULL != xid) {
- *xid = Portable_ntohs(parse->header->xid);
- }
-
- return TRUE;
-}
-
-
-/*
- *-----------------------------------------------------------------------------
- *
- * SLPv2MsgParser_AttributeRequestMatch -
- *
- * Returns TRUE if the packet matches the SLPv2 request parameters
- * passed to this function.
- *
- * Results:
- * Returns TRUE upon match.
- *
- * Side effects:
- * None
- *
- *-----------------------------------------------------------------------------
- */
-
-Bool
-SLPv2MsgParser_AttributeRequestMatch(struct SLPv2_Parse *parse, // IN
- char *myIpsList, // UN
- char *url, // IN
- char *myScope, // IN
- char *tagList, // IN
- uint16 *xid) // OUT
-{
- ASSERT(NULL != parse);
-
- if (SLPV2_ATTRIBUTEREQUEST != parse->header->functionId) {
- return FALSE;
- }
-
- /*
- * TODO: ip address matching.
- */
-
- if ((url != NULL) && (0 != strcmp(url, parse->attributeRequest.url))) {
- return FALSE;
- }
-
- if (! SLPv2MsgParserMatchStringInList(parse->serviceRequest.scope,
- myScope)) {
- return FALSE;
- }
-
- /*
- * TODO: tag list and LDAPv3 predicate matching.
- */
-
- if (NULL != xid) {
- *xid = Portable_ntohs(parse->header->xid);
- }
-
- return TRUE;
-}
-
-
-
-/*
- *-----------------------------------------------------------------------------
- *
- * SLPv2MsgParser_AttributeReplyMatch -
- *
- * Returns TRUE if the packet matches the SLPv2 parameters
- * passed to this function.
- *
- * Results:
- * Returns TRUE upon match.
- *
- * Side effects:
- * None
- *
- *-----------------------------------------------------------------------------
- */
-
-Bool
-SLPv2MsgParser_AttributeReplyMatch(struct SLPv2_Parse *parse, // IN
- char **attributeList, // OUT
- uint16 *xid) // OUT
-{
- ASSERT(NULL != parse);
-
- if (SLPV2_ATTRIBUTEREPLY != parse->header->functionId) {
- return FALSE;
- }
-
- if (attributeList != NULL) {
- *attributeList = Util_SafeStrdup(parse->attributeReply.attributeList);
- }
-
- if (NULL != xid) {
- *xid = Portable_ntohs(parse->header->xid);
- }
-
- return TRUE;
-}
-
-
+++ /dev/null
-/*********************************************************
- * Copyright (C) 2005 VMware, Inc. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation version 2.1 and no later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- *********************************************************/
-
-#include "vmware.h"
-#include "dynbuf.h"
-#include "SLPv2.h"
-#include "SLPv2Private.h"
-#ifdef WIN32
-#include <Winsock.h>
-#else
-#include <sys/types.h>
-#include <netinet/in.h>
-#endif
-#include <string.h>
-
-/*
- *-----------------------------------------------------------------------------
- *
- * SLPv2MsgAssemblerHeader --
- *
- * Appends an SLPv2 header to a DynBuf.
- *
- * Results:
- * Returns TRUE upon success, FALSE upon memory error.
- *
- * Side effects:
- * None
- *
- *-----------------------------------------------------------------------------
- */
-
-Bool
-SLPv2MsgAssemblerHeader(DynBuf *b, // IN
- uint8 functionId, // IN
- uint32 length, // IN
- Bool overflowFlag, // IN
- Bool freshFlag, // IN
- Bool requestMulticastFlag, // IN
- uint16 xid) // IN
-{
- struct SLPv2_Header header;
- uint8 *lengthArray = (uint8 *) &length;
-
- length = Portable_htonl(length);
-
- header.version = SLPV2_VERSION;
- header.functionId = functionId;
- header.length[0] = lengthArray[0];
- header.length[1] = lengthArray[1];
- header.length[2] = lengthArray[2];
- header.flags = Portable_htons((overflowFlag << 15)
- | (freshFlag << 14)
- | (requestMulticastFlag << 13)); // flags
- header.extOffset[0] = 0; // next extension offset
- header.extOffset[1] = 0;
- header.extOffset[2] = 0;
- header.xid = Portable_htons(xid);
-
- return DynBuf_Append(b, &header, sizeof header);
-}
-
-/*
- *-----------------------------------------------------------------------------
- *
- * SLPv2MsgAssemblerUrl --
- *
- * Appends an SLPv2 URL Entry to a DynBuf.
- *
- * Results:
- * Returns TRUE upon success, FALSE upon memory error.
- *
- * Side effects:
- * None
- *
- *-----------------------------------------------------------------------------
- */
-
-Bool
-SLPv2MsgAssemblerUrl(DynBuf *b, // IN
- uint16 lifetime, // IN
- char *url) // IN
-{
- static uint8 numberUrlAuths = 0;
- struct SLPv2_URL urlEntry;
-
- ASSERT(url);
-
- urlEntry.reserved = 0;
- urlEntry.lifetime = Portable_htons(lifetime);
- urlEntry.length = Portable_htons(strlen(url));
-
- if (! DynBuf_Append(b, &urlEntry, sizeof urlEntry)) {
- goto abort;
- }
- if (! DynBuf_Append(b, &url, strlen(url))) {
- goto abort;
- }
- if (! DynBuf_Append(b, &numberUrlAuths, sizeof numberUrlAuths)) {
- goto abort;
- }
- return TRUE;
-
-abort:
- return FALSE;
-}
-
-/*
- *-----------------------------------------------------------------------------
- *
- * SLPv2MsgAssembler_ServiceRequest --
- *
- * Appends an SLPv2 Service Request to a DynBuf.
- *
- * Results:
- * Returns TRUE upon success, FALSE upon memory error.
- *
- * Side effects:
- * None
- *
- *-----------------------------------------------------------------------------
- */
-
-Bool
-SLPv2MsgAssembler_ServiceRequest(char **packet, // OUT
- int *packetSize, // OUT
- uint16 xid, // IN
- Bool overflowFlag, // IN
- Bool freshFlag, // IN
- Bool requestMulticastFlag, // IN
- char *languageTag, // IN
- char *prList, // IN
- char *serviceType, // IN
- char *scopeList, // IN
- char *predicate, // IN
- char *spi) // IN
-{
- int len;
- static char *empty = "";
- uint16 languageTagLen;
- uint16 languageTagLenBE; /* big endian */
- uint16 prListLen;
- uint16 prListLenBE;
- uint16 serviceTypeLen;
- uint16 serviceTypeLenBE;
- uint16 scopeListLen;
- uint16 scopeListLenBE;
- uint16 predicateLen;
- uint16 predicateLenBE;
- uint16 spiLen;
- uint16 spiLenBE;
- DynBuf b;
-
- DynBuf_Init(&b);
- ASSERT(NULL != packet && NULL != packetSize);
-
- languageTag = (NULL == languageTag) ? empty : languageTag;
- prList = (NULL == prList) ? empty : prList;
- serviceType = (NULL == serviceType) ? empty : serviceType;
- scopeList = (NULL == scopeList) ? empty : scopeList;
- predicate = (NULL == predicate) ? empty : predicate;
- spi = (NULL == spi) ? empty : spi;
-
- if (strlen(languageTag) > 65535 || strlen(prList) > 65535
- || strlen(serviceType) > 65535 || strlen(scopeList) > 65535
- || strlen(predicate) > 65535 || strlen(spi) > 65535) {
- return FALSE;
- }
-
- languageTagLen = strlen(languageTag);
- languageTagLenBE = Portable_htons(languageTagLen);
- prListLen = strlen(prList);
- prListLenBE = Portable_htons(prListLen);
- serviceTypeLen = strlen(serviceType);
- serviceTypeLenBE = Portable_htons(serviceTypeLen);
- scopeListLen = strlen(scopeList);
- scopeListLenBE = Portable_htons(scopeListLen);
- predicateLen = strlen(predicate);
- predicateLenBE = Portable_htons(predicateLen);
- spiLen = strlen(spi);
- spiLenBE = Portable_htons(spiLen);
-
- len = sizeof (struct SLPv2_Header)
- + sizeof languageTagLen + languageTagLen
- + sizeof prListLen + prListLen
- + sizeof serviceTypeLen + serviceTypeLen
- + sizeof scopeListLen + scopeListLen
- + sizeof predicateLen + predicateLen
- + sizeof spiLen + spiLen;
-
- if (! SLPv2MsgAssemblerHeader(&b, SLPV2_SERVICEREQUEST, len,
- overflowFlag, freshFlag,
- requestMulticastFlag, xid)) {
- goto abort;
- }
- if (! DynBuf_Append(&b, &languageTagLenBE, sizeof languageTagLenBE)) {
- goto abort;
- }
- if (! DynBuf_Append(&b, languageTag, languageTagLen)) {
- goto abort;
- }
- if (! DynBuf_Append(&b, &prListLenBE, sizeof prListLenBE)) {
- goto abort;
- }
- if (! DynBuf_Append(&b, prList, prListLen)) {
- goto abort;
- }
- if (! DynBuf_Append(&b, &serviceTypeLenBE, sizeof serviceTypeLenBE)) {
- goto abort;
- }
- if (! DynBuf_Append(&b, serviceType, serviceTypeLen)) {
- goto abort;
- }
- if (! DynBuf_Append(&b, &scopeListLenBE, sizeof scopeListLenBE)) {
- goto abort;
- }
- if (! DynBuf_Append(&b, scopeList, scopeListLen)) {
- goto abort;
- }
- if (! DynBuf_Append(&b, &predicateLenBE, sizeof predicateLenBE)) {
- goto abort;
- }
- if (! DynBuf_Append(&b, predicate, predicateLen)) {
- goto abort;
- }
- if (! DynBuf_Append(&b, &spiLenBE, sizeof spiLenBE)) {
- goto abort;
- }
- if (! DynBuf_Append(&b, spi, spiLen)) {
- goto abort;
- }
-
- ASSERT(DynBuf_GetSize(&b) == len);
- DynBuf_Trim(&b);
- if (NULL != packetSize) {
- *packetSize = DynBuf_GetSize(&b);
- }
- if (NULL != packet) {
- *packet = DynBuf_Detach(&b);
- }
- DynBuf_Destroy(&b);
- return TRUE;
-
-abort:
- DynBuf_Destroy(&b);
- return FALSE;
-}
-
-/*
- *-----------------------------------------------------------------------------
- *
- * SLPv2MsgAssembler_ServiceReply --
- *
- * Appends an SLPv2 Service Reply to a DynBuf.
- *
- * Results:
- * Returns TRUE upon success, FALSE upon memory error.
- *
- * Side effects:
- * None
- *
- *-----------------------------------------------------------------------------
- */
-
-Bool
-SLPv2MsgAssembler_ServiceReply(char **packet, // OUT
- int *packetSize, // OUT
- uint16 xid, // IN
- char *languageTag, // IN
- uint16 errorCode, // IN
- uint16 urlEntryCount, // IN
- char **urls) // IN
-{
- int len;
- int urlTotalLength = 0;
- int i;
- static char *empty = "";
- uint16 languageTagLen;
- uint16 urlStringLength;
- DynBuf b;
-
- DynBuf_Init(&b);
- ASSERT(NULL != packet && NULL != packetSize);
-
- languageTag = (NULL == languageTag) ? empty : languageTag;
-
- if (strlen(languageTag) > 65535) {
- return FALSE;
- }
-
- languageTagLen = strlen(languageTag);
-
- /*
- * Compute the total length of all strings pointed to by "urls".
- */
- if (NULL != urls) {
- urlTotalLength = urlEntryCount * 2;
- for (i = 0; i < urlEntryCount; i++) {
- ASSERT(NULL != urls[i]);
- urlTotalLength += strlen(urls[i]);
- }
- } else {
- /*
- * If urls==NULL, then urlEntryCount better be zero!
- */
- ASSERT(0 == urlEntryCount);
- }
-
- len = sizeof (struct SLPv2_Header) + sizeof languageTagLen + languageTagLen
- + sizeof errorCode + sizeof urlEntryCount + urlTotalLength;
-
- languageTagLen = Portable_htons(languageTagLen);
- errorCode = Portable_htons(errorCode);
- urlEntryCount = Portable_htons(urlEntryCount);
-
- if (! SLPv2MsgAssemblerHeader(&b, SLPV2_SERVICEREPLY, len,
- FALSE, FALSE, FALSE, xid)) {
- goto abort;
- }
- if (! DynBuf_Append(&b, &languageTagLen, sizeof languageTagLen)) {
- goto abort;
- }
- if (! DynBuf_Append(&b, languageTag, Portable_ntohs(languageTagLen))) {
- goto abort;
- }
- if (! DynBuf_Append(&b, &errorCode, sizeof errorCode)) {
- goto abort;
- }
- if (! DynBuf_Append(&b, &urlEntryCount, sizeof urlEntryCount)) {
- goto abort;
- }
-
- /*
- * Append URLs.
- */
- urlEntryCount = Portable_ntohs(urlEntryCount);
- for (i = 0 ; i < urlEntryCount ; i++) {
- urlStringLength = Portable_htons(strlen(urls[i]));
- if (! DynBuf_Append(&b, &urlStringLength, sizeof urlStringLength)) {
- goto abort;
- }
- if (! DynBuf_Append(&b, urls[i], Portable_ntohs(urlStringLength))) {
- goto abort;
- }
- }
-
-
- ASSERT(DynBuf_GetSize(&b) == len);
- DynBuf_Trim(&b);
- if (NULL != packetSize) {
- *packetSize = DynBuf_GetSize(&b);
- }
- if (NULL != packet) {
- *packet = DynBuf_Detach(&b);
- }
- DynBuf_Destroy(&b);
- return TRUE;
-
-abort:
- DynBuf_Destroy(&b);
- return FALSE;
-
-}
-
-
-/*
- *-----------------------------------------------------------------------------
- *
- * SLPv2MsgAssembler_AttributeRequest --
- *
- * Appends an SLPv2 Attribute Request to a DynBuf.
- *
- * Results:
- * Returns TRUE upon success, FALSE upon memory error.
- *
- * Side effects:
- * None
- *
- *-----------------------------------------------------------------------------
- */
-
-Bool
-SLPv2MsgAssembler_AttributeRequest(char **packet, // OUT
- int *packetSize, // OUT
- uint16 xid, // IN
- Bool overflowFlag, // IN
- Bool freshFlag, // IN
- Bool requestMulticastFlag, // IN
- char *languageTag, // IN
- char *prList, // IN
- char *url, // IN
- char *scopeList, // IN
- char *tagList, // IN
- char *spi) // IN
-{
- int len;
- static char *empty = "";
- uint16 languageTagLen;
- uint16 prListLen;
- uint16 urlLen;
- uint16 scopeListLen;
- uint16 tagListLen;
- uint16 spiLen;
- uint16 languageTagLenBE; /* big endian */
- uint16 prListLenBE;
- uint16 urlLenBE;
- uint16 scopeListLenBE;
- uint16 tagListLenBE;
- uint16 spiLenBE;
- DynBuf b;
-
-
- DynBuf_Init(&b);
- ASSERT(NULL != packet && NULL != packetSize);
-
- languageTag = (NULL == languageTag) ? empty : languageTag;
- prList = (NULL == prList) ? empty : prList;
- url = (NULL == url) ? empty : url;
- scopeList = (NULL == scopeList) ? empty : scopeList;
- tagList = (NULL == tagList) ? empty : tagList;
- spi = (NULL == spi) ? empty : spi;
-
- if (strlen(languageTag) > 65535 || strlen(prList) > 65535
- || strlen(url) > 65535 || strlen(scopeList) > 65535
- || strlen(tagList) > 65535 || strlen(spi) > 65535) {
- return FALSE;
- }
-
- languageTagLen = strlen(languageTag);
- languageTagLenBE = Portable_htons(languageTagLen);
- prListLen = strlen(prList);
- prListLenBE = Portable_htons(prListLen);
- urlLen = strlen(url);
- urlLenBE = Portable_htons(urlLen);
- scopeListLen = strlen(scopeList);
- scopeListLenBE = Portable_htons(scopeListLen);
- tagListLen = strlen(tagList);
- tagListLenBE = Portable_htons(tagListLen);
- spiLen = strlen(spi);
- spiLenBE = Portable_htons(spiLen);
-
- len = sizeof (struct SLPv2_Header)
- + sizeof languageTagLen + languageTagLen
- + sizeof prListLen + prListLen
- + sizeof urlLen + urlLen
- + sizeof scopeListLen + scopeListLen
- + sizeof tagListLen + tagListLen
- + sizeof spiLen + spiLen;
-
- if (! SLPv2MsgAssemblerHeader(&b, SLPV2_ATTRIBUTEREQUEST, len,
- overflowFlag, freshFlag,
- requestMulticastFlag, xid)) {
- goto abort;
- }
- if (! DynBuf_Append(&b, &languageTagLenBE, sizeof languageTagLenBE)) {
- goto abort;
- }
- if (! DynBuf_Append(&b, languageTag, languageTagLen)) {
- goto abort;
- }
- if (! DynBuf_Append(&b, &prListLenBE, sizeof prListLenBE)) {
- goto abort;
- }
- if (! DynBuf_Append(&b, prList, prListLen)) {
- goto abort;
- }
- if (! DynBuf_Append(&b, &urlLenBE, sizeof urlLenBE)) {
- goto abort;
- }
- if (! DynBuf_Append(&b, url, urlLen)) {
- goto abort;
- }
- if (! DynBuf_Append(&b, &scopeListLenBE, sizeof scopeListLenBE)) {
- goto abort;
- }
- if (! DynBuf_Append(&b, scopeList, scopeListLen)) {
- goto abort;
- }
- if (! DynBuf_Append(&b, &tagListLenBE, sizeof tagListLenBE)) {
- goto abort;
- }
- if (! DynBuf_Append(&b, tagList, tagListLen)) {
- goto abort;
- }
- if (! DynBuf_Append(&b, &spiLenBE, sizeof spiLenBE)) {
- goto abort;
- }
- if (! DynBuf_Append(&b, spi, spiLen)) {
- goto abort;
- }
-
- ASSERT(DynBuf_GetSize(&b) == len);
- DynBuf_Trim(&b);
- if (NULL != packetSize) {
- *packetSize = DynBuf_GetSize(&b);
- }
- if (NULL != packet) {
- *packet = DynBuf_Detach(&b);
- }
- DynBuf_Destroy(&b);
- return TRUE;
-
-abort:
- DynBuf_Destroy(&b);
- return FALSE;
-}
-
-/*
- *-----------------------------------------------------------------------------
- *
- * SLPv2MsgAssembler_AttributeReply --
- *
- * Appends an SLPv2 Attribute Reply to a DynBuf.
- *
- * Results:
- * Returns TRUE upon success, FALSE upon memory error.
- *
- * Side effects:
- * None
- *
- *-----------------------------------------------------------------------------
- */
-
-Bool
-SLPv2MsgAssembler_AttributeReply(char **packet, // OUT
- int *packetSize, // OUT
- uint16 xid, // IN
- char *languageTag, // IN
- uint16 errorCode, // IN
- char *attributeList) // IN
-{
- int len;
- static char *empty = "";
- uint16 languageTagLen;
- uint16 languageTagLenBE; /* big endian */
- uint16 attributeListLen;
- uint16 attributeListLenBE;
- uint16 errorCodeBE;
- DynBuf b;
-
- DynBuf_Init(&b);
- ASSERT(NULL != packet && NULL != packetSize);
-
- languageTag = (NULL == languageTag) ? empty : languageTag;
- attributeList = (NULL == attributeList) ? empty : attributeList;
-
- if (strlen(languageTag) > 65535 || strlen(attributeList) > 65535) {
- return FALSE;
- }
-
- errorCodeBE = Portable_htons(errorCode);
- languageTagLen = strlen(languageTag);
- languageTagLenBE = Portable_htons(languageTagLen);
- attributeListLen = strlen(attributeList);
- attributeListLenBE = Portable_htons(attributeListLen);
-
- len = sizeof (struct SLPv2_Header)
- + sizeof languageTagLen + languageTagLen
- + sizeof errorCode
- + sizeof attributeListLen + attributeListLen;
-
- if (! SLPv2MsgAssemblerHeader(&b, SLPV2_ATTRIBUTEREPLY, len,
- FALSE, FALSE, FALSE, xid)) {
- goto abort;
- }
- if (! DynBuf_Append(&b, &languageTagLenBE, sizeof languageTagLenBE)) {
- goto abort;
- }
- if (! DynBuf_Append(&b, languageTag, languageTagLen)) {
- goto abort;
- }
- if (! DynBuf_Append(&b, &errorCodeBE, sizeof errorCodeBE)) {
- goto abort;
- }
- if (! DynBuf_Append(&b, &attributeListLenBE, sizeof attributeListLenBE)) {
- goto abort;
- }
- if (! DynBuf_Append(&b, attributeList, attributeListLen)) {
- goto abort;
- }
-
- ASSERT(DynBuf_GetSize(&b) == len);
- DynBuf_Trim(&b);
- if (NULL != packetSize) {
- *packetSize = DynBuf_GetSize(&b);
- }
- if (NULL != packet) {
- *packet = DynBuf_Detach(&b);
- }
- DynBuf_Destroy(&b);
- return TRUE;
-
-abort:
- DynBuf_Destroy(&b);
- return FALSE;
-}
-
+++ /dev/null
-/*********************************************************
- * Copyright (C) 2005 VMware, Inc. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation version 2.1 and no later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- *********************************************************/
-#include "vmware.h"
-
-#ifdef WIN32
-#include <winsock.h>
-#else
-#include <sys/types.h>
-#include <netinet/in.h>
-#endif
-#include <string.h>
-#include <stdlib.h>
-
-#include "str.h"
-#include "util.h"
-#include "SLPv2.h"
-#include "SLPv2Private.h"
-
-/*
- *-----------------------------------------------------------------------------
- *
- * SLPv2MsgParserStringValid -
- *
- * Returns TRUE if the string at 'offset' bytes into 'packet'
- * actually fits inside the packet, which is 'len' bytes.
- *
- * Results:
- * Returns TRUE upon success, FALSE upon memory error.
- *
- * Side effects:
- * None
- *
- *-----------------------------------------------------------------------------
- */
-
-Bool
-SLPv2MsgParserStringValid(char *packet, // IN
- int len, // IN
- int offset) // IN
-{
- uint16 stringLength = Portable_ntohs(*((uint16 *) (packet + len)));
- return (offset + stringLength > len) ? FALSE : TRUE;
-}
-
-/*
- *-----------------------------------------------------------------------------
- *
- * SLPv2MsgParserGetString -
- *
- * Returns a C string, given the (16 bit length) Pascal string at
- * packet+offset.
- *
- * Results:
- * Returns a C string.
- *
- * Side effects:
- * None
- *
- *-----------------------------------------------------------------------------
- */
-
-char *
-SLPv2MsgParserGetString(char *packet, // IN
- int packetLength, // IN
- int offset, // IN
- Bool *ok) // OUT
-{
- uint16 stringLength = Portable_ntohs(*((uint16 *) (packet + offset)));
- char *string = NULL;
- Bool myOk = TRUE;
-
- /* make sure the string actually fits in the packet */
- if (offset + stringLength > packetLength) {
- if (NULL != ok) {
- myOk = FALSE;
- }
- goto bye;
- }
-
- string = Util_SafeMalloc(stringLength + 1);
-
- /*
- * We use memcpy() because Str_Strcpy() doesn't handle non-NULL
- * terminated strings.
- */
- memcpy(string, packet + offset + 2, stringLength);
- string[stringLength] = '\0';
-
-bye:
- if (NULL != ok) {
- if (*ok == FALSE && myOk == TRUE) {
- myOk = FALSE;
- }
- *ok = myOk;
- }
- return string;
-}
-
-/*
- *-----------------------------------------------------------------------------
- *
- * SLPv2MsgParser_Init -
- *
- * Initializes a SLPv2_Parse structure.
- *
- * Results:
- * Returns a pointer to a SLPv2_Parse structure or NULL upon error.
- *
- * Side effects:
- * None
- *
- *-----------------------------------------------------------------------------
- */
-
-struct SLPv2_Parse *
-SLPv2MsgParser_Init()
-{
- struct SLPv2_Parse *parse;
-
- parse = (struct SLPv2_Parse *) Util_SafeMalloc(sizeof (struct SLPv2_Parse));
- parse->header = NULL;
- parse->languageTag = NULL;
-
- parse->serviceRequest.prList = NULL;
- parse->serviceRequest.serviceType = NULL;
- parse->serviceRequest.scope = NULL;
- parse->serviceRequest.predicate = NULL;
- parse->serviceRequest.spi = NULL;
-
- parse->serviceReply.error = 0;
- parse->serviceReply.urlCount = 0;
- parse->serviceReply.url = NULL;
-
- parse->attributeRequest.prList = NULL;
- parse->attributeRequest.url = NULL;
- parse->attributeRequest.scope = NULL;
- parse->attributeRequest.tagList = NULL;
- parse->attributeRequest.spi = NULL;
-
- parse->attributeReply.error = 0;
- parse->attributeReply.attributeList = NULL;
-
- return parse;
-}
-
-/*
- *-----------------------------------------------------------------------------
- *
- * SLPv2MsgParserGetHeader -
- *
- * Populates the SLPv2_Parse structure with SLPv2 header data.
- *
- * Results:
- * Returns TRUE upon success, FALSE upon memory error.
- *
- * Side effects:
- * None
- *
- *-----------------------------------------------------------------------------
- */
-
-Bool
-SLPv2MsgParserGetHeader(char *packet, // IN
- int len, // IN
- struct SLPv2_Parse *parse) // IN
-{
- uint16 languageTagOffset = sizeof(struct SLPv2_Header);
- Bool parseOk = TRUE;
- uint32 lengthTemp;
- uint8 *lengthArrayTemp = (uint8 *) &lengthTemp;
-
- parse->header = (struct SLPv2_Header *) packet;
-
- if (len < sizeof(struct SLPv2_Header)) {
- return FALSE;
- }
-
- if (SLPV2_VERSION != parse->header->version) {
- return FALSE;
- }
-
- parse->languageTagLength = Portable_ntohs(*((uint16 *) (packet + languageTagOffset)));
-
- parse->languageTag = SLPv2MsgParserGetString(packet,
- len,
- languageTagOffset,
- &parseOk);
- if (! parseOk) {
- return FALSE;
- }
-
-
- lengthArrayTemp[0] = parse->header->length[0];
- lengthArrayTemp[1] = parse->header->length[1];
- lengthArrayTemp[2] = parse->header->length[2];
- lengthTemp = Portable_ntohl(lengthTemp);
- parse->header->length[0] = lengthArrayTemp[0];
- parse->header->length[1] = lengthArrayTemp[1];
- parse->header->length[2] = lengthArrayTemp[2];
-
- parse->header->xid = Portable_ntohs(parse->header->xid);
-
- return TRUE;
-}
-
-/*
- *-----------------------------------------------------------------------------
- *
- * SLPv2MsgParserParseServiceRequest -
- *
- * Populates the SLPv2_Parse structure with SLPv2 Service Request data.
- *
- * Results:
- * Returns TRUE upon success, FALSE upon memory error.
- *
- * Side effects:
- * None
- *
- *-----------------------------------------------------------------------------
- */
-
-Bool
-SLPv2MsgParserParseServiceRequest(char *packet, // IN
- int len, // IN
- struct SLPv2_Parse *parse) // IN
-{
- Bool parseOkay = TRUE;
-
- /* previous responder list */
- uint16 prOffset = sizeof(struct SLPv2_Header) + parse->languageTagLength + 2;
- uint16 prLength = Portable_ntohs(*((uint16 *) (packet + prOffset)));
-
- /* service type */
- uint16 stOffset = prOffset + prLength + 2;
- uint16 stLength = Portable_ntohs(*((uint16 *) (packet + stOffset)));
-
- /* scope list */
- uint16 slOffset = stOffset + stLength + 2;
- uint16 slLength = Portable_ntohs(*((uint16 *) (packet + slOffset)));
-
- /* predicate */
- uint16 predicateOffset = slOffset + slLength + 2;
- uint16 predicateLength = Portable_ntohs(*((uint16 *) (packet + predicateOffset)));
-
- /* security parameter index */
- uint16 spiOffset = predicateOffset + predicateLength + 2;
-
- parse->serviceRequest.prList = SLPv2MsgParserGetString(packet, len,
- prOffset, &parseOkay);
- parse->serviceRequest.serviceType = SLPv2MsgParserGetString(packet, len,
- stOffset, &parseOkay);
- parse->serviceRequest.scope = SLPv2MsgParserGetString(packet, len,
- slOffset, &parseOkay);
- parse->serviceRequest.predicate = SLPv2MsgParserGetString(packet, len,
- predicateOffset, &parseOkay);
- parse->serviceRequest.spi = SLPv2MsgParserGetString(packet, len,
- spiOffset, &parseOkay);
- if (! parseOkay) {
- return FALSE;
- }
-
- return TRUE;
-}
-
-
-/*
- *-----------------------------------------------------------------------------
- *
- * SLPv2MsgParserParseServiceReply -
- *
- * Populates the SLPv2_Parse structure with SLPv2 Service Reply data.
- *
- * Results:
- * Returns TRUE upon success, FALSE upon memory error.
- *
- * Side effects:
- * None
- *
- *-----------------------------------------------------------------------------
- */
-
-Bool
-SLPv2MsgParserParseServiceReply(char *packet, // IN
- int len, // IN
- struct SLPv2_Parse *parse) // IN
-{
- uint16 errorOffset;
- uint16 urlCountOffset;
- uint16 urlOffset;
- Bool parseOk = TRUE;
- int i;
-
- /* error code */
- errorOffset = sizeof(struct SLPv2_Header) + parse->languageTagLength + 2;
- parse->serviceReply.error = Portable_ntohs(*((uint16 *) (packet + errorOffset)));
-
- urlCountOffset = errorOffset + 2;
- parse->serviceReply.urlCount = Portable_ntohs(*((uint16 *) (packet
- + urlCountOffset)));
- parse->serviceReply.url = Util_SafeMalloc(sizeof(char *)
- * parse->serviceReply.urlCount);
- urlOffset = urlCountOffset + 2;
-
- /*
- * Zero out the URL array so if we fail in the middle of
- * populating it, * SLPv2MsgParser_Destroy will free a bunch
- * of NULLs instead of dangling pointers.
- */
- for (i = 0; i < parse->serviceReply.urlCount; i++) {
- parse->serviceReply.url[i] = NULL;
- }
-
- for (i = 0; i < parse->serviceReply.urlCount; i++) {
- uint16 urlLength = Portable_ntohs(*((uint16 *) (packet + urlOffset)));
-
- parse->serviceReply.url[i] = SLPv2MsgParserGetString(packet, len,
- urlOffset, &parseOk);
- if (! parseOk) {
- return FALSE;
- }
- urlOffset = urlOffset + urlLength + 2;
- }
-
- return TRUE;
-}
-
-
-/*
- *-----------------------------------------------------------------------------
- *
- * SLPv2MsgParserParseAttributeRequest -
- *
- * Populates the SLPv2_Parse structure with SLPv2 Attribute Request data.
- *
- * Results:
- * Returns TRUE upon success, FALSE upon memory error.
- *
- * Side effects:
- * None
- *
- *-----------------------------------------------------------------------------
- */
-
-Bool
-SLPv2MsgParserParseAttributeRequest(char *packet, // IN
- int len, // IN
- struct SLPv2_Parse *parse) // IN
-{
- Bool parseOkay = TRUE;
-
- /* previous responder list */
- uint16 prOffset = sizeof(struct SLPv2_Header) + parse->languageTagLength + 2;
- uint16 prLength = Portable_ntohs(*((uint16 *) (packet + prOffset)));
-
- /* url */
- uint16 urlOffset = prOffset + prLength + 2;
- uint16 urlLength = Portable_ntohs(*((uint16 *) (packet + urlOffset)));
-
- /* scope list */
- uint16 slOffset = urlOffset + urlLength + 2;
- uint16 slLength = Portable_ntohs(*((uint16 *) (packet + slOffset)));
-
- /* tag list */
- uint16 tagOffset = slOffset + slLength + 2;
- uint16 tagLength = Portable_ntohs(*((uint16 *) (packet + tagOffset)));
-
- /* security parameter index */
- uint16 spiOffset = tagOffset + tagLength + 2;
-
-
- parse->attributeRequest.prList = SLPv2MsgParserGetString(packet, len,
- prOffset, &parseOkay);
- parse->attributeRequest.url = SLPv2MsgParserGetString(packet, len,
- urlOffset, &parseOkay);
- parse->attributeRequest.scope = SLPv2MsgParserGetString(packet, len,
- slOffset, &parseOkay);
- parse->attributeRequest.tagList = SLPv2MsgParserGetString(packet, len,
- tagOffset, &parseOkay);
- parse->attributeRequest.spi = SLPv2MsgParserGetString(packet, len,
- spiOffset, &parseOkay);
-
- if (! parseOkay) {
- return FALSE;
- }
-
- return TRUE;
-}
-
-
-/*
- *-----------------------------------------------------------------------------
- *
- * SLPv2MsgParserParseAttributeReply -
- *
- * Populates the SLPv2_Parse structure with SLPv2 Attribute Reply data.
- *
- * Results:
- * Returns TRUE upon success, FALSE upon memory error.
- *
- * Side effects:
- * None
- *
- *-----------------------------------------------------------------------------
- */
-
-Bool
-SLPv2MsgParserParseAttributeReply(char *packet, // IN
- int len, // IN
- struct SLPv2_Parse *parse) // IN
-{
- uint16 errorOffset;
- uint16 attributeOffset;
- Bool parseOkay = TRUE;
- /* error code */
- errorOffset = sizeof(struct SLPv2_Header) + parse->languageTagLength + 2;
- parse->attributeReply.error = Portable_ntohs(*((uint16 *) (packet + errorOffset)));
-
- /* attribute list */
- attributeOffset = errorOffset + 2;
- parse->attributeReply.attributeList = SLPv2MsgParserGetString(packet, len,
- attributeOffset, &parseOkay);
-
- if (! parseOkay) {
- return FALSE;
- }
-
- return TRUE;
-}
-
-/*
- *-----------------------------------------------------------------------------
- *
- * SLPv2MsgParser_Parse -
- *
- * Returns TRUE if the packet parses as a SLPv2 message.
- *
- * Results:
- * Returns TRUE upon success, FALSE upon memory error.
- *
- * Side effects:
- * None
- *
- *-----------------------------------------------------------------------------
- */
-
-Bool
-SLPv2MsgParser_Parse(struct SLPv2_Parse *parse, // IN
- char *packet, // IN
- int len) // IN
-{
- Bool parseOk = TRUE;
- ASSERT(NULL != parse);
-
- parseOk = SLPv2MsgParserGetHeader(packet, len, parse);
-
- if (parseOk) {
- switch (parse->header->functionId) {
- case SLPV2_SERVICEREQUEST:
- parseOk = SLPv2MsgParserParseServiceRequest(packet, len, parse);
- break;
- case SLPV2_SERVICEREPLY:
- parseOk = SLPv2MsgParserParseServiceReply(packet, len, parse);
- break;
- case SLPV2_ATTRIBUTEREQUEST:
- parseOk = SLPv2MsgParserParseAttributeRequest(packet, len, parse);
- break;
- case SLPV2_ATTRIBUTEREPLY:
- parseOk = SLPv2MsgParserParseAttributeReply(packet, len, parse);
- break;
- default:
- parseOk = FALSE;
- } // switch
- } // if parseOk
-
- return parseOk;
-}
-
-
-/*
- *-----------------------------------------------------------------------------
- *
- * SLPv2MsgParser_Destroy -
- *
- * Returns TRUE if the
- *
- * Results:
- * Disposes of a SLPv2_Parse structure.
- *
- * Side effects:
- * None
- *
- *-----------------------------------------------------------------------------
- */
-
-void
-SLPv2MsgParser_Destroy(struct SLPv2_Parse *parse) // IN
-{
- int i;
-
- ASSERT(NULL != parse);
-
- /*
- * header. We don't free(parse->header) because that's up to the caller
- * to manage, since the caller allocated the buffer that contains the
- * packet.
- */
-
- parse->header = NULL;
- free(parse->languageTag);
- parse->languageTag = NULL;
-
- /*
- * service request strings.
- */
- free(parse->serviceRequest.prList);
- free(parse->serviceRequest.serviceType);
- free(parse->serviceRequest.scope);
- free(parse->serviceRequest.predicate);
- free(parse->serviceRequest.spi);
- parse->serviceRequest.prList = NULL;
- parse->serviceRequest.serviceType = NULL;
- parse->serviceRequest.scope = NULL;
- parse->serviceRequest.predicate = NULL;
- parse->serviceRequest.spi = NULL;
-
- /*
- * service response.
- */
- for (i=0; i < parse->serviceReply.urlCount; i++) {
- free(parse->serviceReply.url[i]);
- parse->serviceReply.url[i] = NULL;
- }
- free(parse->serviceReply.url);
-
- /*
- * attribute request.
- */
- free(parse->attributeRequest.prList);
- free(parse->attributeRequest.url);
- free(parse->attributeRequest.scope);
- free(parse->attributeRequest.tagList);
- free(parse->attributeRequest.spi);
- parse->attributeRequest.prList = NULL;
- parse->attributeRequest.url = NULL;
- parse->attributeRequest.scope = NULL;
- parse->attributeRequest.tagList = NULL;
- parse->attributeRequest.spi = NULL;
-
- /*
- * attribute reply.
- */
- free(parse->attributeReply.attributeList);
- parse->attributeReply.attributeList = NULL;
-
- free(parse);
-} // SLPv2MsgParser_Destroy
-
+++ /dev/null
-/*********************************************************
- * Copyright (C) 2005 VMware, Inc. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation version 2.1 and no later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- *********************************************************/
-
-#ifndef _SLPV2_H_
-#define _SLPV2_H_
-
-struct sockaddr_in;
-
-/*
- * These functions are used by a client to discover services.
- */
-
-typedef void (*SLPv2DiscoveryCallbackProcType)(struct sockaddr_in *sin,
- int sin_len,
- const char *url,
- const char *attributes,
- Bool *cancelSearch,
- void *context);
-
-void SLPv2_DiscoverServices(char *serviceType,
- int32 timeoutInUSecs,
- SLPv2DiscoveryCallbackProcType callBackProc,
- void *callBackProcContext);
-
-
-/*
- * These functions are used by a server to manage a list of local service
- * names that it advertises to the network.
- */
-
-Bool SLPv2Service_Initialize(void);
-
-void SLPv2Service_Shutdown(void);
-
-Bool SLPv2Service_Announce(char *servicename, char *serviceProperties, int options);
-
-
-#endif // _SLPV2_H_
+++ /dev/null
-/*********************************************************
- * Copyright (C) 2005 VMware, Inc. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation version 2.1 and no later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- *********************************************************/
-
-#ifndef _SLPV2_PRIVATE_H_
-#define _SLPV2_PRIVATE_H_
-
-#define SLPV2_PORT 427
-#define SLPV2_HIGHPORT 61526 /* vmware internal */
-
-/*
- * SLPv2 header constants
- */
-#define SLPV2_VERSION 2
-
-/*
- * SLPv2 Function IDs
- */
-#define SLPV2_SERVICEREQUEST 1
-#define SLPV2_SERVICEREPLY 2
-#define SLPV2_ATTRIBUTEREQUEST 6
-#define SLPV2_ATTRIBUTEREPLY 7
-
-
-/*
- * These are procedures on windows. But, networking is not available on
- * all guests (I'm looking at you, Win95), so we cannot link with htons
- * or similar functions.
- */
-#define Portable_ntohl(in) ((in >> 24) & 0x000000ff) | ((in >> 8) & 0x0000ff00) | \
- ((in << 8) & 0x00ff0000) | ((in << 24) & 0xff000000)
-#define Portable_htonl(in) Portable_ntohl(in)
-#define Portable_ntohs(in) ((in >> 8) & 0x00ff) | ((in << 8) & 0xff00)
-#define Portable_htons(in) Portable_ntohs(in)
-
-
-/*
- * From RFC 2608, Section 8. SLPv2 Header:
- *
- * 0 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- *+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *| Version | Function-ID | Length |
- *+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *| Length, contd.|O|F|R| reserved |Next Ext Offset|
- *+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *| Next Extension Offset, contd.| XID |
- *+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *| Language Tag Length | Language Tag \
- *+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-#include "vmware_pack_begin.h"
-struct SLPv2_Header {
- uint8 version;
- uint8 functionId;
- uint8 length[3]; // "uint32 length:24" doesn't pack correctly w/Win32.
- uint16 flags;
- uint8 extOffset[3]; // "uint32 extOffset:24" doesn't pack correctly w/Win32.
- uint16 xid;
-}
-#include "vmware_pack_end.h"
-;
-
-/*
- * From RFC 2608, Section 4.3. SLPv2 URL Entry:
- *
- * 0 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Reserved | Lifetime | URL Length |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * |URL len, contd.| URL (variable length) \
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * |# of URL auths | Auth. blocks (if any) \
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
-
-#include "vmware_pack_begin.h"
-struct SLPv2_URL {
- uint8 reserved;
- uint16 lifetime;
- uint16 length;
-}
-#include "vmware_pack_end.h"
-;
-
-struct SLPv2_ServiceRequest {
- char *prList; /* Previous Responder List */
- char *serviceType;
- char *scope;
- char *predicate; /* LDAPv3 search filter, optional */
- char *spi; /* SLP Security Parameter Index */
-};
-
-struct SLPv2_ServiceReply {
- uint16 error;
- uint16 urlCount;
- char **url;
-};
-
-struct SLPv2_AttributeRequest {
- char *prList; /* Previous Responder List */
- char *url;
- char *scope;
- char *tagList;
- char *spi; /* SLP Security Parameter Index */
-};
-
-struct SLPv2_AttributeReply {
- uint16 error;
- char *attributeList;
-};
-
-struct SLPv2_Parse {
- struct SLPv2_Header *header;
- uint16 languageTagLength;
- char *languageTag;
- struct SLPv2_ServiceRequest serviceRequest;
- struct SLPv2_ServiceReply serviceReply;
- struct SLPv2_AttributeRequest attributeRequest;
- struct SLPv2_AttributeReply attributeReply;
-};
-
-
-/*
- * From RFC 2608, Section 8.1. Service Request:
- *
- * 0 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Service Location header (function = SrvRqst = 1) |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | length of <PRList> | <PRList> String \
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | length of <service-type> | <service-type> String \
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | length of <scope-list> | <scope-list> String \
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | length of predicate string | Service Request <predicate> \
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | length of <SLP SPI> string | <SLP SPI> String \
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
-/*
- * From RFC 2608, Section 8.2. Service Reply:
- * 0 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Service Location header (function = SrvRply = 2) |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Error Code | URL Entry count |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | <URL Entry 1> ... <URL Entry N> \
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
-/*
- * From RFC 2608, Section 10.3. Attribute Request:
- * 0 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Service Location header (function = AttrRqst = 6) |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | length of PRList | <PRList> String \
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | length of URL | URL \
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | length of <scope-list> | <scope-list> string \
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | length of <tag-list> string | <tag-list> string \
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | length of <SLP SPI> string | <SLP SPI> string \
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
-/*
- * From RFC 2608, Section 10.4. Attribute Reply:
- * 0 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Service Location header (function = AttrRply = 7) |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Error Code | length of <attr-list> |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | <attr-list> \
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * |# of AttrAuths | Attribute Authentication Block (if present) \
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
-
-/*
- * SLPv2 Parsing prototypes.
- */
-struct SLPv2_Parse *SLPv2MsgParser_Init(void);
-Bool SLPv2MsgParser_Parse(struct SLPv2_Parse *parse, char *packet, int len);
-void SLPv2MsgParser_Destroy(struct SLPv2_Parse *parse);
-
-
-/*
- * Matching.
- */
-
-Bool SLPv2MsgParser_ServiceRequestMatch(struct SLPv2_Parse *parse, // IN
- char *myIpsList, // UN
- char *myServiceType, // IN
- char *myScope, // IN
- char *myPredicate, // IN
- uint16 *xid); // OUT
-
-Bool SLPv2MsgParser_ServiceReplyMatch(struct SLPv2_Parse *parse, // IN
- int *urlCount, // OUT
- char ***urlArray, // OUT
- uint16 *xid); // OUT
-
-Bool SLPv2MsgParser_AttributeRequestMatch(struct SLPv2_Parse *parse, // IN
- char *myIpsList, // UN
- char *url, // IN
- char *myScope, // IN
- char *tagList, // IN
- uint16 *xid); // OUT
-
-Bool SLPv2MsgParser_AttributeReplyMatch(struct SLPv2_Parse *parse, // IN
- char **attributeList, // OUT
- uint16 *xid); // OUT
-
-
-
-/*
- * SLPv2 packet generation prototypes.
- */
-Bool SLPv2MsgAssembler_ServiceRequest(char **packet, // OUT
- int *packetSize, // OUT
- uint16 xid, // IN
- Bool overflowFlag, // IN
- Bool freshFlag, // IN
- Bool requestMulticastFlag, // IN
- char *languageTag, // IN
- char *prList, // IN
- char *serviceType, // IN
- char *scopeList, // IN
- char *predicate, // IN
- char *spi); // IN
-
-Bool SLPv2MsgAssembler_ServiceReply(char **packet, // OUT
- int *packetSize, // OUT
- uint16 xid, // IN
- char *languageTag, // IN
- uint16 errorCode, // IN
- uint16 urlEntryCount, // IN
- char **urls); // IN
-
-Bool SLPv2MsgAssembler_AttributeRequest(char **packet, // OUT
- int *packetSize, // OUT
- uint16 xid, // IN
- Bool overflowFlag, // IN
- Bool freshFlag, // IN
- Bool requestMulticastFlag, // IN
- char *languageTag, // IN
- char *prList, // IN
- char *url, // IN
- char *scopeList, // IN
- char *tagList, // IN
- char *spi); // IN
-
-Bool SLPv2MsgAssembler_AttributeReply(char **packet, // OUT
- int *packetSize, // OUT
- uint16 xid, // IN
- char *languageTag, // IN
- uint16 errorCode, // IN
- char *attributeList); // IN
-
-
-
-
-#endif // _SLPV2_PRIVATE_H_
-
-
-