CORDET Framework - C2 Implementation
CrPsPktUtil.c
Go to the documentation of this file.
1 
21 #include <CrPsUserConstants.h>
22 
29 uint32_t getPcktInt(void* p, uint32_t pos)
30 {
31  uint32_t t;
32  (void)memcpy(&t, &((uint8_t*)p)[pos], sizeof(t));
33  return __builtin_bswap32(t);
34 }
35 
42 uint16_t getPcktShort(void* p, uint32_t pos)
43 {
44  uint16_t t;
45  (void)memcpy(&t, &((uint8_t*)p)[pos], sizeof(t));
46  return __builtin_bswap16(t);
47 }
48 
55 uint8_t getPcktChar(void* p, uint32_t pos)
56 {
57  uint8_t t;
58  (void)memcpy(&t, &((uint8_t*)p)[pos], sizeof(t));
59  return t;
60 }
61 
68 void setPcktInt(void* p, uint32_t pos, uint32_t t)
69 {
70  t=__builtin_bswap32(t);
71  (void)memcpy(&((uint8_t*)p)[pos], &t, sizeof(t));
72 }
73 
80 void setPcktShort(void* p, uint32_t pos, uint16_t t)
81 {
82  t=__builtin_bswap16(t);
83  (void)memcpy(&((uint8_t*)p)[pos], &t, sizeof(t));
84 }
85 
92 void setPcktChar(void* p, uint32_t pos, uint8_t t)
93 {
94  (void)memcpy(&((uint8_t*)p)[pos], &t, sizeof(t));
95 }
96 
97 
98 /*----------------------------------------------------------------------------*/
Header file to define all user-configurable constants and types for the IASW Application.
uint32_t getPcktInt(void *p, uint32_t pos)
Generic Getter for Int Values from a Packet.
Definition: CrPsPktUtil.c:29
void setPcktShort(void *p, uint32_t pos, uint16_t t)
Generic Setter for Short Values from a Packet.
Definition: CrPsPktUtil.c:80
void setPcktInt(void *p, uint32_t pos, uint32_t t)
Generic Setter for Int Values from a Packet.
Definition: CrPsPktUtil.c:68
void setPcktChar(void *p, uint32_t pos, uint8_t t)
Generic Setter for Character Values from a Packet.
Definition: CrPsPktUtil.c:92
uint16_t getPcktShort(void *p, uint32_t pos)
Generic Getter for Short Values from a Packet.
Definition: CrPsPktUtil.c:42
uint8_t getPcktChar(void *p, uint32_t pos)
Generic Getter for Character Values from a Packet.
Definition: CrPsPktUtil.c:55
P&P Software GmbH, Copyright 2012-2013, All Rights Reserved