The Assimilation Project  based on Assimilation version
Go to the documentation of this file.
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>
33 FSTATIC gboolean _unknownframe_default_isvalid(const Frame *, gconstpointer, gconstpointer);
41 FSTATIC gboolean
43  gconstpointer tlvptr,
44  gconstpointer pktend)
45 {
46  (void)self; (void)tlvptr; (void)pktend;
48  return FALSE;
49 }
55 unknownframe_new(guint16 frame_type)
56 {
57  Frame* baseframe;
59  baseframe = frame_new(frame_type, sizeof(UnknownFrame));
61  proj_class_register_subclassed (baseframe, "UnknownFrame");
63  return CASTTOCLASS(UnknownFrame, baseframe);
64 }
69 Frame*
70 unknownframe_tlvconstructor(gpointer 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);
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
void(* setvalue)(Frame *self, gpointer value, guint32 length, GDestroyNotify valfinal)
member function for setting value
Definition: frame.h:52
FSTATIC gboolean _unknownframe_default_isvalid(const Frame *, gconstpointer, gconstpointer)
UnknownFrame class &#39;isvalid&#39; member function (always returns FALSE)
Definition: unknownframe.c:42
guint16 get_generic_tlv_type(gconstpointer tlv_vp, gconstpointer pktend)
Return the &#39;Type&#39; 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:125
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
guint32 get_generic_tlv_len(gconstpointer tlv_vp, gconstpointer pktend)
Return the &#39;Length&#39; of the given generic TLV entry (first 3 bytes after type) Note: return result is ...
Project common header file.
Header file defining the data layouts for our Frames.
TLV helper interfaces definitions.
gboolean(* isvalid)(const Frame *self, gconstpointer tlvptr, gconstpointer pktend)
TRUE if TLV data looks valid...
Definition: frame.h:50
Frame * unknownframe_tlvconstructor(gpointer 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:57
Provides definitions for using our generic TLV capabilities.
gconstpointer get_generic_tlv_value(gconstpointer tlv_vp, gconstpointer pktend)
Return a const pointer to the &#39;Value&#39; of the given generic TLV entry.
#define CASTTOCLASS(Cclass, obj)
Safely cast &#39;obj&#39; to C-class &#39;class&#39; - verifying that it was registerd as being of type class ...
Definition: proj_classes.h:66