From Julien Kerihuel, add support for

unaligned unmarshalling of dissectors generated by PIDL.

This will allow us to use PIDL and additional IDLs from the samba 
project since they use "noalign" for certain protocols.


This may also allow us to use PIDL to describe, and machinegenerate 
dissectors for normal, non-DCERPC, protocols.


This patch for PIDL is still under review, but the PIDL patch is l;ikely 
to be committed soonish.




svn path=/trunk/; revision=31583
This commit is contained in:
Ronnie Sahlberg 2010-01-20 06:02:42 +00:00
parent f817636cc6
commit 9a9f7acffe
3 changed files with 18 additions and 14 deletions

View File

@ -129,7 +129,7 @@ dissect_ndr_uint16 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
}
if (offset % 2) {
if (!di->no_align && (offset % 2)) {
offset++;
}
return dissect_dcerpc_uint16 (tvb, offset, pinfo,
@ -151,7 +151,7 @@ PIDL_dissect_uint16 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
}
if (offset % 2) {
if (!di->no_align && (offset % 2)) {
offset++;
}
offset=dissect_dcerpc_uint16 (tvb, offset, pinfo,
@ -207,7 +207,7 @@ dissect_ndr_uint32 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
}
if (offset % 4) {
if (!di->no_align && (offset % 4)) {
offset += 4 - (offset % 4);
}
return dissect_dcerpc_uint32 (tvb, offset, pinfo,
@ -277,7 +277,7 @@ PIDL_dissect_uint32 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
}
if (offset % 4) {
if (!di->no_align && (offset % 4)) {
offset += 4 - (offset % 4);
}
offset=dissect_dcerpc_uint32 (tvb, offset, pinfo,
@ -337,7 +337,7 @@ dissect_ndr_duint32 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
return offset;
}
if (offset % 4) {
if (!di->no_align && (offset % 4)) {
offset += 4 - (offset % 4);
}
return dissect_dcerpc_uint64 (tvb, offset, pinfo,
@ -360,7 +360,7 @@ dissect_ndr_uint64 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
return offset;
}
if (offset % 8) {
if (!di->no_align && (offset % 8)) {
offset += 8 - (offset % 8);
}
return dissect_dcerpc_uint64 (tvb, offset, pinfo,
@ -381,7 +381,7 @@ PIDL_dissect_uint64 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
return offset;
}
if (offset % 8) {
if (!di->no_align && (offset % 8)) {
offset += 8 - (offset % 8);
}
offset=dissect_dcerpc_uint64 (tvb, offset, pinfo,
@ -437,7 +437,7 @@ dissect_ndr_float(tvbuff_t *tvb, gint offset, packet_info *pinfo,
return offset;
}
if (offset % 4) {
if (!di->no_align && (offset % 4)) {
offset += 4 - (offset % 4);
}
return dissect_dcerpc_float(tvb, offset, pinfo,
@ -459,7 +459,7 @@ dissect_ndr_double(tvbuff_t *tvb, gint offset, packet_info *pinfo,
return offset;
}
if (offset % 8) {
if (!di->no_align && (offset % 8)) {
offset += 8 - (offset % 8);
}
return dissect_dcerpc_double(tvb, offset, pinfo,
@ -481,7 +481,7 @@ dissect_ndr_time_t (tvbuff_t *tvb, gint offset, packet_info *pinfo,
}
if (offset % 4) {
if (!di->no_align && (offset % 4)) {
offset += 4 - (offset % 4);
}
return dissect_dcerpc_time_t (tvb, offset, pinfo,
@ -502,7 +502,7 @@ dissect_ndr_uuid_t (tvbuff_t *tvb, gint offset, packet_info *pinfo,
}
/* uuid's are aligned to 4 bytes, due to initial uint32 in struct */
if (offset % 4) {
if (!di->no_align && (offset % 4)) {
offset += 4 - (offset % 4);
}
return dissect_dcerpc_uuid_t (tvb, offset, pinfo,
@ -532,7 +532,7 @@ dissect_ndr_ctx_hnd (tvbuff_t *tvb, gint offset, packet_info *pinfo,
return offset;
}
if (offset % 4) {
if (!di->no_align && (offset % 2)) {
offset += 4 - (offset % 4);
}
ctx_hnd.attributes = dcerpc_tvb_get_ntohl (tvb, offset, drep);

View File

@ -507,6 +507,9 @@ get_next_di(void)
if(di_counter>=20){
di_counter=0;
}
memset(&di[di_counter], 0, sizeof(dcerpc_info));
return &di[di_counter];
}
@ -1428,7 +1431,7 @@ dissect_ndr_cvstring(tvbuff_t *tvb, int offset, packet_info *pinfo,
buffer_len = size_is * (guint32)len;
/* Adjust offset */
if (offset % size_is)
if (!di->no_align && (offset % size_is))
offset += size_is - (offset % size_is);
if (size_is == sizeof(guint16)) {
@ -1615,7 +1618,7 @@ dissect_ndr_vstring(tvbuff_t *tvb, int offset, packet_info *pinfo,
buffer_len = size_is * (guint32)len;
/* Adjust offset */
if (offset % size_is)
if (!di->no_align && (offset % size_is))
offset += size_is - (offset % size_is);
if (size_is == sizeof(guint16)) {

View File

@ -325,6 +325,7 @@ typedef struct _dcerpc_info {
guint16 smb_fid; /* FID for DCERPC over SMB */
guint8 ptype; /* packet type: PDU_REQ, PDU_RESP, ... */
gboolean conformant_run;
gboolean no_align; /* are data aligned? (default yes) */
gint32 conformant_eaten; /* how many bytes did the conformant run eat?*/
guint32 array_max_count; /* max_count for conformant arrays */
guint32 array_max_count_offset;