The Assimilation Project
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
unknownframe.c
Go to the documentation of this file.
1 
25 #include <string.h>
26 #include <projectcommon.h>
27 #include <frameset.h>
28 #include <unknownframe.h>
29 #include <frametypes.h>
30 #include <generic_tlv_min.h>
31 #include <tlvhelper.h>
32 
33 FSTATIC gboolean _unknownframe_default_isvalid(const Frame *, gconstpointer, gconstpointer);
34 
39 
41 FSTATIC gboolean
43  gconstpointer tlvptr,
44  gconstpointer pktend)
45 {
46  (void)self; (void)tlvptr; (void)pktend;
48  return FALSE;
49 }
50 
51 
55 unknownframe_new(guint16 frame_type)
56 {
57  Frame* baseframe;
58 
59  baseframe = frame_new(frame_type, sizeof(UnknownFrame));
61  proj_class_register_subclassed (baseframe, "UnknownFrame");
62 
63  return CASTTOCLASS(UnknownFrame, baseframe);
64 }
65 
66 
69 Frame*
70 unknownframe_tlvconstructor(gconstpointer tlvstart,
71  gconstpointer pktend,
72  gpointer* ignorednewpkt,
73  gpointer* ignorednewpktend)
74 {
75  guint16 frametype = get_generic_tlv_type(tlvstart, pktend);
76  guint32 framelength = get_generic_tlv_len(tlvstart, pktend);
77  const guint8* framevalue = get_generic_tlv_value(tlvstart, pktend);
78  UnknownFrame * ret = unknownframe_new(frametype);
79  Frame * fret = CASTTOCLASS(Frame, ret);
80  (void)ignorednewpkt;
81  (void)ignorednewpktend;
82  g_return_val_if_fail(ret != NULL, NULL);
83 
84  ret->baseclass.length = framelength;
85  fret->setvalue(fret, g_memdup(framevalue, framelength), framelength, frame_default_valuefinalize);
86  return fret;
87 }
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
Describes interfaces to the Unknown Frame (UnknownFrame) C-Class.
UnknownFrame * unknownframe_new(guint16 frame_type)
Construct a new UnknownFrame - disallowing for "derived" frame types...
Definition: unknownframe.c:55
This is our UnknownFrame class object - for unrecognized Frames.
Definition: unknownframe.h:34
#define FSTATIC
Definition: projectcommon.h:31
FSTATIC gboolean _unknownframe_default_isvalid(const Frame *, gconstpointer, gconstpointer)
UnknownFrame class 'isvalid' member function (always returns FALSE)
Definition: unknownframe.c:42
guint16 get_generic_tlv_type(gconstpointer tlv_vp, gconstpointer pktend)
Return the 'Type' of the given TLV TLV entry (first two bytes)
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
gboolean(* isvalid)(const Frame *self, gconstpointer tlvptr, gconstpointer pktend)
TRUE if TLV data looks valid...
Definition: frame.h:50
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 * unknownframe_tlvconstructor(gconstpointer tlvstart, gconstpointer pktend, gpointer *ignorednewpkt, gpointer *ignorednewpktend)
Given marshalled data corresponding to an unknown Frame (basic binary frame), return that correspondi...
Definition: unknownframe.c:70
FSTATIC void frame_default_valuefinalize(gpointer value)
Finalize a Frame.
Definition: frame.c:56
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.
void(* setvalue)(Frame *self, gpointer value, guint32 length, GDestroyNotify valfinal)
member function for setting value
Definition: frame.h:52
#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