1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
/*
bpcancel.c: bundle cancellation utility.
*/
/* */
/* Copyright (c) 2009, California Institute of Technology. */
/* All rights reserved. */
/* Author: Scott Burleigh, Jet Propulsion Laboratory */
/* */
#include <bpP.h>
#if defined (VXWORKS) || defined (RTEMS)
int bpcancel(int a1, int a2, int a3, int a4, int a5,
int a6, int a7, int a8, int a9, int a10)
{
char *sourceEid = (char *) a1;
unsigned int creationSec = a2;
unsigned int creationCount = a3;
unsigned int fragmentOffset = a4;
unsigned int fragmentLength = a5;
#else
int main(int argc, char **argv)
{
char *sourceEid = argc > 1 ? argv[1] : NULL;
unsigned int creationSec = argc > 2 ? atoi(argv[2]) : 0;
unsigned int creationCount = argc > 3 ? atoi(argv[3]) : 0;
unsigned int fragmentOffset = argc > 4 ? atoi(argv[4]) : 0;
unsigned int fragmentLength = argc > 5 ? atoi(argv[5]) : 0;
#endif
Sdr sdr;
BpTimestamp creationTime;
Object bundleObj;
if (sourceEid == NULL || creationSec == 0)
{
PUTS("Usage: bpcancel <source EID> <creation seconds> \
<creation count> <fragment offset> <fragment length>");
return 0;
}
creationTime.seconds = creationSec;
creationTime.count = creationCount;
if (bp_attach() < 0)
{
putErrmsg("Can't attach to BP.", NULL);
return 0;
}
sdr = bp_get_sdr();
CHKZERO(sdr_begin_xn(sdr));
if (findBundle(sourceEid, &creationTime, fragmentOffset, fragmentLength,
&bundleObj) < 0)
{
sdr_cancel_xn(sdr);
bp_detach();
putErrmsg("bpcancel failed finding bundle.", NULL);
return 0;
}
if (bundleObj)
{
if (bpDestroyBundle(bundleObj, 1) < 0)
{
sdr_cancel_xn(sdr);
bp_detach();
putErrmsg("bpcancel failed destroying bundle.", NULL);
return 0;
}
}
if (sdr_end_xn(sdr) < 0)
{
putErrmsg("bpcancel failed.", NULL);
}
writeErrmsgMemos();
PUTS("Stopping bpcancel.");
bp_detach();
return 0;
}
|