Revision fbc89189

View differences:

include/net_helper.h
120 120
* Serialize a nodeID in a byte array.
121 121
* @param[in] b A pointer to the byte array that will contain the nodeID serialization.
122 122
* @param[in] s A pointer to the nodeID to be serialized.
123
* @return The number of bytes written in the buffer.
123
* @param[in] max_write_size A number of bytes available in b
124
* @return The number of bytes written in the buffer, or -1 if error
124 125
*/
125
int nodeid_dump(uint8_t *b, const struct nodeID *s);
126
int nodeid_dump(uint8_t *b, const struct nodeID *s, size_t max_write_size);
126 127

  
127 128
#endif /* NET_HELPER_H */
som/net_helper.c
190 190
  return (memcmp(&s1->addr, &s2->addr, sizeof(struct sockaddr_in)) == 0);
191 191
}
192 192

  
193
int nodeid_dump(uint8_t *b, const struct nodeID *s)
193
int nodeid_dump(uint8_t *b, const struct nodeID *s, size_t max_write_size)
194 194
{
195
  if (max_write_size < sizeof(struct sockaddr_in)) return -1;
196

  
195 197
  memcpy(b, &s->addr, sizeof(struct sockaddr_in));
196 198

  
197 199
  return sizeof(struct sockaddr_in);

Also available in: Unified diff