/[dynamips]/trunk/utils.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/utils.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

upstream/dynamips-0.2.6-RC3/utils.c revision 4 by dpavlin, Sat Oct 6 16:06:49 2007 UTC upstream/dynamips-0.2.8-RC1/utils.c revision 11 by dpavlin, Sat Oct 6 16:33:40 2007 UTC
# Line 1  Line 1 
1  /*    /*  
2   * Cisco C7200 (Predator) simulation platform.   * Cisco router simulation platform.
3   * Copyright (c) 2005,2006 Christophe Fillot.  All rights reserved.   * Copyright (c) 2005,2006 Christophe Fillot.  All rights reserved.
4   *   *
5   * Utility functions.   * Utility functions.
# Line 208  void mem_dump(FILE *f_output,u_char *pkt Line 208  void mem_dump(FILE *f_output,u_char *pkt
208     }     }
209    
210     fprintf(f_output,"\n");     fprintf(f_output,"\n");
211       fflush(f_output);
212  }  }
213    
214  /* Logging function */  /* Logging function */
# Line 256  char *m_fgets(char *buffer,int size,FILE Line 257  char *m_fgets(char *buffer,int size,FILE
257  }  }
258    
259  /* Read a file and returns it in a buffer */  /* Read a file and returns it in a buffer */
260  ssize_t m_read_file(char *filename,char **buffer)  ssize_t m_read_file(char *filename,u_char **buffer)
261  {  {
262     char tmp[256],*ptr,*nptr;     u_char tmp[256],*ptr,*nptr;
263     size_t len,tot_len;     size_t len,tot_len;
264     FILE *fd;     FILE *fd;
265    
# Line 296  void *m_memalign(size_t boundary,size_t Line 297  void *m_memalign(size_t boundary,size_t
297  {  {
298     void *p;     void *p;
299    
300  #ifdef __linux__  #if defined(__linux__) || HAS_POSIX_MEMALIGN
301     if (posix_memalign((void *)&p,boundary,size))     if (posix_memalign((void *)&p,boundary,size))
302  #else  #else
303  #if defined(__CYGWIN__) || defined(SUNOS)  #if defined(__CYGWIN__) || defined(SUNOS)
# Line 441  m_uint16_t nvram_cksum(m_uint16_t *ptr,s Line 442  m_uint16_t nvram_cksum(m_uint16_t *ptr,s
442    
443     return(~sum);     return(~sum);
444  }  }
445    
446    /* Byte-swap a memory block */
447    void mem_bswap32(void *ptr,size_t len)
448    {
449       m_uint32_t *p = ptr;
450       size_t count = len >> 2;
451       int i;
452    
453       for(i=0;i<count;i++,p++)
454          *p = swap32(*p);
455    }
456    
457    /* Reverse a byte */
458    m_uint8_t m_reverse_u8(m_uint8_t val)
459    {
460       m_uint8_t res = 0;
461       int i;
462    
463       for(i=0;i<8;i++)
464          if (val & (1 << i))
465             res |= 1 << (7 - i);
466      
467       return(res);
468    }

Legend:
Removed from v.4  
changed lines
  Added in v.11

  ViewVC Help
Powered by ViewVC 1.1.26