Commit d31ab2bd authored by David Johnson's avatar David Johnson

Adds rmcp support (for new wifi pcs) to the power command. For now, you

have to re-run the swig-wrappers target in tools/rmanage/GNUmakefile to
generate the wrapper and perl module; this must of course be done when
changes are made to the rmcp libs.

  * GNUmakefile.in, configure, configure.in: add tools/rmanage
  * tbsetup/GNUmakefile.in, tbsetup/power*.in: add rmcp to power command
  * tools/GNUmakefile.in: add rmanage
  * tools/rmanage/*.c,*.h: bugfixes, swig helper methods, etc.
  * tools/rmanage/rmcp.i: swig import control file
  * tools/rmanage/rmcp.pm,rmcp_wrap.c: rmcp wrapper/module generated by swig
parent c50308a8
......@@ -31,7 +31,7 @@ include Makeconf
SUBDIRS = lib db assign www @optional_subdirs@ ipod security sensors \
pxe tbsetup account tmcd utils tip capture ipod vis \
sensors os xmlrpc install/newnode_sshkeys mote tools/whol \
tools/svn wiki bugdb collab
tools/svn wiki bugdb collab tools/rmanage
all: all-subdirs
......
......@@ -2481,7 +2481,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
tools/GNUmakefile rc.d/1.mysql-server.sh tools/svn/GNUmakefile \
tools/pcapper/GNUmakefile tools/teachswitch/GNUmakefile \
tools/webcamapplet/GNUmakefile tools/whol/GNUmakefile \
tools/selectapplet/GNUmakefile \
tools/selectapplet/GNUmakefile tools/rmanage/GNUmakefile \
$eventfiles \
$winfiles \
$pelabfiles \
......
......@@ -862,7 +862,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
tools/GNUmakefile rc.d/1.mysql-server.sh tools/svn/GNUmakefile \
tools/pcapper/GNUmakefile tools/teachswitch/GNUmakefile \
tools/webcamapplet/GNUmakefile tools/whol/GNUmakefile \
tools/selectapplet/GNUmakefile \
tools/selectapplet/GNUmakefile tools/rmanage/GNUmakefile \
$eventfiles \
$winfiles \
$pelabfiles \
......
......@@ -74,7 +74,7 @@ LIB_STUFF = libtbsetup.pm exitonwarn.pm libtestbed.pm snmpit_intel.pm \
snmpit_nortel.pm \
libaudit.pm libreboot.pm libosload.pm libtestbed.py \
libadminmfs.pm libtblog.pm libtblog_simple.pm libArchive.pm \
power_mail.pm power_whol.pm Template.pm
power_mail.pm power_whol.pm Template.pm power_rmcp.pm
# These scripts installed setuid, with sudo.
SETUID_BIN_SCRIPTS = node_reboot eventsys_control tarfiles_setup savelogs \
......
......@@ -30,6 +30,7 @@ use power_rpc27;
use power_sgmote;
use power_mail;
use power_whol;
use power_rmcp;
use snmpit_apc;
use libtestbed;
use NodeType;
......@@ -256,7 +257,8 @@ foreach my $power_id (keys %outlets) {
my $IP;
my $class;
if ($power_id eq "mail" || $power_id =~ /^whol-/) {
if ($power_id eq "mail" || $power_id =~ /^whol-/
|| $power_id=~ /^rmcp-/) {
$type = $power_id;
$IP = "";
$class = "";
......@@ -314,6 +316,11 @@ foreach my $power_id (keys %outlets) {
print "Control of $nodestr failed.\n"; $exitval++;
$errors++;
}
} elsif ($type =~ /rmcp-(\w+)/) {
if (rmcpctrl($1,$op,@nodes)) {
print "Control of $nodestr failed.\n"; ++$exitval;
++$errors;
}
} elsif ($type eq "mail") {
if (mailctrl($op,@nodes)) {
print "Control of $nodestr failed.\n"; $exitval++;
......
#!/usr/bin/perl -wT
#
# EMULAB-COPYRIGHT
# Copyright (c) 2007 University of Utah and the Flux Group.
# All rights reserved.
#
#
# Handle RMCP-ASF power control. Can be extended for IPMI later.
# Sends cycle,off,on to node list in parallel.
#
package power_rmcp;
use Exporter;
@ISA = ("Exporter");
@EXPORT = qw( rmcpctrl );
use lib "@prefix@/lib";
use libdb;
use rmcp;
my $debug = 0;
my $parallelize = 0;
# Turn off line buffering on output
$| = 1;
my %portinfo = ();
# usage: rmcpctrl(type, cmd, nodes)
# type = { "asf" } # can probably be extended to ipmi
# cmd = { "cycle" | "on" | "off" }
# nodes = list of one or more physcial node names
#
# Returns 0 on success. Non-zero on failure.
#
sub rmcpctrl($$@) {
my ($type,$cmd,@nodes) = @_;
my $exitval = 0;
if ($debug) {
print "rmcpctrl called with $type,$cmd,(" . join(',',@nodes) . ")\n";
}
if ($cmd ne "cycle" && $cmd ne "on" && $cmd ne "off") {
warn "invalid power command '$cmd'; \n" .
" valid commands are 'cycle, 'off', and 'on'.\n";
return scalar(@nodes);
}
my %rmcp_nodeinfo = ();
# grab rmcp keys and info
for my $n (@nodes) {
my $res = DBQueryFatal("select key_type,key_role,key_uid,mykey" .
" from outlets_remoteauth" .
" where node_id='$n' and key_type='$type'");
if (!$res || $res->num_rows() == 0) {
warn "No keys of type $type in database for $n, skipping\n";
++$exitval;
}
while (my ($ttype,$role,$uid,$key) = $res->fetchrow()) {
my $atref = [ $ttype,$role,$uid,$key ];
if (!defined($rmcp_nodeinfo{$n})) {
$rmcp_nodeinfo{$n} = [];
}
if ($debug) {
print "DEBUG: considered key ($ttype,$role,$uid,$key) for $n\n";
}
push @{$rmcp_nodeinfo{$n}}, $atref;
}
}
if ($debug) {
rmcp::rmcp_set_debug_level(5);
rmcp::rmcp_set_enable_warn_err(1);
}
for my $n (keys(%rmcp_nodeinfo)) {
if ($debug) {
print "DEBUG: selecting asf keys for $n\n";
}
if ($type eq 'asf' || $type eq 'ASF') {
my ($rkey,$rolestr,$gkey);
for my $keylist (@{$rmcp_nodeinfo{$n}}) {
if ($debug) {
print "DEBUG: considered keylist (" . join(',',@{$keylist}) . ")\n";
}
if ($keylist->[0] eq "$type") {
if ($keylist->[1] eq 'generation'
|| $keylist->[1] eq 'Generation') {
$gkey = $keylist->[3];
}
else {
#
# XXX: yes, this will use only the LAST
# non-"generation" key as the role key for asf.
#
$rkey = $keylist->[3];
$rolestr = $keylist->[1];
}
}
}
if ($parallelize) {
if (my $pid = fork()) {
push @kids, $pid;
}
else {
my $tret = rmcpexec($type,$cmd,$n,$rolestr,$rkey,$gkey);
exit $tret;
}
}
else {
if (rmcpexec($type,$cmd,$n,$rolestr,$rkey,$gkey)) {
++$exitval;
}
}
# grab child exit vals
if ($parallelize) {
while (wait() > 0) {
if ($?) {
++$exitval;
}
}
}
}
else {
warn "Unsupported RMCP type $type for $node_id, skipping";
++$exitval;
}
}
return $exitval;
}
#
# Arguments: $type,$cmd,$node_id,$rolestr,$role_key,$gen_key
#
# XXX: add support for key usernames (no rush cause we don't have machines
# that support that functionality.
sub rmcpexec($$$$$$) {
my ($type,$cmd,$node_id,$rolestr,$role_key,$gen_key) = @_;
if (!defined($type) || !defined($cmd) || !defined($node_id)
|| !defined($rolestr) || !defined($role_key) || !defined($gen_key)) {
warn "Incomplete argument list, skipping node" .
(defined($node_id)?" $node_id":"");
return -1;
}
if ($type eq 'asf' || $type eq 'ASF') {
my $rrole;
if ($rolestr eq 'administrator' || $rolestr eq 'Administrator') {
$rrole = $rmcp::RMCP_ROLE_ADM;
}
elsif ($rolestr eq 'operator' || $rolestr eq 'Operator') {
$rrole = $rmcp::RMCP_ROLE_OP;
}
else {
warn "Unknown RMCP role $rolestr, skipping";
return -2;
}
if ($debug) {
print "DEBUG: starting rmcp for $node_id\n";
}
my $rkey = rmcp::rmcp_setstrbuf($role_key,length($role_key));
my $gkey = rmcp::rmcp_setstrbuf($gen_key,length($gen_key));
my $ctx = rmcp::rmcp_ctx_init(5,3);
if (rmcp::rmcp_ctx_setsecure($ctx,$rrole,
$rkey,length($role_key),
$gkey,length($gen_key))
!= $rmcp::RMCP_SUCCESS) {
warn "Could not create a secure RMCP context for " .
"$node_id, skipping";
rmcp::rmcp_finalize($ctx);
return -3;
}
if (rmcp::rmcp_open($ctx,$node_id) != $rmcp::RMCP_SUCCESS) {
warn "Could not open an RMCP connection for $node_id, skipping";
rmcp::rmcp_finalize($ctx);
return -4;
}
if (rmcp::rmcp_start_secure_session($ctx) != $rmcp::RMCP_SUCCESS) {
warn "Could not start a secure RMCP session for $node_id, skipping";
rmcp::rmcp_finalize($ctx);
return -5;
}
my $retval;
if ($cmd eq 'cycle') {
$retval = rmcp::rmcp_asf_power_cycle($ctx);
}
elsif ($cmd eq 'on') {
$retval = rmcp::rmcp_asf_power_up($ctx);
}
elsif ($cmd eq 'off') {
$retval = rmcp::rmcp_asf_power_down($ctx);
}
else {
warn "Unknown RMCP command $cmd for $node_id, skipping";
return -6;
}
if ($retval != $rmcp::RMCP_SUCCESS) {
warn "While cycling $node_id, RMCP error (" .
rmcp::rmcp_error_tostr($retval) . ")";
return $retval;
}
}
else {
warn "Unsupported RMCP type $type for $node_id, skipping";
return -7;
}
return 0;
}
1;
......@@ -11,7 +11,7 @@ SUBDIR = tools
include $(OBJDIR)/Makeconf
SUBDIRS = teachswitch webcamapplet whol svn
SUBDIRS = teachswitch webcamapplet whol svn rmanage
ifneq ($(host_cpu),arm)
SUBDIRS += pcapper
......
#
# EMULAB-COPYRIGHT
# Copyright (c) 2006 University of Utah and the Flux Group.
# Copyright (c) 2006-2007 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -11,15 +11,28 @@ SUBDIR = tools/rmanage
include $(OBJDIR)/Makeconf
all: rmanage
CFLAGS = -Wall
LDFLAGS = -lssl
SWIG_INCS = -I/usr/local/lib/perl5/5.8.8/mach/CORE -I$(SRCDIR)
LIB_STUFF = rmcp.so rmcp.pm
SBIN_STUFF = rmanage
all: $(SBIN_STUFF) $(LIB_STUFF)
include $(TESTBED_SRCDIR)/GNUmakerules
CFLAGS = -Wall
LDFLAGS = -lssl
# swig ourselves
rmcp.so: rmcp.o rmcp_wrap.o
ld -shared $^ -lssl -o rmcp.so
rmanage: GNUmakefile rmanage.o
$(CC) $(CFLAGS) $(LDFLAGS) rmanage.o -o rmanage
swig-wrappers: rmcp.h rmcp.i
swig -perl5 -module rmcp -o rmcp_wrap.c $(SWIG_INCS) $(SRCDIR)/rmcp.i
rmcp_wrap.o: $(SRCDIR)/rmcp_wrap.c
$(CC) -fpic -c $(CFLAGS) $(SWIG_INCS) $(LDFLAGS) $(SRCDIR)/rmcp_wrap.c
rmanage: GNUmakefile rmanage.o rmcp.o
$(CC) $(CFLAGS) $(LDFLAGS) rmanage.o rmcp.o -o rmanage
cp rmanage rmanage.debug
strip rmanage
......@@ -29,7 +42,12 @@ rmanage.o: rmanage.c rmcp.c
rmcp.o: rmcp.c rmcp.h
$(CC) -c -o rmcp.o $(CFLAGS) $<
install boss-install: $(INSTALL_SBINDIR)/rmanage
install: all script-install
boss-install: install
script-install: $(addprefix $(INSTALL_SBINDIR)/, $(SBIN_STUFF)) \
$(addprefix $(INSTALL_LIBDIR)/, $(LIB_STUFF))
clean:
rm -f *.o core rmanage rmanage.debug
rm -f *.o core rmanage rmanage.debug *.so
......@@ -4,13 +4,14 @@
* All rights reserved.
*/
#include "rmcp.h"
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include "rmcp.h"
extern char *optarg;
extern int optopt;
......@@ -97,7 +98,6 @@ int main(int argc,char **argv) {
int roleno;
char *uid = NULL;
char *command = NULL;
int i;
while ((c = getopt(argc,argv,"c:t:m:r:k:g:u:hdsH")) != -1) {
switch (c) {
......@@ -173,6 +173,8 @@ int main(int argc,char **argv) {
}
rmcp_set_debug_level(debug);
rmcp_set_enable_warn_err(1);
ctx = rmcp_ctx_init(timeout,retries);
if (secure) {
......@@ -187,14 +189,10 @@ int main(int argc,char **argv) {
exit(-4);
}
/* rkey_len = gkey_len = 4; */
rmcp_ctx_setsecure(ctx,
roleno,
//rkey,rkey_len, //"1234",4, //rkey_len,
//gkey,gkey_len); //"1234",4); // gkey_len);
"1234",rkey_len,
"1234",gkey_len);
rkey,rkey_len,
gkey,gkey_len);
if (uid) {
rmcp_ctx_setuid(ctx,uid,strlen(uid)-1);
}
......@@ -203,8 +201,8 @@ int main(int argc,char **argv) {
retval = rmcp_open(ctx,client);
if (retval != RMCP_SUCCESS) {
fprintf(stderr,
"Could not open connection to client %s: error 0x%x.\n",
client,retval);
"Could not open connection to client %s: error %s.\n",
client,rmcp_error_tostr(retval));
exit(-5);
}
......@@ -223,9 +221,9 @@ int main(int argc,char **argv) {
retval = rmcp_asf_ping(ctx,&supported);
if (retval != RMCP_SUCCESS) {
fprintf(stderr,
"Command '%s' failed: 0x%x\n",
"Command '%s' failed: %s\n",
command,
retval);
rmcp_error_tostr(retval));
exit(-16);
}
rmcp_print_asf_supported(supported,NULL);
......@@ -235,9 +233,9 @@ int main(int argc,char **argv) {
retval = rmcp_asf_get_capabilities(ctx,&capabilities);
if (retval != RMCP_SUCCESS) {
fprintf(stderr,
"Command '%s' failed: 0x%x\n",
"Command '%s' failed: %s\n",
command,
retval);
rmcp_error_tostr(retval));
exit(-16);
}
rmcp_print_asf_capabilities(capabilities,NULL);
......@@ -247,9 +245,9 @@ int main(int argc,char **argv) {
retval = rmcp_asf_get_sysstate(ctx,&sysstate);
if (retval != RMCP_SUCCESS) {
fprintf(stderr,
"Command '%s' failed: 0x%x\n",
"Command '%s' failed: %s\n",
command,
retval);
rmcp_error_tostr(retval));
exit(-16);
}
rmcp_print_asf_sysstate(sysstate,NULL);
......@@ -267,7 +265,8 @@ int main(int argc,char **argv) {
fprintf(stdout,"Reset sent successfully.\n");
}
else {
fprintf(stderr,"Reset unsuccessful: 0x%x\n",retval);
fprintf(stderr,"Reset unsuccessful: %s\n",
rmcp_error_tostr(retval));
exit(-12);
}
}
......@@ -278,7 +277,8 @@ int main(int argc,char **argv) {
fprintf(stdout,"Power cycle sent successfully.\n");
}
else {
fprintf(stderr,"Power cycle unsuccessful: 0x%x\n",retval);
fprintf(stderr,"Power cycle unsuccessful: %s\n",
rmcp_error_tostr(retval));
exit(-12);
}
}
......@@ -289,7 +289,8 @@ int main(int argc,char **argv) {
fprintf(stdout,"Power up sent successfully.\n");
}
else {
fprintf(stderr,"Power up unsuccessful: 0x%x\n",retval);
fprintf(stderr,"Power up unsuccessful: %s\n",
rmcp_error_tostr(retval));
exit(-12);
}
}
......@@ -300,7 +301,8 @@ int main(int argc,char **argv) {
fprintf(stdout,"Power down sent successfully.\n");
}
else {
fprintf(stderr,"Power down unsuccessful: 0x%x\n",retval);
fprintf(stderr,"Power down unsuccessful: %s\n",
rmcp_error_tostr(retval));
exit(-12);
}
}
......@@ -308,8 +310,8 @@ int main(int argc,char **argv) {
retval = rmcp_finalize(ctx);
if (retval != RMCP_SUCCESS) {
fprintf(stderr,
"Could not close session/connection: 0x%x\n",
retval);
"Could not close session/connection: %s\n",
rmcp_error_tostr(retval));
exit(-10);
}
......
......@@ -4,8 +4,6 @@
* All rights reserved.
*/
#include "rmcp.h"
#include <stdlib.h>
#include <string.h>
#include <arpa/inet.h>
......@@ -23,8 +21,10 @@
#include <sys/stat.h>
#include <time.h>
#include "rmcp.h"
static int rmcp_debug_level = 0;
static int rmcp_warnerr = 0;
#define INFO(level,fmt,...) { \
if (level <= rmcp_debug_level) { \
......@@ -34,19 +34,27 @@ static int rmcp_debug_level = 0;
} \
}
#define WARN(fmt,...) { \
fputs("WARN: ",stderr); \
fputs(__FUNCTION__,stderr); \
fprintf(stderr,": " fmt "\n", ## __VA_ARGS__); \
if (rmcp_warnerr) { \
fputs("WARN: ",stderr); \
fputs(__FUNCTION__,stderr); \
fprintf(stderr,": " fmt "\n", ## __VA_ARGS__); \
} \
}
#define ERROR(fmt,...) { \
fprintf(stderr,"ERROR:%d: ",__LINE__); \
fprintf(stderr,"%s: " fmt "\n", __FUNCTION__, ## __VA_ARGS__); \
if (rmcp_warnerr) { \
fprintf(stderr,"ERROR:%d: ",__LINE__); \
fprintf(stderr,"%s: " fmt "\n", __FUNCTION__, ## __VA_ARGS__); \
} \
}
void rmcp_set_debug_level(int debug) {
rmcp_debug_level = debug;
}
void rmcp_set_enable_warn_err(int enable) {
rmcp_warnerr = enable;
}
/**
* need a generic protocol read function that reads packets -- and it should
* not need to know anything about protocol state. all packets can be read
......@@ -55,8 +63,8 @@ void rmcp_set_debug_level(int debug) {
* can still make use of the packet marshalling functions.
*/
static u_int8_t rmcp_incr_seqno(rmcp_ctx_t *ctx);
static u_int8_t rmcp_rsp_incr_seqno(rmcp_ctx_t *ctx);
static void rmcp_incr_seqno(rmcp_ctx_t *ctx);
static void rmcp_rsp_incr_seqno(rmcp_ctx_t *ctx);
static void rmcp_rsp_fill_hdr(rmcp_ctx_t *ctx,rmcp_msg_t *msg);
static void rmcp_fill_hdr(rmcp_ctx_t *ctx,rmcp_msg_t *msg);
......@@ -69,8 +77,62 @@ static void rmcp_rsp_fill_tlr(rmcp_ctx_t *ctx,rmcp_msg_t *msg);
static void rmcp_fill_all(rmcp_ctx_t *ctx,rmcp_msg_t *msg,
u_int8_t type,u_int8_t data_len,u_int8_t *data);
static char *rmcp_rsp_rakp_msg_code_str(int code);
/**
* swig convenience functions.
*/
u_int8_t *swr_fill_str(char *str,int len) {
u_int8_t *retval = NULL;
retval = (u_int8_t *)malloc(sizeof(u_int8_t)*len);
if (retval != NULL) {
strncpy((char *)retval,str,len);
}
return retval;
}
rmcp_error_t swr_rmcp_asf_ping(rmcp_ctx_t *rit,
rmcp_asf_supported_t *supported) {
rmcp_asf_supported_t *sptr = NULL;
rmcp_error_t retval;
retval = rmcp_asf_ping(rit,&sptr);
if (retval == RMCP_SUCCESS) {
*supported = *sptr;
}
free(sptr);
return retval;
}
rmcp_error_t swr_rmcp_asf_get_capabilities(rmcp_ctx_t *rit,
rmcp_asf_capabilities_t *cap) {
rmcp_asf_capabilities_t *cptr = NULL;
rmcp_error_t retval;
retval = rmcp_asf_get_capabilities(rit,&cptr);
if (retval == RMCP_SUCCESS) {
*cap = *cptr;
}
free(cptr);
return retval;
}
rmcp_error_t swr_rmcp_asf_get_sysstate(rmcp_ctx_t *rit,
rmcp_asf_sysstate_t *state) {
rmcp_asf_sysstate_t *sptr = NULL;
rmcp_error_t retval;
retval = rmcp_asf_get_sysstate(rit,&sptr);
if (retval == RMCP_SUCCESS) {
*state = *sptr;
}
free(sptr);
return retval;
}
rmcp_error_t rmcp_asf_ping(rmcp_ctx_t *ctx,
......@@ -109,7 +171,7 @@ rmcp_error_t rmcp_asf_ping(rmcp_ctx_t *ctx,
return RMCP_SUCCESS;
}
ERROR("protocol error",retval);
ERROR("protocol error %d",retval);
rmcp_free_asf_msg(recv);
return RMCP_ERR_PROTOCOL;
}
......@@ -150,7 +212,7 @@ rmcp_error_t rmcp_asf_get_capabilities(rmcp_ctx_t *ctx,
return RMCP_SUCCESS;
}
ERROR("protocol error",retval);
ERROR("protocol error %d",retval);
rmcp_free_asf_msg(recv);
return RMCP_ERR_PROTOCOL;
}
......@@ -190,7 +252,7 @@ rmcp_error_t rmcp_asf_get_sysstate(rmcp_ctx_t *ctx,
return RMCP_SUCCESS;
}
ERROR("protocol error",retval);
ERROR("protocol error %d",retval);
rmcp_free_asf_msg(recv);
return RMCP_ERR_PROTOCOL;
}
......@@ -200,7 +262,6 @@ rmcp_error_t rmcp_asf_get_sysstate(rmcp_ctx_t *ctx,
*/
rmcp_error_t rmcp_asf_reset(rmcp_ctx_t *ctx) {
rmcp_msg_t *send;
rmcp_msg_t *recv;
rmcp_error_t retval;
u_int8_t buf[4+1+2+2+2];
int wc;
......@@ -233,7 +294,6 @@ rmcp_error_t rmcp_asf_reset(rmcp_ctx_t *ctx) {
}
rmcp_error_t rmcp_asf_power_up(rmcp_ctx_t *ctx) {
rmcp_msg_t *send;
rmcp_msg_t *recv;
rmcp_error_t retval;
u_int8_t buf[4+1+2+2+2];
int wc;
......@@ -266,7 +326,6 @@ rmcp_error_t rmcp_asf_power_up(rmcp_ctx_t *ctx) {
}
rmcp_error_t rmcp_asf_power_cycle(rmcp_ctx_t *ctx) {
rmcp_msg_t *send;
rmcp_msg_t *recv;
rmcp_error_t retval;
u_int8_t buf[4+1+2+2+2];
int wc;
......@@ -300,7 +359,6 @@ rmcp_error_t rmcp_asf_power_cycle(rmcp_ctx_t *ctx) {
rmcp_error_t rmcp_asf_power_down(rmcp_ctx_t *ctx) {
rmcp_msg_t *send;
rmcp_msg_t *recv;
rmcp_error_t retval;
u_int8_t buf[4+1+2+2+2];
int wc;
......@@ -353,7 +411,7 @@ static char *rmcp_rsp_rakp_msg_codes[] = {
"Invalid integrity check value",
};
static char *rmcp_rsp_rakp_msg_code_str(int code) {
char *rmcp_rsp_rakp_msg_code_tostr(int code) {
if (code < RMCP_RSP_RAKP_SUCCESS || code > RMCP_RSP_RAKP_ERR_INVALID_INTEGRITY_VALUE) {
return "UNKNOWN RSP/RAKP MSG CODE!";
}
......@@ -404,14 +462,14 @@ rmcp_error_t rmcp_finalize(rmcp_ctx_t *ctx) {
}
else {
WARN("rsp/rakp status '%s'",
rmcp_rsp_rakp_msg_code_str(recv->data->data[0]));
rmcp_rsp_rakp_msg_code_tostr(recv->data->data[0]));
rmcp_free_asf_msg(recv);
return RMCP_ERR_PROTOCOL;
}
}
rmcp_free_asf_msg(recv);
ERROR("protocol error",retval);
ERROR("protocol error %d",retval);
return RMCP_ERR_PROTOCOL;
}
......@@ -585,7 +643,7 @@ rmcp_error_t rmcp_start_secure_session(rmcp_ctx_t *ctx) {
else {
/* error somewhere, probably on our end... */
ERROR("open session response error: '%s'",
rmcp_rsp_rakp_msg_code_str(rmsg->data->data[0]));
rmcp_rsp_rakp_msg_code_tostr(rmsg->data->data[0]));
rmcp_free_asf_msg(rmsg);
return RMCP_ERR_PROTOCOL;
}
......@@ -714,7 +772,7 @@ rmcp_error_t rmcp_start_secure_session(rmcp_ctx_t *ctx) {
else {
/* error somewhere, probably on our end... */
ERROR("RAKP2 response error: '%s'",
rmcp_rsp_rakp_msg_code_str(rmsg->data->data[0]));
rmcp_rsp_rakp_msg_code_tostr(rmsg->data->data[0]));
rmcp_free_asf_msg(rmsg);
return RMCP_ERR_PROTOCOL;
}
......@@ -955,7 +1013,7 @@ rmcp_error_t rmcp_open(rmcp_ctx_t *ctx,char *hostname) {
return RMCP_SUCCESS;
}
static u_int8_t rmcp_incr_seqno(rmcp_ctx_t *ctx) {
static void rmcp_incr_seqno(rmcp_ctx_t *ctx) {
++(ctx->rmcp_seqno);
/* have to jump over 0xff -- otherwise our msgs won't get ack'd */
if (ctx->rmcp_seqno == 0xff) {
......@@ -963,7 +1021,7 @@ static u_int8_t rmcp_incr_seqno(rmcp_ctx_t *ctx) {
}
}
static u_int8_t rmcp_rsp_incr_seqno(rmcp_ctx_t *ctx) {
static void rmcp_rsp_incr_seqno(rmcp_ctx_t *ctx) {
if (ctx->secure) {
++(ctx->rmcp_rsp_seqno);
}
......@@ -1095,10 +1153,10 @@ rmcp_error_t rmcp_raw_read(rmcp_ctx_t *ctx,
}
rmcp_error_t rmcp_recv_msg_and_ack(rmcp_ctx_t *ctx,rmcp_msg_t **msg) {
struct timeval tv,ntv;