#ifdef EXTRA_MSGS
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include "mslp_sd.h"
#include "slp.h"
#include "mslp.h"
#include "mslp_dat.h"
#include "mslplib.h"
#include "mslplib_opt.h"
TESTEXPORT SLPInternalError
generate_srvtyperqst(char *pcSendBuf, int *piSendSz,
const char *pcLangTag, const char *pcNamingAuth, const char *pcScope) {
int offset = 0;
SLPInternalError err;
int iMTU = *piSendSz;
if (!pcNamingAuth || !pcScope) {
return SLP_PARAMETER_BAD;
}
if (!(strlen(pcNamingAuth) == 1 && pcNamingAuth[0] == '*') &&
(err = isURLEscapedOK(pcNamingAuth)) != SLP_OK)
{
LOG_SLP_ERROR_AND_RETURN( SLP_LOG_ERR,"generate_srvtyperqst: bad naming auth string",err);
}
if ((err = add_header(pcLangTag,pcSendBuf,iMTU,SRVTYPERQST,0,&offset))
!= SLP_OK) {
LOG_SLP_ERROR_AND_RETURN(SLP_LOG_ERR,"generate_srvtyperqst: could not add header",err);
}
offset += 2;
if (pcNamingAuth[0] == '*' && pcNamingAuth[1] == '\0') {
if ((err = add_sht(pcSendBuf,iMTU,0xffff,&offset)) != SLP_OK) {
LOG_SLP_ERROR_AND_RETURN(SLP_LOG_ERR,"generate_srvtyperqst: couldn't add wildcard NA",err);
}
} else if ((err = add_string(pcSendBuf,iMTU,pcNamingAuth,&offset))
!= SLP_OK) {
LOG_SLP_ERROR_AND_RETURN(SLP_LOG_ERR,"generate_srvtyperqst: couldn't add naming auth",err);
}
if ((err = add_string(pcSendBuf,iMTU,pcScope,&offset)) != SLP_OK) {
LOG_SLP_ERROR_AND_RETURN(SLP_LOG_ERR,"generate_srvtyperqst: could not add scope list",err);
}
SETLEN(pcSendBuf,offset);
*piSendSz = offset;
return SLP_OK;
}
TESTEXPORT SLPInternalError
generate_attrrqst(char *pcSendBuf, int *piSendSz,
const char *pcLangTag, const char *pcService,
const char *pcScope, const char *pcTagList) {
int offset = 0;
SLPInternalError err;
int iMTU = *piSendSz;
if (!pcScope || !pcLangTag || !pcService || !pcSendBuf || !piSendSz) {
return SLP_PARAMETER_BAD;
}
(void) memset(pcSendBuf, 0, *piSendSz);
if ((err = add_header(pcLangTag,pcSendBuf,iMTU,ATTRRQST,0,&offset))
!= SLP_OK) {
LOG_SLP_ERROR_AND_RETURN(SLP_LOG_ERR,"generate_attrrqst: could not add header",err);
}
offset += 2;
if ((err = add_string(pcSendBuf,iMTU,pcService,&offset)) != SLP_OK) {
LOG_SLP_ERROR_AND_RETURN(SLP_LOG_ERR,"generate_attrrqst: could not add url or type",err);
}
if ((err = add_string(pcSendBuf,iMTU,pcScope,&offset)) != SLP_OK) {
LOG_SLP_ERROR_AND_RETURN(SLP_LOG_ERR,"generate_attrrqst: could not add scopes",err);
}
if ((err = add_string(pcSendBuf,iMTU,pcTagList,&offset)) != SLP_OK) {
LOG_SLP_ERROR_AND_RETURN(SLP_LOG_ERR,"generate_attrrqst: could not add tag list",err);
}
if ((err = add_sht(pcSendBuf, iMTU, 0, &offset)) != SLP_OK) {
LOG_SLP_ERROR_AND_RETURN(SLP_LOG_ERR,"generate_attrrqst: could not add 0 SLP SPI len", err);
}
SETLEN(pcSendBuf,offset);
*piSendSz = offset;
return SLP_OK;
}
#else
#endif