The Assimilation Project
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
cryptframe.c
Go to the documentation of this file.
1 
25 #include <string.h>
26 #include <projectcommon.h>
27 #include <frameset.h>
28 #include <cryptframe.h>
29 #include <frametypes.h>
30 #include <generic_tlv_min.h>
31 #include <tlvhelper.h>
32 
33 FSTATIC gboolean _cryptframe_default_isvalid(const Frame *, gconstpointer, gconstpointer);
34 
39 
41 FSTATIC gboolean
43  gconstpointer tlvptr,
44  gconstpointer pktend)
45 {
46  gsize length;
47  const CryptFrame* cself = CASTTOCONSTCLASS(CryptFrame, self);
48 
49  if (tlvptr == NULL) {
50  if (cself->encryption_method <= 0 ) {
51  return FALSE;
52  }
53  length = self->length;
54  }else{
55  length = get_generic_tlv_len(tlvptr, pktend);
56  }
57  (void)length;
58 
60  return FALSE;
61 }
62 
63 
67 cryptframe_new(guint16 frame_type,
68  guint16 encryption_method,
69  void * keyinfo)
70 {
71  Frame* baseframe;
72  CryptFrame* ret;
73 
74  baseframe = frame_new(frame_type, sizeof(CryptFrame));
76  proj_class_register_subclassed (baseframe, "CryptFrame");
77 
78 
79  ret = CASTTOCLASS(CryptFrame, baseframe);
80  ret->encryption_method = encryption_method;
81  ret->encryption_key_info = keyinfo;
82  return ret;
83 }
88 cryptframe_tlvconstructor(gconstpointer tlvstart,
89  gconstpointer pktend,
90  gpointer* ignorednewpkt,
91  gpointer* ignoredpktend)
92 {
93  guint16 frametype = get_generic_tlv_type(tlvstart, pktend);
94  guint32 framelength = get_generic_tlv_len(tlvstart, pktend);
95  const guint8* framevalue = get_generic_tlv_value(tlvstart, pktend);
97  CryptFrame * cret = cryptframe_new(frametype, 0, NULL);
98  Frame * ret = CASTTOCLASS(Frame, cret);
99 
100  (void)ignorednewpkt;
101  (void)ignoredpktend;
102  g_return_val_if_fail(cret != NULL, NULL);
103 
104  cret->baseclass.length = framelength;
105  (void)frametype;
106  (void)framelength;
107  (void)framevalue;
108  (void)ret;
110  return NULL;
111 }
guint32 length
Frame Length.
Definition: frame.h:46
Implements minimal client-oriented Frame and Frameset capabilities.
This is the base Frame class object (in-memory TLV (type, length, value)) for every general component...
Definition: frame.h:43
#define WINEXPORT
Definition: projectcommon.h:45
#define FSTATIC
Definition: projectcommon.h:31
guint16 get_generic_tlv_type(gconstpointer tlv_vp, gconstpointer pktend)
Return the 'Type' of the given TLV TLV entry (first two bytes)
Describes interfaces to C-String Frame (Cstringframe) C-Class It holds conventional zero-terminated b...
Frame * frame_new(guint16 frame_type, gsize framesize)
Construct a new frame - allowing for "derived" frame types...
Definition: frame.c:124
gpointer proj_class_register_subclassed(gpointer object, const char *static_subclassname)
Log the creation of a subclassed object from a superclassed object.
Definition: proj_classes.c:192
CryptFrame * cryptframe_new(guint16 frame_type, guint16 encryption_method, void *keyinfo)
Construct a new CryptFrame This can only be used directly for creating CryptFrame frames...
Definition: cryptframe.c:67
gboolean(* isvalid)(const Frame *self, gconstpointer tlvptr, gconstpointer pktend)
TRUE if TLV data looks valid...
Definition: frame.h:50
#define CASTTOCONSTCLASS(Cclass, obj)
Safely cast 'obj' to const C-class 'class' - verifying that it was registered as being of type class ...
Definition: proj_classes.h:71
guint32 get_generic_tlv_len(gconstpointer tlv_vp, gconstpointer pktend)
Return the 'Length' of the given generic TLV entry (first 3 bytes after type)
Project common header file.
Header file defining the data layouts for our Frames.
TLV helper interfaces definitions.
Frame baseclass
Definition: cryptframe.h:35
int encryption_method
Definition: cryptframe.h:36
FSTATIC gboolean _cryptframe_default_isvalid(const Frame *, gconstpointer, gconstpointer)
CryptFrame class 'isvalid' member function (checks for valid cryptframe objects)
Definition: cryptframe.c:42
void * encryption_key_info
Definition: cryptframe.h:37
Provides definitions for using our generic TLV capabilities.
gconstpointer get_generic_tlv_value(gconstpointer tlv_vp, gconstpointer pktend)
Return a const pointer to the 'Value' of the given generic TLV entry.
This is our CryptFrame class object - representing an encryption method.
Definition: cryptframe.h:34
#define CASTTOCLASS(Cclass, obj)
Safely cast 'obj' to C-class 'class' - verifying that it was registerd as being of type class ...
Definition: proj_classes.h:66
WINEXPORT Frame * cryptframe_tlvconstructor(gconstpointer tlvstart, gconstpointer pktend, gpointer *ignorednewpkt, gpointer *ignoredpktend)
Given marshalled packet data corresponding to an CryptFrame (C-style string), return the correspondin...
Definition: cryptframe.c:88