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 {
91  guint16 frametype = get_generic_tlv_type(tlvstart, pktend);
92  guint16 framelength = get_generic_tlv_len(tlvstart, pktend);
93  const guint8* framevalue = get_generic_tlv_value(tlvstart, pktend);
95  CryptFrame * cret = cryptframe_new(frametype, 0, NULL);
96  Frame * ret = CASTTOCLASS(Frame, cret);
97  g_return_val_if_fail(cret != NULL, NULL);
98 
99  cret->baseclass.length = framelength;
100  (void)frametype;
101  (void)framelength;
102  (void)framevalue;
103  (void)ret;
105  return NULL;
106 }