File: ecos.c

package info (click to toggle)
ion 3.2.1%2Bdfsg-1.1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 23,768 kB
  • ctags: 11,049
  • sloc: ansic: 141,798; sh: 22,848; makefile: 7,818; python: 1,638; sql: 311; perl: 197; awk: 178; xml: 50; java: 19
file content (131 lines) | stat: -rw-r--r-- 2,602 bytes parent folder | download | duplicates (2)
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
 *	ecos.c:		implementation of the extension definition
 *			functions for the Extended Class of Service
 *			block.
 *
 *	Copyright (c) 2008, California Institute of Technology.
 *	ALL RIGHTS RESERVED.  U.S. Government Sponsorship
 *	acknowledged.
 *
 *	Author: Scott Burleigh, JPL
 */

#include "bpP.h"
#include "bei.h"
#include "ecos.h"

int	ecos_offer(ExtensionBlock *blk, Bundle *bundle)
{
	Sdnv	flowLabelSdnv;
	char	dataBuffer[32];

	if (bundle->extendedCOS.flags == 0 && bundle->extendedCOS.ordinal == 0)
	{
		return 0;	/*	ECOS block is unnecessary.	*/
	}

	blk->blkProcFlags = BLK_MUST_BE_COPIED;
	blk->dataLength = 2;
	if (bundle->extendedCOS.flags & BP_FLOW_LABEL_PRESENT)
	{
		encodeSdnv(&flowLabelSdnv, bundle->extendedCOS.flowLabel);
	}
	else
	{
		flowLabelSdnv.length = 0;
	}

	blk->dataLength += flowLabelSdnv.length;
	blk->size = 0;
	blk->object = 0;
	dataBuffer[0] = bundle->extendedCOS.flags;
	dataBuffer[1] = bundle->extendedCOS.ordinal;
	memcpy(dataBuffer + 2, flowLabelSdnv.text, flowLabelSdnv.length);
	return serializeExtBlk(blk, NULL, dataBuffer);
}

void	ecos_release(ExtensionBlock *blk)
{
	return;
}

int	ecos_record(ExtensionBlock *sdrBlk, AcqExtBlock *ramBlk)
{
	return 0;
}

int	ecos_copy(ExtensionBlock *newBlk, ExtensionBlock *oldBlk)
{
	return 0;
}

int	ecos_processOnFwd(ExtensionBlock *blk, Bundle *bundle, void *ctxt)
{
	return 0;
}

int	ecos_processOnAccept(ExtensionBlock *blk, Bundle *bundle, void *ctxt)
{
	return 0;
}

int	ecos_processOnEnqueue(ExtensionBlock *blk, Bundle *bundle, void *ctxt)
{
	return 0;
}

int	ecos_processOnDequeue(ExtensionBlock *blk, Bundle *bundle, void *ctxt)
{
	return 0;
}

int	ecos_acquire(AcqExtBlock *blk, AcqWorkArea *wk)
{
	Bundle		*bundle = &wk->bundle;
	unsigned char	*cursor;
	int		bytesRemaining = blk->dataLength;

	if (bytesRemaining < 2)
	{
		return 0;		/*	Malformed.		*/
	}

	/*	Data parsed out of the ecos byte array go directly
	 *	into the bundle structure, not into a block-specific
	 *	workspace object.					*/

	blk->size = 0;
	blk->object = NULL;
	cursor = blk->bytes + (blk->length - blk->dataLength);
	bundle->extendedCOS.flags = *cursor;
	cursor++;
	bundle->extendedCOS.ordinal = *cursor;
	cursor++;
	bytesRemaining -= 2;
	if (bundle->extendedCOS.flags & BP_FLOW_LABEL_PRESENT)
	{
		extractSmallSdnv(&(bundle->extendedCOS.flowLabel), &cursor,
				&bytesRemaining);
	}
	else
	{
		bundle->extendedCOS.flowLabel = 0;
	}

	if (bytesRemaining != 0)
	{
		return 0;		/*	Malformed.		*/
	}

	return 1;
}

int	ecos_check(AcqExtBlock *blk, AcqWorkArea *wk)
{
	return 0;
}

void	ecos_clear(AcqExtBlock *blk)
{
	return;
}