New get/set methods for packet object.

This commit is contained in:
wb2osz 2021-09-21 12:56:45 -04:00
parent 1b3ed76584
commit 257d2e3544
2 changed files with 45 additions and 1 deletions

View File

@ -372,7 +372,7 @@ packet_t ax25_from_text (char *monitor, int strict)
/*
* Tearing it apart is destructive so make our own copy first.
*/
char stuff[512];
char stuff[AX25_MAX_PACKET_LEN+1];
char *pinfo;
int ssid_temp, heard_temp;
@ -1717,6 +1717,19 @@ int ax25_get_info (packet_t this_p, unsigned char **paddr)
} /* end ax25_get_info */
void ax25_set_info (packet_t this_p, unsigned char *new_info_ptr, int new_info_len)
{
unsigned char *old_info_ptr;
int old_info_len = ax25_get_info (this_p, &old_info_ptr);
this_p->frame_len -= old_info_len;
if (new_info_len < 0) new_info_len = 0;
if (new_info_len > AX25_MAX_INFO_LEN) new_info_len = AX25_MAX_INFO_LEN;
memcpy (old_info_ptr, new_info_ptr, new_info_len);
this_p->frame_len += new_info_len;
}
/*------------------------------------------------------------------------------
*
* Name: ax25_cut_at_crlf
@ -1892,6 +1905,25 @@ void ax25_set_modulo (packet_t this_p, int modulo)
}
/*------------------------------------------------------------------------------
*
* Name: ax25_get_modulo
*
* Purpose: Get modulo value for I and S frame sequence numbers.
*
* Returns: 8 or 128 if known.
* 0 if unknown.
*
*------------------------------------------------------------------------------*/
int ax25_get_modulo (packet_t this_p)
{
assert (this_p->magic1 == MAGIC);
assert (this_p->magic2 == MAGIC);
return (this_p->modulo);
}
@ -2598,6 +2630,15 @@ int ax25_get_frame_len (packet_t this_p)
} /* end ax25_get_frame_len */
unsigned char *ax25_get_frame_data_ptr (packet_t this_p)
{
assert (this_p->magic1 == MAGIC);
assert (this_p->magic2 == MAGIC);
return (this_p->frame_data);
} /* end ax25_get_frame_data_ptr */
/*------------------------------------------------------------------------------
*

View File

@ -397,6 +397,7 @@ extern int ax25_get_first_not_repeated(packet_t pp);
extern int ax25_get_rr (packet_t this_p, int n);
extern int ax25_get_info (packet_t pp, unsigned char **paddr);
extern void ax25_set_info (packet_t pp, unsigned char *info_ptr, int info_len);
extern int ax25_cut_at_crlf (packet_t this_p);
extern void ax25_set_nextp (packet_t this_p, packet_t next_p);
@ -409,6 +410,7 @@ extern void ax25_set_release_time (packet_t this_p, double release_time);
extern double ax25_get_release_time (packet_t this_p);
extern void ax25_set_modulo (packet_t this_p, int modulo);
extern int ax25_get_modulo (packet_t this_p);
extern void ax25_format_addrs (packet_t pp, char *);
extern void ax25_format_via_path (packet_t this_p, char *result, size_t result_size);
@ -428,6 +430,7 @@ extern int ax25_get_c2 (packet_t this_p);
extern int ax25_get_pid (packet_t this_p);
extern int ax25_get_frame_len (packet_t this_p);
extern unsigned char *ax25_get_frame_data_ptr (packet_t this_p);
extern unsigned short ax25_dedupe_crc (packet_t pp);