Przeglądaj źródła

Removes _t suffixes on all of our defined types to respect POSIX recommandations

Julien 'Lta' BALLET 11 lat temu
rodzic
commit
8be75ecde3

+ 2 - 2
bin/discover.c

@@ -29,8 +29,8 @@
 
 int main(int ac, char **av)
 {
-  netbios_ns_t        *ns;
-  netbios_ns_entry_t  *entry;
+  netbios_ns        *ns;
+  netbios_ns_entry  *entry;
 
   ns = netbios_ns_new();
 

+ 6 - 6
bin/dsm.c

@@ -88,8 +88,8 @@ int main(int ac, char **av)
 {
   const char          *pname, *host, *login, *password, *fname;
   struct sockaddr_in  addr;
-  netbios_ns_t        *ns;
-  smb_session_t       *session;
+  netbios_ns        *ns;
+  smb_session       *session;
   int                 argoffset;
 
   pname     = ((pname = strrchr(av[0], '/')) != NULL) ? pname + 1 : av[0];
@@ -113,7 +113,7 @@ int main(int ac, char **av)
   //netbios_ns_discover(ctx->ns);
   //exit(0);
 
-  // netbios_session_t *session;
+  // netbios_session *session;
   // session = netbios_session_new(addr.sin_addr.s_addr);
   // if (netbios_session_connect(session, "Cerbere"))
   //   printf("A NetBIOS session with %s has been established\n", host);
@@ -179,14 +179,14 @@ int main(int ac, char **av)
 
   //char              data[1024];
   char              **share_list;
-  smb_file_t        *files;
+  smb_file        *files;
 
 
   // smb_fread(session, fd, data, 1024);
   // fprintf(stderr, "Read from file:\n%s\n", data);
   // smb_fclose(session, fd);
 
-  if (!smb_share_list(session, &share_list))
+  if (!smb_share_get_list(session, &share_list))
   {
     fprintf(stderr, "Unable to list share for %s\n", host);
     exit(42);
@@ -209,7 +209,7 @@ int main(int ac, char **av)
     fprintf(stderr, "Unable to list files\n");
 
   fprintf(stderr, "Query file info for path: %s\n", fname);
-  files = smb_stat(session, test, fname);
+  files = smb_fstat(session, test, fname);
 
   if (files != NULL)
     printf("File '%s' is %lu bytes long\n", fname, files->size);

+ 1 - 1
bin/inverse.c

@@ -29,7 +29,7 @@
 
 int main(int ac, char **av)
 {
-  netbios_ns_t        *ns;
+  netbios_ns        *ns;
   struct in_addr      addr;
   const char          *name;
 

+ 1 - 1
bin/lookup.c

@@ -29,7 +29,7 @@
 
 int main(int ac, char **av)
 {
-  netbios_ns_t        *ns;
+  netbios_ns        *ns;
   struct in_addr      addr;
 
   ns = netbios_ns_new();

+ 2 - 2
include/bdsm/netbios_defs.h

@@ -60,7 +60,7 @@ typedef struct
   uint16_t                    ns_count;   // Number of authorities (?)
   uint16_t                    ar_count;   // Additionnal (??)
   char                        payload[];
-} __attribute__((packed))   netbios_query_packet_t;
+} __attribute__((packed))   netbios_query_packet;
 
 typedef struct
 {
@@ -69,6 +69,6 @@ typedef struct
                                           // beginning of the length field (!!)
   uint16_t                    length;     // payload length;
   uint8_t                     payload[];
-} __attribute__((packed))   netbios_session_packet_t;
+} __attribute__((packed))   netbios_session_packet;
 
 #endif

+ 20 - 20
include/bdsm/netbios_ns.h

@@ -43,7 +43,7 @@ typedef struct                netbios_ns_entry_s
   struct in_addr                address;
   char                          name[NETBIOS_NAME_LENGTH + 1];
   char                          type;
-}                             netbios_ns_entry_t;
+}                             netbios_ns_entry;
 
 /**
  * @brief Get the name of the entry referenced by the iterator iter.
@@ -52,14 +52,14 @@ typedef struct                netbios_ns_entry_s
  *
  * @return A null-terminated ASCII string representing the name of a netbios machine.
  */
-const char          *netbios_ns_entry_name(netbios_ns_entry_t *entry);
+const char          *netbios_ns_entry_name(netbios_ns_entry *entry);
 
 /**
  * @brief Return the IP address of the correspondance referenced by the iterator
  *
  * @return The ip address of this entry, in network byte order.
  */
-uint32_t            netbios_ns_entry_ip(netbios_ns_entry_t *entry);
+uint32_t            netbios_ns_entry_ip(netbios_ns_entry *entry);
 
 /**
  * @brief Return the type of record
@@ -68,7 +68,7 @@ uint32_t            netbios_ns_entry_ip(netbios_ns_entry_t *entry);
  * 0 for workstation, etc.) or a value < 0 if the iterator is invalid or an
  * error occured.
  */
-char                netbios_ns_entry_type(netbios_ns_entry_t *entry);
+char                netbios_ns_entry_type(netbios_ns_entry *entry);
 
 /**
  * @brief The netbios name service object.
@@ -82,21 +82,21 @@ typedef struct {
   int                 socket;
   struct sockaddr_in  addr;
   uint16_t            last_trn_id;  // Last transaction id used;
-  netbios_ns_entry_t  *entries;     // NS entries cache, mainly used by discover()
-}                   netbios_ns_t;
+  netbios_ns_entry  *entries;     // NS entries cache, mainly used by discover()
+}                   netbios_ns;
 
 /**
  * @brief Allocate and initialize the Netbios name service client object.
- * @return A newly allocated netbios_ns_t ready for querying.
+ * @return A newly allocated netbios_ns ready for querying.
  * Deallocate with netbios_ns_destroy().
  */
-netbios_ns_t  *netbios_ns_new();
+netbios_ns    *netbios_ns_new();
 
 /**
  * @brief Destroy the netbios name service object
- * @param[in] ns A pointer on the netbios_ns_t to destroy and deallocate
+ * @param[in] ns A pointer on the netbios_ns to destroy and deallocate
  */
-void          netbios_ns_destroy(netbios_ns_t *ns);
+void          netbios_ns_destroy(netbios_ns *ns);
 
 /**
  * @brief Resolve a Netbios name
@@ -110,8 +110,8 @@ void          netbios_ns_destroy(netbios_ns_t *ns);
  * @param[out] addr The IP address in network byte order of the machine if found.
  * @return the ipv4 address in network byte-order or 0 if it wasn't successfull.
  */
-int             netbios_ns_resolve(netbios_ns_t *ns, const char *name,
-                                   char type, uint32_t * addr);
+int           netbios_ns_resolve(netbios_ns *ns, const char *name,
+                                 char type, uint32_t * addr);
 
 /**
  * @brief Try to discover all the Netbios/SMB speaking machine on the LAN.
@@ -124,7 +124,7 @@ int             netbios_ns_resolve(netbios_ns_t *ns, const char *name,
  * @param ns The name service object.
  * @return It returns 0 in case of error.
  */
-int           netbios_ns_discover(netbios_ns_t *ns);
+int           netbios_ns_discover(netbios_ns *ns);
 
 /**
  * @brief Get the list of entries (know machine) for this name service object
@@ -133,7 +133,7 @@ int           netbios_ns_discover(netbios_ns_t *ns);
  *
  * @return The list of entries in the name service.
  */
-int             netbios_ns_entry_count(netbios_ns_t *ns);
+int           netbios_ns_entry_count(netbios_ns *ns);
 
 /**
  * @brief Get the entry at a certain position in the entry list
@@ -145,9 +145,9 @@ int             netbios_ns_entry_count(netbios_ns_t *ns);
  * @param ns The nameservice object.
  * @param pos The index/position of the item to access in the list. Must be <
  * netbios_ns_entry_count(ns) or the pointer returned will be NULL.
- * @return A pointer to a opaque netbios_ns_entry_t structure
+ * @return A pointer to a opaque netbios_ns_entry structure
  */
-netbios_ns_entry_t *netbios_ns_entry_at(netbios_ns_t *ns, int pos);
+netbios_ns_entry *netbios_ns_entry_at(netbios_ns *ns, int pos);
 
 /**
  * @brief Perform an inverse netbios lookup (get name from ip)
@@ -161,14 +161,14 @@ netbios_ns_entry_t *netbios_ns_entry_at(netbios_ns_t *ns, int pos);
  * @return A null-terminated ASCII string containing the NETBIOS name. You don't
  * own the it (it'll be freed when destroying/clearing the name service)
  */
-const char          *netbios_ns_inverse(netbios_ns_t *ns, uint32_t ip);
+const char          *netbios_ns_inverse(netbios_ns *ns, uint32_t ip);
 
 /**
  * @brief Clear all the existing entries from the name service
  *
  * @param ns The nameservice object
  */
-void                netbios_ns_clear(netbios_ns_t *ns);
+void                netbios_ns_clear(netbios_ns *ns);
 
 /**
  * @internal
@@ -181,7 +181,7 @@ void                netbios_ns_clear(netbios_ns_t *ns);
  * @param ip The IP address in network byte order (or 0)
  * @return The added entry
  */
-netbios_ns_entry_t  *netbios_ns_entry_add(netbios_ns_t *ns, const char *name,
+netbios_ns_entry    *netbios_ns_entry_add(netbios_ns *ns, const char *name,
                                           char type, uint32_t ip);
 /**
  * @internal
@@ -193,7 +193,7 @@ netbios_ns_entry_t  *netbios_ns_entry_add(netbios_ns_t *ns, const char *name,
  * @param ip [description]
  * @return [description]
  */
-netbios_ns_entry_t  *netbios_ns_entry_find(netbios_ns_t *ns, const char *by_name,
+netbios_ns_entry    *netbios_ns_entry_find(netbios_ns *ns, const char *by_name,
                                            uint32_t ip);
 
 #endif

+ 7 - 7
include/bdsm/netbios_query.h

@@ -27,18 +27,18 @@
 typedef struct              netbios_query_s {
   size_t                      payload_size;
   size_t                      cursor;
-  netbios_query_packet_t      *packet;
-}                           netbios_query_t;
+  netbios_query_packet      *packet;
+}                           netbios_query;
 
-netbios_query_t   *netbios_query_new(size_t payload_size, int is_query,
+netbios_query   *netbios_query_new(size_t payload_size, int is_query,
                                      char opcode);
-void              netbios_query_destroy(netbios_query_t *q);
-void              netbios_query_set_flag(netbios_query_t *q,
+void              netbios_query_destroy(netbios_query *q);
+void              netbios_query_set_flag(netbios_query *q,
                                          uint16_t flag, int value);
-int               netbios_query_append(netbios_query_t *q, const char *data,
+int               netbios_query_append(netbios_query *q, const char *data,
                                        size_t data_size);
 
-void              netbios_query_print(netbios_query_t *q);
+void              netbios_query_print(netbios_query *q);
 
 
 #endif

+ 9 - 9
include/bdsm/netbios_session.h

@@ -49,22 +49,22 @@ typedef struct              netbios_session_s {
   // Where is the write cursor relative to the beginning of the payload
   size_t                      packet_cursor;
   // Our allocated packet, this is where the magic happen :)
-  netbios_session_packet_t    *packet;
+  netbios_session_packet      *packet;
   // Some buffer space to receive message from peer;
   uint8_t                     recv_buffer[NETBIOS_SESSION_BUFFER];
-}                           netbios_session_t;
+}                           netbios_session;
 
 // Return NULL if unable to open socket/connect
-netbios_session_t *netbios_session_new(uint32_t ip_addr);
-void              netbios_session_destroy(netbios_session_t *);
+netbios_session   *netbios_session_new(uint32_t ip_addr);
+void              netbios_session_destroy(netbios_session *);
 
-int               netbios_session_connect(netbios_session_t *s,
+int               netbios_session_connect(netbios_session *s,
                                           const char *name);
-void              netbios_session_packet_init(netbios_session_t *s,
+void              netbios_session_packet_init(netbios_session *s,
                                               uint8_t opcode);
-int               netbios_session_packet_append(netbios_session_t *s,
+int               netbios_session_packet_append(netbios_session *s,
                                                 const char *data, size_t size);
-int               netbios_session_packet_send(netbios_session_t *s);
-ssize_t           netbios_session_packet_recv(netbios_session_t *s);
+int               netbios_session_packet_send(netbios_session *s);
+ssize_t           netbios_session_packet_recv(netbios_session *s);
 
 #endif

+ 6 - 6
include/bdsm/smb_fd.h

@@ -21,12 +21,12 @@
 
 #include "bdsm/smb_session.h"
 
-void            smb_session_share_add(smb_session_t *s, smb_share_t *share);
-smb_share_t     *smb_session_share_get(smb_session_t *s, smb_tid tid);
-smb_share_t     *smb_session_share_remove(smb_session_t *s, smb_tid tid);
+void            smb_session_share_add(smb_session *s, smb_share *share);
+smb_share     *smb_session_share_get(smb_session *s, smb_tid tid);
+smb_share     *smb_session_share_remove(smb_session *s, smb_tid tid);
 
-int             smb_session_file_add(smb_session_t *s, smb_tid tid, smb_file_t *f);
-smb_file_t      *smb_session_file_get(smb_session_t *s, smb_fd fd);
-smb_file_t      *smb_session_file_remove(smb_session_t *s, smb_fd fd);
+int             smb_session_file_add(smb_session *s, smb_tid tid, smb_file *f);
+smb_file      *smb_session_file_get(smb_session *s, smb_fd fd);
+smb_file      *smb_session_file_remove(smb_session *s, smb_fd fd);
 
 #endif

+ 4 - 4
include/bdsm/smb_file.h

@@ -40,7 +40,7 @@
  *
  * @see smb_tree_connect
  */
-smb_fd    smb_fopen(smb_session_t *s, smb_tid tid, const char *path,
+smb_fd    smb_fopen(smb_session *s, smb_tid tid, const char *path,
                     uint32_t mod);
 
 /**
@@ -51,7 +51,7 @@ smb_fd    smb_fopen(smb_session_t *s, smb_tid tid, const char *path,
  * @param s The session object
  * @param fd The SMB file descriptor
  */
-void      smb_fclose(smb_session_t *s, smb_fd fd);
+void      smb_fclose(smb_session *s, smb_fd fd);
 
 /**
  * @brief Read from an open file
@@ -66,7 +66,7 @@ void      smb_fclose(smb_session_t *s, smb_fd fd);
  * @param[in] buf_size [description]
  * @return The number of bytes read or -1 in case of error.
  */
-ssize_t   smb_fread(smb_session_t *s, smb_fd fd, void *buf, size_t buf_size);
+ssize_t   smb_fread(smb_session *s, smb_fd fd, void *buf, size_t buf_size);
 
 /**
  * @brief Sets/Moves/Get the read pointer for a given file
@@ -86,6 +86,6 @@ ssize_t   smb_fread(smb_session_t *s, smb_fd fd, void *buf, size_t buf_size);
  * #SMB_SEEK_SET and #SMB_SEEK_CUR
  * @return The current read pointer position
  */
-ssize_t   smb_fseek(smb_session_t *s, smb_fd fd, ssize_t offset, int whence);
+ssize_t   smb_fseek(smb_session *s, smb_fd fd, ssize_t offset, int whence);
 
 #endif

+ 14 - 14
include/bdsm/smb_message.h

@@ -22,22 +22,22 @@
 #include "bdsm/smb_defs.h"
 #include "bdsm/smb_types.h"
 
-smb_message_t   *smb_message_new(uint8_t cmd, size_t payload_size);
-smb_message_t   *smb_message_grow(smb_message_t *msg, size_t size);
-void            smb_message_destroy(smb_message_t *msg);
-int             smb_message_advance(smb_message_t *msg, size_t size);
-int             smb_message_append(smb_message_t *msg, const void *data,
+smb_message   *smb_message_new(uint8_t cmd, size_t payload_size);
+smb_message   *smb_message_grow(smb_message *msg, size_t size);
+void            smb_message_destroy(smb_message *msg);
+int             smb_message_advance(smb_message *msg, size_t size);
+int             smb_message_append(smb_message *msg, const void *data,
                                    size_t data_size);
-int             smb_message_put8(smb_message_t *msg, uint8_t data);
-int             smb_message_put16(smb_message_t *msg, uint16_t data);
-int             smb_message_put32(smb_message_t *msg, uint32_t data);
-int             smb_message_put64(smb_message_t *msg, uint64_t data);
-size_t          smb_message_put_utf16(smb_message_t *msg, const char *src_enc,
+int             smb_message_put8(smb_message *msg, uint8_t data);
+int             smb_message_put16(smb_message *msg, uint16_t data);
+int             smb_message_put32(smb_message *msg, uint32_t data);
+int             smb_message_put64(smb_message *msg, uint64_t data);
+size_t          smb_message_put_utf16(smb_message *msg, const char *src_enc,
                                       const char *str, size_t str_len);
-int             smb_message_put_uuid(smb_message_t *msg, uint32_t a, uint16_t b,
+int             smb_message_put_uuid(smb_message *msg, uint32_t a, uint16_t b,
                                      uint16_t c, const uint8_t e[8]);
 
-void            smb_message_set_default_flags(smb_message_t *msg);
-void            smb_message_set_andx_members(smb_message_t *msg);
-void            smb_message_flag(smb_message_t *msg, uint32_t flag, int value);
+void            smb_message_set_default_flags(smb_message *msg);
+void            smb_message_set_andx_members(smb_message *msg);
+void            smb_message_flag(smb_message *msg, uint32_t flag, int value);
 #endif

+ 22 - 22
include/bdsm/smb_packets.h

@@ -44,13 +44,13 @@ typedef struct
   uint16_t        pid;          // Process ID.
   uint16_t        uid;          // User ID.
   uint16_t        mux_id;       // Multiplex ID. Increment it sometimes.
-} __attribute__((packed))       smb_header_t;
+} __attribute__((packed))       smb_header;
 
 typedef struct
 {
-  smb_header_t    header;       // A packet header full of gorgeous goodness.
+  smb_header    header;       // A packet header full of gorgeous goodness.
   uint8_t         payload[];    // Ze yummy data inside. Eat 5 fruits/day !
-} __attribute__((packed))       smb_packet_t;
+} __attribute__((packed))       smb_packet;
 
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -63,7 +63,7 @@ typedef struct
   uint16_t        bct;
   char            dialects[];
 
-} __attribute__((packed))   smb_negotiate_req_t;
+} __attribute__((packed))   smb_negotiate_req;
 
 //<- Negotiate Protocol
 typedef struct
@@ -82,7 +82,7 @@ typedef struct
   uint16_t        bct;
   uint64_t        challenge;      // Normally 8 bytes, if not then wtf monkey
   uint8_t         payload[];      // The rest isn't really meaningfull for us
-} __attribute__((packed))   smb_negotiate_resp_t;
+} __attribute__((packed))   smb_negotiate_resp;
 
 
 
@@ -102,7 +102,7 @@ typedef struct
   uint32_t        caps;         // Capabilities
   uint16_t        payload_size;
   uint8_t         payload[];
-} __attribute__((packed))   smb_session_req_t;
+} __attribute__((packed))   smb_session_req;
 
 //<- Session Setup
 typedef struct
@@ -112,7 +112,7 @@ typedef struct
   uint16_t        action;
   uint16_t        bct;
   uint8_t         bullshit[];
-} __attribute__((packed))   smb_session_resp_t;
+} __attribute__((packed))   smb_session_resp;
 
 
 
@@ -126,7 +126,7 @@ typedef struct
   uint16_t        bct;
   uint8_t         payload[];        // Password | Path | Service
 
-} __attribute__((packed))   smb_tree_connect_req_t;
+} __attribute__((packed))   smb_tree_connect_req;
 
 //<- Tree Connect
 typedef struct
@@ -138,7 +138,7 @@ typedef struct
   uint32_t        guest_rights;
   uint16_t        bct;
   uint8_t         payload[];
-} __attribute__((packed))   smb_tree_connect_resp_t;
+} __attribute__((packed))   smb_tree_connect_resp;
 
 
 
@@ -161,7 +161,7 @@ typedef struct
   uint8_t         security_flags;
   uint16_t        bct;
   uint8_t         path[];             // UTF16 Path, starting with '\'
-} __attribute__((packed))   smb_create_req_t;
+} __attribute__((packed))   smb_create_req;
 
 //<- Create File
 typedef struct
@@ -182,7 +182,7 @@ typedef struct
   uint16_t        ipc_state;
   uint8_t         is_dir;
   uint16_t        bct;                // 0
-} __attribute__((packed))   smb_create_resp_t;
+} __attribute__((packed))   smb_create_resp;
 
 
 
@@ -193,7 +193,7 @@ typedef struct
   uint16_t        fid;
   uint32_t        last_write;         // Not defined == 0xffffffff
   uint16_t        bct;                // 0
-} __attribute__((packed))   smb_close_req_t;
+} __attribute__((packed))   smb_close_req;
 
 
 
@@ -210,7 +210,7 @@ typedef struct
   uint16_t        remaining;
   uint32_t        offset_high;        // Continuation of offset field'
   uint16_t        bct;                // 0
-} __attribute__((packed))   smb_read_req_t;
+} __attribute__((packed))   smb_read_req;
 
 //<- Read File
 typedef struct
@@ -228,7 +228,7 @@ typedef struct
   uint16_t        bct;
   uint8_t         padding;
   uint8_t         file[];
-} __attribute__((packed))   smb_read_resp_t;
+} __attribute__((packed))   smb_read_resp;
 
 //-> Trans
 typedef struct
@@ -253,7 +253,7 @@ typedef struct
   uint16_t      fid;
   uint16_t      bct;
   uint8_t       payload[];
-} __attribute__((packed))   smb_trans_req_t;
+} __attribute__((packed))   smb_trans_req;
 
 
 
@@ -282,7 +282,7 @@ typedef struct
   uint16_t      bct;
   uint8_t       padding[3];
   uint8_t       payload[];
-} __attribute__((packed))   smb_trans2_req_t;
+} __attribute__((packed))   smb_trans2_req;
 
 //// -> Trans2|FindFirst2
 typedef struct
@@ -293,7 +293,7 @@ typedef struct
   uint16_t      interest;           // What kind of info do we want ?
   uint32_t      storage;            // ? => 0
   uint8_t       pattern[];          // The queried pattern "\\folder\\*"
-} __attribute__((packed))   smb_tr2_find2_t;
+} __attribute__((packed))   smb_tr2_find2;
 
 //// -> Trans2|QueryPathInfo
 typedef struct
@@ -301,7 +301,7 @@ typedef struct
   uint16_t      interest;
   uint32_t      reserved;
   uint8_t       path[];
-} __attribute__((packed))   smb_tr2_query_t;
+} __attribute__((packed))   smb_tr2_query;
 
 //<- Trans2
 
@@ -322,7 +322,7 @@ typedef struct
   uint16_t      bct;
   uint8_t       padding;
   uint8_t       payload[];
-} __attribute__((packed))   smb_trans2_resp_t;
+} __attribute__((packed))   smb_trans2_resp;
 
 //// <- Trans2|FindFirst2Params
 typedef struct
@@ -333,7 +333,7 @@ typedef struct
   uint16_t      ea_error_offset;
   uint16_t      last_name_offset;
   uint16_t      padding;
-} __attribute__((packed))   smb_tr2_find2_params_t;
+} __attribute__((packed))   smb_tr2_find2_params;
 
 //// <- Trans2|FindFirst2FileInfo
 typedef struct
@@ -353,7 +353,7 @@ typedef struct
   uint8_t       reserved;
   uint8_t       short_name[24];
   uint8_t       name[];
-} __attribute__((packed))   smb_tr2_find2_entry_t;
+} __attribute__((packed))   smb_tr2_find2_entry;
 
 
 //// <- Trans2|QueryPathInfo
@@ -374,7 +374,7 @@ typedef struct
   uint32_t      ea_list_len;
   uint32_t      name_len;
   uint8_t       name[];
-} __attribute__((packed))   smb_tr2_path_info_t;
+} __attribute__((packed))   smb_tr2_path_info;
 
 
 //-> Example

+ 10 - 10
include/bdsm/smb_session.h

@@ -63,7 +63,7 @@
  * call smb_session_connect, then authenticate with smb_authenticate.
  * @return A new Session object.
  */
-smb_session_t   *smb_session_new();
+smb_session   *smb_session_new();
 
 /**
  * @brief Close a session and deallocate its ressources
@@ -72,7 +72,7 @@ smb_session_t   *smb_session_new();
  *
  * @param s The session to destroy
  */
-void            smb_session_destroy(smb_session_t *s);
+void            smb_session_destroy(smb_session *s);
 
 
 /**
@@ -81,17 +81,17 @@ void            smb_session_destroy(smb_session_t *s);
  * @see SMB_STATE_NEW
  * @see SMB_STATE_SESSION_OK
  */
-int             smb_session_state(smb_session_t *s);
+int             smb_session_state(smb_session *s);
 
 
 
 // ---------------------------------
 // Internal stuff, maybe move this somewhere else
-int             smb_negotiate(smb_session_t *s);
-int             smb_session_send_msg(smb_session_t *s, smb_message_t *msg);
+int             smb_negotiate(smb_session *s);
+int             smb_session_send_msg(smb_session *s, smb_message *msg);
 // msg->packet will be updated to point on received data. You don't own this
 // memory. It'll be reused on next recv_msg
-size_t          smb_session_recv_msg(smb_session_t *s, smb_message_t *msg);
+size_t          smb_session_recv_msg(smb_session *s, smb_message *msg);
 // --------------------------------
 
 /**
@@ -106,7 +106,7 @@ size_t          smb_session_recv_msg(smb_session_t *s, smb_message_t *msg);
  * @param ip The ip of the machine to connect to (in network byte order)
  * @return 0 in case of error, a value > 0 otherwise.
  */
-int             smb_session_connect(smb_session_t *s, const char *name,
+int             smb_session_connect(smb_session *s, const char *name,
                                     uint32_t ip);
 
 /**
@@ -124,7 +124,7 @@ int             smb_session_connect(smb_session_t *s, const char *name,
  * you are logged in with the user you requested. If guest are activated on
  * the remote host, when login fails, you are logged in as 'Guest'.
  */
-int             smb_session_login(smb_session_t *s, const char *domain,
+int             smb_session_login(smb_session *s, const char *domain,
                                   const char *user, const char *password);
 
 /**
@@ -135,7 +135,7 @@ int             smb_session_login(smb_session_t *s, const char *domain,
  * 0  -> Logged in as regular user
  * -1 -> Error (not logged in, invalid session, etc.)
  */
-int             smb_session_is_guest(smb_session_t *s);
+int             smb_session_is_guest(smb_session *s);
 
 /**
  * @brief Returns the server name with the <XX> type
@@ -143,6 +143,6 @@ int             smb_session_is_guest(smb_session_t *s);
  * @param s The session object
  * @return The server name or NULL. The memory is owned by the session object.
  */
-const char      *smb_session_server_name(smb_session_t *s);
+const char      *smb_session_server_name(smb_session *s);
 
 #endif

+ 7 - 7
include/bdsm/smb_share.h

@@ -34,12 +34,12 @@
  * starting with a $ are supposed to be system/hidden share.
  *
  * @param[in] s The session object
- * @param[out] list A pointer to an opaque share_list_t object.
+ * @param[out] list A pointer to an opaque share_list object.
  *
  * @return The number of share listed or 0 if there was an error (There
  * theorically cannot be 0 share on a machine, there's at least $IPC)
  */
-size_t          smb_share_list(smb_session_t *s, smb_share_list_t *list);
+size_t          smb_share_get_list(smb_session *s, smb_share_list *list);
 
 /**
  * @brief Get the number of share in the list
@@ -47,7 +47,7 @@ size_t          smb_share_list(smb_session_t *s, smb_share_list_t *list);
  * @param list An opaque share list returned by smb_share_list()
  * @return The number of share in the opaque share_list object
  */
-size_t          smb_share_list_count(smb_share_list_t list);
+size_t          smb_share_list_count(smb_share_list list);
 
 /**
  * @brief Get the name of the share in the list at the given index
@@ -57,7 +57,7 @@ size_t          smb_share_list_count(smb_share_list_t list);
  *
  * @return The string has been decoded from UTF16 to you local encoding
  */
-const char      *smb_share_list_at(smb_share_list_t list, size_t index);
+const char      *smb_share_list_at(smb_share_list list, size_t index);
 
 /**
  * @brief Destroy an opaque share list object
@@ -65,7 +65,7 @@ const char      *smb_share_list_at(smb_share_list_t list, size_t index);
  * @param list The list to destroy. The object is not usable anymore afterward,
  * you can set it to 'NULL'
  */
-void            smb_share_list_destroy(smb_share_list_t list);
+void            smb_share_list_destroy(smb_share_list list);
 
 /**
  * @brief Connects to a SMB share
@@ -79,7 +79,7 @@ void            smb_share_list_destroy(smb_share_list_t list);
  * @return An opaque value representing an open share (like a file descriptor)
  * or 0 if there was an error
  */
-smb_tid         smb_tree_connect(smb_session_t *s, const char *name);
+smb_tid         smb_tree_connect(smb_session *s, const char *name);
 
 /**
  * @brief Disconnect from a share
@@ -87,6 +87,6 @@ smb_tid         smb_tree_connect(smb_session_t *s, const char *name);
  *
  * @return ?
  */
-int             smb_tree_disconnect(smb_session_t *s, smb_tid tid);
+int             smb_tree_disconnect(smb_session *s, smb_tid tid);
 
 #endif

+ 14 - 14
include/bdsm/smb_stat.h

@@ -53,9 +53,9 @@
  * @param pattern The pattern to match files. '\\*' will list all the files at
  * the root of the share. '\\afolder\\*' will list all the files inside of the
  * 'afolder' directory.
- * @return An opaque list of smb_stat_t or NULL in case of error
+ * @return An opaque list of smb_stat or NULL in case of error
  */
-smb_stat_list_t   smb_find(smb_session_t *s, smb_tid tid, const char *pattern);
+smb_stat_list   smb_find(smb_session *s, smb_tid tid, const char *pattern);
 
 /**
  * @brief Get the status of a file from it's path inside of a share
@@ -64,9 +64,9 @@ smb_stat_list_t   smb_find(smb_session_t *s, smb_tid tid, const char *pattern);
  * @param tid The tree id of a share obtained by smb_tree_connect()
  * @param path The full path of the file relative to the root of the share
  * (e.g. '\\folder\\file.ext')
- * @return An opaque smb_stat_t or NULL in case of error
+ * @return An opaque smb_stat or NULL in case of error
  */
-smb_stat_t        smb_stat(smb_session_t *s, smb_tid tid, const char *path);
+smb_stat        smb_fstat(smb_session *s, smb_tid tid, const char *path);
 
 /**
  * @brief Get the status of an open file from it's file descriptor
@@ -75,17 +75,17 @@ smb_stat_t        smb_stat(smb_session_t *s, smb_tid tid, const char *path);
  * @param s The session object
  * @param fd The smb_fd from which you want infos/status
  *
- * @return  An opaque smb_stat_t or NULL in case of error
+ * @return  An opaque smb_stat or NULL in case of error
  */
-smb_stat_t        smb_stat_fd(smb_session_t *s, smb_fd fd);
+smb_stat        smb_stat_fd(smb_session *s, smb_fd fd);
 
 /**
- * @brief Get the number of item in a smb_stat_list_t file info
+ * @brief Get the number of item in a smb_stat_list file info
  *
  * @param list The list you want the length of
  * @return The length of the list. It returns 0 if the list is invalid
  */
-size_t            smb_stat_list_count(smb_stat_list_t list);
+size_t            smb_stat_list_count(smb_stat_list list);
 
 /**
  * @brief Get the element at the given position.
@@ -93,9 +93,9 @@ size_t            smb_stat_list_count(smb_stat_list_t list);
  * @param list A stat list
  * @param index The position of the element you want.
  *
- * @return An opaque smb_stat_t or NULL in case of error
+ * @return An opaque smb_stat or NULL in case of error
  */
-smb_stat_t        smb_stat_list_at(smb_stat_list_t list, size_t index);
+smb_stat        smb_stat_list_at(smb_stat_list list, size_t index);
 
 /**
  * @brief Get the name of the file from its status
@@ -103,15 +103,15 @@ smb_stat_t        smb_stat_list_at(smb_stat_list_t list, size_t index);
  * @param info A file status
  * @return A null-terminated string in you current locale encoding or NULL.
  */
-const char        *smb_stat_name(smb_stat_t info);
+const char        *smb_stat_name(smb_stat info);
 
 /**
  * @brief Get a file attribute
  * @details This function is a getter that allow you to retrieve various
- * informations about a file on a smb_stat_t object. You can get its size,
+ * informations about a file on a smb_stat object. You can get its size,
  * various timestamps, etc.
  *
- * @param info The smb_stat_t object to get info from.
+ * @param info The smb_stat object to get info from.
  * @param what This parameter tells the functions which information to get, can
  * be one of #SMB_STAT_SIZE, #SMB_STAT_ALLOC_SIZE, #SMB_STAT_ISDIR,
  * #SMB_STAT_CTIME, #SMB_STAT_ATIME, #SMB_STAT_MTIME, #SMB_STAT_WTIME.
@@ -119,6 +119,6 @@ const char        *smb_stat_name(smb_stat_t info);
  * @return The meaning of the returned value depends on the 'what' parameter.
  * See each item documentation.
  */
-uint64_t          smb_stat_get(smb_stat_t info, int what);
+uint64_t          smb_stat_get(smb_stat info, int what);
 
 #endif

+ 16 - 16
include/bdsm/smb_types.h

@@ -38,7 +38,7 @@ typedef uint16_t    smb_fid;
 
 // Concatenation of the two above, representing a file inside of a session
 // First 4 bytes are the TreeID (smb_tid), last 4 are the File ID (FUID)
-// A map between smb_fd and smb_file_t is maintained inside each session
+// A map between smb_fd and smb_file is maintained inside each session
 /** @struct smb_fd
   * @brief SMB File descriptor, represents a file within a session.
   */
@@ -46,7 +46,7 @@ typedef uint32_t    smb_fd;
 
 /**
  * @internal
- * @struct smb_file_t
+ * @struct smb_file
  * @brief An opaque data structure to represent file
  */
 typedef struct  smb_file_s
@@ -65,7 +65,7 @@ typedef struct  smb_file_s
   uint32_t            attr;
   uint32_t            readp;          // Current read pointer (position);
   int                 is_dir;         // 0 -> file, 1 -> directory
-} smb_file_t;
+} smb_file;
 
 typedef struct smb_share_s
 {
@@ -75,7 +75,7 @@ typedef struct smb_share_s
   uint16_t            opts;           // Optionnal support opts
   uint16_t            rights;         // Maximum rights field
   uint16_t            guest_rights;
-} smb_share_t;
+} smb_share;
 
 /**
  * @brief An opaque data structure to represent a SMB Session.
@@ -85,7 +85,7 @@ typedef struct
   int                 state;
   int                 guest;            // boolean, are we logged as guest ?
   uint16_t            uid;              // uid attributed by the server
-  netbios_session_t   *nb_session;
+  netbios_session   *nb_session;
 
   // Informations about the smb server we are connected to.
   struct {
@@ -98,38 +98,38 @@ typedef struct
     uint64_t            ts;             // It seems Win7 requires it :-/
   }                   srv;
 
-  struct smb_share_s  *shares;          // shares->files | Map fd <-> smb_file_t
-}                   smb_session_t;
+  struct smb_share_s  *shares;          // shares->files | Map fd <-> smb_file
+}                   smb_session;
 
 /**
- * @struct smb_share_list_t
+ * @struct smb_share_list
  * @brief An opaque object representing the list of share of a SMB file server.
  */
-typedef char  **smb_share_list_t;
+typedef char  **smb_share_list;
 
 /**
- * @struct smb_stat_list_t
+ * @struct smb_stat_list
  * @brief An opaque structure containing a list of file status
  */
-typedef smb_file_t *smb_stat_list_t;
+typedef smb_file *smb_stat_list;
 
 /**
- * @struct smb_stat_t
+ * @struct smb_stat
  * @brief An opaque structure containing info about a file
  */
-typedef smb_file_t *smb_stat_t;
+typedef smb_file *smb_stat;
 
 /**
  * @internal
- * @struct smb_message_t
+ * @struct smb_message
  * @brief A convenience structure used to build smb messages
  */
 typedef struct
 {
   size_t          payload_size; // Size of the allocated payload
   size_t          cursor;       // Write cursor in the payload
-  smb_packet_t    *packet;      // Yummy yummy, Fruity fruity !
-}                               smb_message_t;
+  smb_packet    *packet;      // Yummy yummy, Fruity fruity !
+}                               smb_message;
 
 
 #endif

+ 19 - 19
src/netbios_ns.c

@@ -35,7 +35,7 @@
 #include "bdsm/netbios_utils.h"
 
 
-static int    ns_open_socket(netbios_ns_t *ns)
+static int    ns_open_socket(netbios_ns *ns)
 {
   int sock_opt;
 
@@ -65,12 +65,12 @@ static int    ns_open_socket(netbios_ns_t *ns)
     return (0);
 }
 
-netbios_ns_t  *netbios_ns_new()
+netbios_ns  *netbios_ns_new()
 {
-  netbios_ns_t  *ns;
+  netbios_ns  *ns;
 
-  assert(ns = malloc(sizeof(netbios_ns_t)));
-  memset((void *)ns, 0, sizeof(netbios_ns_t));
+  assert(ns = malloc(sizeof(netbios_ns)));
+  memset((void *)ns, 0, sizeof(netbios_ns));
 
   if (!ns_open_socket(ns))
   {
@@ -84,7 +84,7 @@ netbios_ns_t  *netbios_ns_new()
   return (ns);
 }
 
-void          netbios_ns_destroy(netbios_ns_t *ns)
+void          netbios_ns_destroy(netbios_ns *ns)
 {
   if (!ns)
     return;
@@ -95,7 +95,7 @@ void          netbios_ns_destroy(netbios_ns_t *ns)
   free(ns);
 }
 
-int               netbios_ns_send_query(netbios_ns_t *ns, netbios_query_t *q,
+int               netbios_ns_send_query(netbios_ns *ns, netbios_query *q,
                                         uint32_t ip)
 {
   struct sockaddr_in  addr;
@@ -112,7 +112,7 @@ int               netbios_ns_send_query(netbios_ns_t *ns, netbios_query_t *q,
   addr.sin_port         = htons(NETBIOS_PORT_NAME);
 
   sent = sendto(ns->socket, (void *)q->packet,
-                sizeof(netbios_query_packet_t) + q->cursor, 0,
+                sizeof(netbios_query_packet) + q->cursor, 0,
                 (struct sockaddr *)&addr, sizeof(struct sockaddr_in));
   netbios_query_destroy(q);
 
@@ -158,11 +158,11 @@ ssize_t           netbios_ns_recv(int sock, void *buf, size_t buf_size,
     return (-1);
 }
 
-int      netbios_ns_resolve(netbios_ns_t *ns, const char *name, char type, uint32_t * addr)
+int      netbios_ns_resolve(netbios_ns *ns, const char *name, char type, uint32_t * addr)
 {
-  netbios_ns_entry_t  *cached;
+  netbios_ns_entry  *cached;
   struct timeval      timeout;
-  netbios_query_t     *q;
+  netbios_query     *q;
   char                *encoded_name;
   char                footer[4] = { 0x00, 0x20, 0x00, 0x01 };
   char                recv_buffer[512]; // Hu ?
@@ -223,7 +223,7 @@ int      netbios_ns_resolve(netbios_ns_t *ns, const char *name, char type, uint3
 
 // We have a small recursive function for discovery, to stack received reply
 // when descending, and performing reverse lookup when ascending
-static void   netbios_ns_discover_rec(netbios_ns_t *ns, struct timeval *timeout,
+static void   netbios_ns_discover_rec(netbios_ns *ns, struct timeval *timeout,
                                       void *recv_buffer)
 {
   struct sockaddr_in  recv_addr;
@@ -243,13 +243,13 @@ static void   netbios_ns_discover_rec(netbios_ns_t *ns, struct timeval *timeout,
   }
 }
 
-int           netbios_ns_discover(netbios_ns_t *ns)
+int           netbios_ns_discover(netbios_ns *ns)
 {
   const char  broadcast_name[] = NETBIOS_WILDCARD;
   char        footer[4]        = { 0x00, 0x20, 0x00, 0x01 };
 
   struct timeval      timeout;
-  netbios_query_t     *q;
+  netbios_query     *q;
   char                recv_buffer[256]; // Hu ?
   uint32_t            ip;
 
@@ -292,14 +292,14 @@ int           netbios_ns_discover(netbios_ns_t *ns)
 
 // Perform inverse name resolution. Grap an IP and return the first <20> field
 // returned by the host
-const char        *netbios_ns_inverse(netbios_ns_t *ns, uint32_t ip)
+const char        *netbios_ns_inverse(netbios_ns *ns, uint32_t ip)
 {
   const char  broadcast_name[] = NETBIOS_WILDCARD;
   char        footer[4]        = { 0x00, 0x21, 0x00, 0x01 }; // NBSTAT/IP
 
-  netbios_ns_entry_t  *cached;
+  netbios_ns_entry  *cached;
   struct timeval      timeout;
-  netbios_query_t     *q;
+  netbios_query     *q;
   char                recv_buffer[512]; // Hu ?
   ssize_t             recv;
 
@@ -334,13 +334,13 @@ const char        *netbios_ns_inverse(netbios_ns_t *ns, uint32_t ip)
 
 
   // Now we've got something, let's find the <20>/<0> name
-  netbios_query_packet_t  *p = (netbios_query_packet_t *)recv_buffer;
+  netbios_query_packet  *p = (netbios_query_packet *)recv_buffer;
   uint8_t                 name_count;
   uint8_t                 name_idx;
   char                    *names;
   char                    *current_name;
   char                    current_type;
-  netbios_ns_entry_t      *entry = NULL, *res = NULL;
+  netbios_ns_entry      *entry = NULL, *res = NULL;
 
   BDSM_dbg("Queried name length: %u\n", p->payload[0]);
   name_count = p->payload[p->payload[0] + 12];

+ 16 - 16
src/netbios_ns_entry.c

@@ -23,7 +23,7 @@
 
 #include "bdsm/netbios_ns.h"
 
-const char          *netbios_ns_entry_name(netbios_ns_entry_t *entry)
+const char          *netbios_ns_entry_name(netbios_ns_entry *entry)
 {
   if (entry != NULL)
     return (entry->name);
@@ -31,7 +31,7 @@ const char          *netbios_ns_entry_name(netbios_ns_entry_t *entry)
     return (NULL);
 }
 
-uint32_t            netbios_ns_entry_ip(netbios_ns_entry_t *entry)
+uint32_t            netbios_ns_entry_ip(netbios_ns_entry *entry)
 {
   if (entry != NULL)
     return (entry->address.s_addr);
@@ -39,7 +39,7 @@ uint32_t            netbios_ns_entry_ip(netbios_ns_entry_t *entry)
     return (0);
 }
 
-char                netbios_ns_entry_type(netbios_ns_entry_t *entry)
+char                netbios_ns_entry_type(netbios_ns_entry *entry)
 {
   if (entry != NULL)
     return (entry->type);
@@ -47,9 +47,9 @@ char                netbios_ns_entry_type(netbios_ns_entry_t *entry)
     return (-1);
 }
 
-void                netbios_ns_clear(netbios_ns_t *ns)
+void                netbios_ns_clear(netbios_ns *ns)
 {
-  netbios_ns_entry_t  *next;
+  netbios_ns_entry  *next;
 
   assert(ns != NULL);
 
@@ -61,14 +61,14 @@ void                netbios_ns_clear(netbios_ns_t *ns)
   }
 }
 
-netbios_ns_entry_t *netbios_ns_entry_add(netbios_ns_t *ns, const char *name,
+netbios_ns_entry *netbios_ns_entry_add(netbios_ns *ns, const char *name,
                                          char type, uint32_t ip)
 {
-  netbios_ns_entry_t  *entry;
+  netbios_ns_entry  *entry;
 
-  entry = malloc(sizeof(netbios_ns_entry_t));
+  entry = malloc(sizeof(netbios_ns_entry));
   assert(entry != NULL);
-  memset((void *)entry, 0, sizeof(netbios_ns_entry_t));
+  memset((void *)entry, 0, sizeof(netbios_ns_entry));
 
   if (name != NULL)
   {
@@ -86,11 +86,11 @@ netbios_ns_entry_t *netbios_ns_entry_add(netbios_ns_t *ns, const char *name,
 }
 // Find an entry in the list. Search by name if name is not NULL,
 // or by ip otherwise
-netbios_ns_entry_t *netbios_ns_entry_find(netbios_ns_t *ns, const char *by_name,
+netbios_ns_entry *netbios_ns_entry_find(netbios_ns *ns, const char *by_name,
                                           uint32_t ip)
 {
-  netbios_ns_entry_t  *found = NULL;
-  netbios_ns_entry_t  *iter;
+  netbios_ns_entry  *found = NULL;
+  netbios_ns_entry  *iter;
 
   assert(ns != NULL);
 
@@ -111,9 +111,9 @@ netbios_ns_entry_t *netbios_ns_entry_find(netbios_ns_t *ns, const char *by_name,
   return (found);
 }
 
-int             netbios_ns_entry_count(netbios_ns_t *ns)
+int             netbios_ns_entry_count(netbios_ns *ns)
 {
-  netbios_ns_entry_t  *iter;
+  netbios_ns_entry  *iter;
   int                 res;
 
   assert (ns != NULL);
@@ -129,9 +129,9 @@ int             netbios_ns_entry_count(netbios_ns_t *ns)
   return (res);
 }
 
-netbios_ns_entry_t  *netbios_ns_entry_at(netbios_ns_t *ns, int pos)
+netbios_ns_entry  *netbios_ns_entry_at(netbios_ns *ns, int pos)
 {
-  netbios_ns_entry_t  *iter = NULL;
+  netbios_ns_entry  *iter = NULL;
   int                 i = 0;
 
   assert(ns != NULL);

+ 12 - 12
src/netbios_query.c

@@ -24,18 +24,18 @@
 
 #include "bdsm/netbios_query.h"
 
-netbios_query_t   *netbios_query_new(size_t payload_size,
+netbios_query   *netbios_query_new(size_t payload_size,
                                      int is_query, char opcode)
 {
-  netbios_query_t *q;
+  netbios_query *q;
 
-  q = malloc(sizeof(netbios_query_t));
+  q = malloc(sizeof(netbios_query));
   assert(q);
-  memset((void *)q, 0, sizeof(netbios_query_t));
+  memset((void *)q, 0, sizeof(netbios_query));
 
-  q->packet = malloc(sizeof(netbios_query_packet_t) + payload_size);
+  q->packet = malloc(sizeof(netbios_query_packet) + payload_size);
   assert(q->packet);
-  memset((void *)q->packet, 0, sizeof(netbios_query_packet_t) + payload_size);
+  memset((void *)q->packet, 0, sizeof(netbios_query_packet) + payload_size);
 
   q->payload_size = payload_size;
 
@@ -45,7 +45,7 @@ netbios_query_t   *netbios_query_new(size_t payload_size,
   return (q);
 }
 
-void              netbios_query_destroy(netbios_query_t *q)
+void              netbios_query_destroy(netbios_query *q)
 {
   assert(q);
 
@@ -54,7 +54,7 @@ void              netbios_query_destroy(netbios_query_t *q)
   free(q);
 }
 
-void              netbios_query_set_flag(netbios_query_t *q,
+void              netbios_query_set_flag(netbios_query *q,
                                          uint16_t flag, int value)
 {
   assert(q && q->packet);
@@ -65,16 +65,16 @@ void              netbios_query_set_flag(netbios_query_t *q,
     q->packet->flags = htons(ntohs(q->packet->flags) & ~flag);
 }
 
-void              netbios_query_print(netbios_query_t *q)
+void              netbios_query_print(netbios_query *q)
 {
   assert(q && q->packet);
 
-  printf("--- netbios_query_t dump :\n");
+  printf("--- netbios_query dump :\n");
   printf("payload = %zu, cursor = %zu.\n", q->payload_size, q->cursor);
   printf("Transaction id = %u.\n", q->packet->trn_id);
 
   printf("-------------------------\n");
-  for(unsigned i = 0; i < sizeof(netbios_query_packet_t) + q->cursor; i++)
+  for(unsigned i = 0; i < sizeof(netbios_query_packet) + q->cursor; i++)
   {
     char c;
     if ((i % 8) == 0 && i != 0)
@@ -89,7 +89,7 @@ void              netbios_query_print(netbios_query_t *q)
   printf("-------------------------\n");
 }
 
-int               netbios_query_append(netbios_query_t *q, const char *data,
+int               netbios_query_append(netbios_query *q, const char *data,
                                        size_t data_size)
 {
   assert(q && q->packet);

+ 18 - 18
src/netbios_session.c

@@ -29,7 +29,7 @@
 #include "bdsm/netbios_session.h"
 #include "bdsm/netbios_utils.h"
 
-static int        open_socket_and_connect(netbios_session_t *s)
+static int        open_socket_and_connect(netbios_session *s)
 {
   if ((s->socket = socket(AF_INET, SOCK_STREAM, 0)) < 0)
     goto error;
@@ -43,18 +43,18 @@ static int        open_socket_and_connect(netbios_session_t *s)
     return (0);
 }
 
-netbios_session_t *netbios_session_new(uint32_t ip_addr)
+netbios_session *netbios_session_new(uint32_t ip_addr)
 {
-  netbios_session_t *session;
+  netbios_session *session;
   size_t            packet_size;
 
-  session = (netbios_session_t *)malloc(sizeof(netbios_session_t));
+  session = (netbios_session *)malloc(sizeof(netbios_session));
   assert(session);
-  memset((void *) session, 0, sizeof(netbios_session_t));
+  memset((void *) session, 0, sizeof(netbios_session));
 
   session->packet_payload_size = NETBIOS_SESSION_PAYLOAD;
-  packet_size = sizeof(netbios_session_packet_t) + session->packet_payload_size;
-  session->packet = (netbios_session_packet_t *)malloc(packet_size);
+  packet_size = sizeof(netbios_session_packet) + session->packet_payload_size;
+  session->packet = (netbios_session_packet *)malloc(packet_size);
   assert(session->packet);
 
   session->remote_addr.sin_family       = AF_INET;
@@ -69,7 +69,7 @@ netbios_session_t *netbios_session_new(uint32_t ip_addr)
   return(session);
 }
 
-void              netbios_session_destroy(netbios_session_t *s)
+void              netbios_session_destroy(netbios_session *s)
 {
   if (!s)
     return;
@@ -79,10 +79,10 @@ void              netbios_session_destroy(netbios_session_t *s)
   free(s);
 }
 
-int               netbios_session_connect(netbios_session_t *s,
+int               netbios_session_connect(netbios_session *s,
                                           const char *name)
 {
-  netbios_session_packet_t  *received;
+  netbios_session_packet  *received;
   ssize_t                   recv_size;
   char                      *encoded_name;
 
@@ -103,10 +103,10 @@ int               netbios_session_connect(netbios_session_t *s,
 
   // Now receiving the reply from the server.
   recv_size = netbios_session_packet_recv(s);
-  if (recv_size < sizeof(netbios_session_packet_t))
+  if (recv_size < sizeof(netbios_session_packet))
     goto error;
 
-  received = (netbios_session_packet_t *)&s->recv_buffer;
+  received = (netbios_session_packet *)&s->recv_buffer;
   // Reply was negative, we are not connected :(
   if (received->opcode != NETBIOS_OP_SESSION_REQ_OK)
   {
@@ -123,21 +123,21 @@ int               netbios_session_connect(netbios_session_t *s,
     return (0);
 }
 
-void              netbios_session_packet_init(netbios_session_t *s,
+void              netbios_session_packet_init(netbios_session *s,
                                               uint8_t opcode)
 {
   size_t          packet_size;
 
   assert(s);
 
-  packet_size = s->packet_payload_size + sizeof(netbios_session_packet_t);
+  packet_size = s->packet_payload_size + sizeof(netbios_session_packet);
   memset((void *)s->packet, 0, packet_size);
 
   s->packet_cursor = 0;
   s->packet->opcode = opcode;
 }
 
-int               netbios_session_packet_append(netbios_session_t *s,
+int               netbios_session_packet_append(netbios_session *s,
                                                 const char *data, size_t size)
 {
   char  *start;
@@ -154,7 +154,7 @@ int               netbios_session_packet_append(netbios_session_t *s,
   return (1);
 }
 
-int               netbios_session_packet_send(netbios_session_t *s)
+int               netbios_session_packet_send(netbios_session *s)
 {
   ssize_t         to_send;
   ssize_t         sent;
@@ -162,7 +162,7 @@ int               netbios_session_packet_send(netbios_session_t *s)
   assert(s && s->packet && s->socket && s->state > 0);
 
   s->packet->length = htons(s->packet_cursor);
-  to_send           = sizeof(netbios_session_packet_t) + s->packet_cursor;
+  to_send           = sizeof(netbios_session_packet) + s->packet_cursor;
   sent              = send(s->socket, (void *)s->packet, to_send, 0);
 
   if (sent != to_send)
@@ -174,7 +174,7 @@ int               netbios_session_packet_send(netbios_session_t *s)
   return (sent);
 }
 
-ssize_t           netbios_session_packet_recv(netbios_session_t *s)
+ssize_t           netbios_session_packet_recv(netbios_session *s)
 {
   assert(s && s->socket && s->state > 0);
 

+ 15 - 15
src/smb_fd.c

@@ -20,9 +20,9 @@
 
 #include "bdsm/smb_fd.h"
 
-void        smb_session_share_add(smb_session_t *s, smb_share_t *share)
+void        smb_session_share_add(smb_session *s, smb_share *share)
 {
-  smb_share_t *iter;
+  smb_share *iter;
 
   assert(s != NULL && share != NULL);
 
@@ -38,9 +38,9 @@ void        smb_session_share_add(smb_session_t *s, smb_share_t *share)
   iter->next = share;
 }
 
-smb_share_t *smb_session_share_get(smb_session_t *s, smb_tid tid)
+smb_share *smb_session_share_get(smb_session *s, smb_tid tid)
 {
-  smb_share_t *iter;
+  smb_share *iter;
 
   assert(s != NULL && tid);
 
@@ -51,9 +51,9 @@ smb_share_t *smb_session_share_get(smb_session_t *s, smb_tid tid)
   return (iter);
 }
 
-smb_share_t *smb_session_share_remove(smb_session_t *s, smb_tid tid)
+smb_share *smb_session_share_remove(smb_session *s, smb_tid tid)
 {
-  smb_share_t *iter, *keep;
+  smb_share *iter, *keep;
 
   assert(s != NULL && tid);
   iter = s->shares;
@@ -78,10 +78,10 @@ smb_share_t *smb_session_share_remove(smb_session_t *s, smb_tid tid)
   return (NULL);
 }
 
-int         smb_session_file_add(smb_session_t *s, smb_tid tid, smb_file_t *f)
+int         smb_session_file_add(smb_session *s, smb_tid tid, smb_file *f)
 {
-  smb_share_t *share;
-  smb_file_t  *iter;
+  smb_share *share;
+  smb_file  *iter;
 
   assert(s != NULL && tid && f != NULL);
 
@@ -101,10 +101,10 @@ int         smb_session_file_add(smb_session_t *s, smb_tid tid, smb_file_t *f)
   return (1);
 }
 
-smb_file_t  *smb_session_file_get(smb_session_t *s, smb_fd fd)
+smb_file  *smb_session_file_get(smb_session *s, smb_fd fd)
 {
-  smb_share_t *share;
-  smb_file_t  *iter;
+  smb_share *share;
+  smb_file  *iter;
 
   assert(s != NULL && fd);
 
@@ -118,10 +118,10 @@ smb_file_t  *smb_session_file_get(smb_session_t *s, smb_fd fd)
   return (iter);
 }
 
-smb_file_t  *smb_session_file_remove(smb_session_t *s, smb_fd fd)
+smb_file  *smb_session_file_remove(smb_session *s, smb_fd fd)
 {
-  smb_share_t *share;
-  smb_file_t  *iter, *keep;
+  smb_share *share;
+  smb_file  *iter, *keep;
 
   assert(s != NULL && fd);
 

+ 26 - 26
src/smb_file.c

@@ -26,14 +26,14 @@
 #include "bdsm/smb_utils.h"
 #include "bdsm/smb_file.h"
 
-smb_fd      smb_fopen(smb_session_t *s, smb_tid tid, const char *path,
+smb_fd      smb_fopen(smb_session *s, smb_tid tid, const char *path,
                       uint32_t o_flags)
 {
-  smb_share_t       *share;
-  smb_file_t        *file;
-  smb_message_t     *req_msg, resp_msg;
-  smb_create_req_t  *req;
-  smb_create_resp_t *resp;
+  smb_share       *share;
+  smb_file        *file;
+  smb_message     *req_msg, resp_msg;
+  smb_create_req  *req;
+  smb_create_resp *resp;
   size_t            path_len;
   int               res;
 
@@ -49,7 +49,7 @@ smb_fd      smb_fopen(smb_session_t *s, smb_tid tid, const char *path,
   req_msg->packet->header.tid = tid;
 
   // Create AndX Params
-  req = (smb_create_req_t *)req_msg->packet->payload;
+  req = (smb_create_req *)req_msg->packet->payload;
   req->wct            = 24;
   req->flags          = 0;
   req->root_fid       = 0;
@@ -63,7 +63,7 @@ smb_fd      smb_fopen(smb_session_t *s, smb_tid tid, const char *path,
   req->security_flags = 0;  // ???
 
   // Create AndX 'Body'
-  smb_message_advance(req_msg, sizeof(smb_create_req_t));
+  smb_message_advance(req_msg, sizeof(smb_create_req));
   smb_message_put8(req_msg, 0);   // Align beginning of path
   path_len = smb_message_put_utf16(req_msg, "", path, strlen(path) + 1);
   // smb_message_put16(req_msg, 0);  // ??
@@ -80,8 +80,8 @@ smb_fd      smb_fopen(smb_session_t *s, smb_tid tid, const char *path,
   if (resp_msg.packet->header.status != NT_STATUS_SUCCESS)
     return (0);
 
-  resp = (smb_create_resp_t *)resp_msg.packet->payload;
-  file = calloc(1, sizeof(smb_file_t));
+  resp = (smb_create_resp *)resp_msg.packet->payload;
+  file = calloc(1, sizeof(smb_file));
   assert(file != NULL);
 
   file->fid           = resp->fid;
@@ -100,11 +100,11 @@ smb_fd      smb_fopen(smb_session_t *s, smb_tid tid, const char *path,
   return (SMB_FD(tid, file->fid));
 }
 
-void        smb_fclose(smb_session_t *s, smb_fd fd)
+void        smb_fclose(smb_session *s, smb_fd fd)
 {
-  smb_file_t        *file;
-  smb_message_t     *msg;
-  smb_close_req_t   *req;
+  smb_file        *file;
+  smb_message     *msg;
+  smb_close_req   *req;
 
   assert(s != NULL && fd);
 
@@ -113,11 +113,11 @@ void        smb_fclose(smb_session_t *s, smb_fd fd)
     return;
 
   msg = smb_message_new(SMB_CMD_CLOSE, 64);
-  req = (smb_close_req_t *)msg->packet->payload;
+  req = (smb_close_req *)msg->packet->payload;
 
   msg->packet->header.tid = SMB_FD_TID(fd);
 
-  smb_message_advance(msg, sizeof(smb_close_req_t));
+  smb_message_advance(msg, sizeof(smb_close_req));
   req->wct        = 3;
   req->fid        = SMB_FD_FID(fd);
   req->last_write = ~0;
@@ -129,12 +129,12 @@ void        smb_fclose(smb_session_t *s, smb_fd fd)
   smb_session_recv_msg(s, 0);
 }
 
-ssize_t   smb_fread(smb_session_t *s, smb_fd fd, void *buf, size_t buf_size)
+ssize_t   smb_fread(smb_session *s, smb_fd fd, void *buf, size_t buf_size)
 {
-  smb_file_t        *file;
-  smb_message_t     *req_msg, resp_msg;
-  smb_read_req_t    *req;
-  smb_read_resp_t   *resp;
+  smb_file        *file;
+  smb_message     *req_msg, resp_msg;
+  smb_read_req    *req;
+  smb_read_resp   *resp;
   size_t            max_read;
   int               res;
 
@@ -146,12 +146,12 @@ ssize_t   smb_fread(smb_session_t *s, smb_fd fd, void *buf, size_t buf_size)
   req_msg->packet->header.tid = file->tid;
   smb_message_set_default_flags(req_msg);
   smb_message_set_andx_members(req_msg);
-  smb_message_advance(req_msg, sizeof(smb_read_req_t));
+  smb_message_advance(req_msg, sizeof(smb_read_req));
 
   max_read = NETBIOS_SESSION_BUFFER - 256; // XXX
   max_read = max_read < buf_size ? max_read : buf_size;
 
-  req = (smb_read_req_t *)req_msg->packet->payload;
+  req = (smb_read_req *)req_msg->packet->payload;
   req->wct              = 12;
   req->fid              = file->fid;
   req->offset           = file->readp;
@@ -172,16 +172,16 @@ ssize_t   smb_fread(smb_session_t *s, smb_fd fd, void *buf, size_t buf_size)
   if (resp_msg.packet->header.status != NT_STATUS_SUCCESS)
     return (-1);
 
-  resp = (smb_read_resp_t *)resp_msg.packet->payload;
+  resp = (smb_read_resp *)resp_msg.packet->payload;
   memcpy(buf, resp->file, resp->data_len);
   smb_fseek(s, fd, resp->data_len, SEEK_CUR);
 
   return (resp->data_len);
 }
 
-ssize_t   smb_fseek(smb_session_t *s, smb_fd fd, ssize_t offset, int whence)
+ssize_t   smb_fseek(smb_session *s, smb_fd fd, ssize_t offset, int whence)
 {
-  smb_file_t  *file;
+  smb_file  *file;
 
   assert(s != NULL);
 

+ 22 - 22
src/smb_message.c

@@ -27,15 +27,15 @@
 #include "bdsm/smb_message.h"
 #include "bdsm/smb_utils.h"
 
-smb_message_t   *smb_message_new(uint8_t cmd, size_t payload_size)
+smb_message   *smb_message_new(uint8_t cmd, size_t payload_size)
 {
   const char    magic[4] = SMB_MAGIC;
-  smb_message_t *msg;
+  smb_message *msg;
 
-  msg = (smb_message_t *)calloc(1, sizeof(smb_message_t));
+  msg = (smb_message *)calloc(1, sizeof(smb_message));
   assert(msg != NULL);
 
-  msg->packet = (smb_packet_t *)calloc(1, sizeof(smb_message_t) + payload_size);
+  msg->packet = (smb_packet *)calloc(1, sizeof(smb_message) + payload_size);
   assert(msg != NULL);
 
   msg->payload_size = payload_size;
@@ -50,25 +50,25 @@ smb_message_t   *smb_message_new(uint8_t cmd, size_t payload_size)
 }
 
 // Duplicate a message while growing payload_size.
-smb_message_t   *smb_message_grow(smb_message_t *msg, size_t size)
+smb_message   *smb_message_grow(smb_message *msg, size_t size)
 {
-  smb_message_t *copy;
+  smb_message *copy;
 
   assert(msg != NULL && msg->packet != NULL);
 
-  copy = malloc(sizeof(smb_message_t));
+  copy = malloc(sizeof(smb_message));
   assert(copy != NULL);
   copy->cursor        = msg->cursor;
   copy->payload_size  = msg->payload_size + size;
 
-  copy->packet = malloc(sizeof(smb_packet_t) + copy->payload_size);
+  copy->packet = malloc(sizeof(smb_packet) + copy->payload_size);
   assert(copy->packet != NULL);
   memcpy((void *)copy->packet, (void *)msg->packet, msg->payload_size);
 
   return (copy);
 }
 
-void            smb_message_destroy(smb_message_t *msg)
+void            smb_message_destroy(smb_message *msg)
 {
   if (msg != NULL)
   {
@@ -78,7 +78,7 @@ void            smb_message_destroy(smb_message_t *msg)
   }
 }
 
-int             smb_message_append(smb_message_t *msg, const void *data,
+int             smb_message_append(smb_message *msg, const void *data,
                                    size_t data_size)
 {
   assert(msg != NULL && data != NULL);
@@ -94,7 +94,7 @@ int             smb_message_append(smb_message_t *msg, const void *data,
   return (1);
 }
 
-int             smb_message_advance(smb_message_t *msg, size_t size)
+int             smb_message_advance(smb_message *msg, size_t size)
 {
   assert(msg != NULL);
 
@@ -107,27 +107,27 @@ int             smb_message_advance(smb_message_t *msg, size_t size)
   return (1);
 }
 
-int             smb_message_put8(smb_message_t *msg, uint8_t data)
+int             smb_message_put8(smb_message *msg, uint8_t data)
 {
   return(smb_message_append(msg, (void *)&data, 1));
 }
 
-int             smb_message_put16(smb_message_t *msg, uint16_t data)
+int             smb_message_put16(smb_message *msg, uint16_t data)
 {
     return(smb_message_append(msg, (void *)&data, 2));
 }
 
-int             smb_message_put32(smb_message_t *msg, uint32_t data)
+int             smb_message_put32(smb_message *msg, uint32_t data)
 {
     return(smb_message_append(msg, (void *)&data, 4));
 }
 
-int             smb_message_put64(smb_message_t *msg, uint64_t data)
+int             smb_message_put64(smb_message *msg, uint64_t data)
 {
     return(smb_message_append(msg, (void *)&data, 8));
 }
 
-size_t          smb_message_put_utf16(smb_message_t *msg, const char *src_enc,
+size_t          smb_message_put_utf16(smb_message *msg, const char *src_enc,
                                       const char *str, size_t str_len)
 {
   char          *utf_str;
@@ -146,7 +146,7 @@ size_t          smb_message_put_utf16(smb_message_t *msg, const char *src_enc,
   return (0);
 }
 
-int             smb_message_put_uuid(smb_message_t *msg, uint32_t a, uint16_t b,
+int             smb_message_put_uuid(smb_message *msg, uint32_t a, uint16_t b,
                                      uint16_t c, const uint8_t d[8])
 {
   assert(msg != NULL);
@@ -164,7 +164,7 @@ int             smb_message_put_uuid(smb_message_t *msg, uint32_t a, uint16_t b,
   return (1);
 }
 
-void            smb_message_flag(smb_message_t *msg, uint32_t flag, int value)
+void            smb_message_flag(smb_message *msg, uint32_t flag, int value)
 {
   uint32_t      *flags;
 
@@ -180,7 +180,7 @@ void            smb_message_flag(smb_message_t *msg, uint32_t flag, int value)
     *flags &= ~flag;
 }
 
-void            smb_message_set_default_flags(smb_message_t *msg)
+void            smb_message_set_default_flags(smb_message *msg)
 {
   assert(msg != NULL && msg->packet != NULL);
 
@@ -189,14 +189,14 @@ void            smb_message_set_default_flags(smb_message_t *msg)
   msg->packet->header.flags2  = 0xc043; // w/o extended security;
 }
 
-void            smb_message_set_andx_members(smb_message_t *msg)
+void            smb_message_set_andx_members(smb_message *msg)
 {
   // This could have been any type with the 'SMB_ANDX_MEMBERS';
-  smb_session_req_t   *req;
+  smb_session_req   *req;
 
   assert(msg != NULL);
 
-  req = (smb_session_req_t *)msg->packet->payload;
+  req = (smb_session_req *)msg->packet->payload;
   req->andx           = 0xff;
   req->andx_reserved  = 0;
   req->andx_offset    = 0;

+ 36 - 36
src/smb_session.c

@@ -25,18 +25,18 @@
 #include "bdsm/smb_session.h"
 #include "bdsm/smb_ntlm.h"
 
-smb_session_t   *smb_session_new()
+smb_session   *smb_session_new()
 {
-  smb_session_t *s;
+  smb_session *s;
 
-  s = malloc(sizeof(smb_session_t));
+  s = malloc(sizeof(smb_session));
   assert(s != NULL);
-  memset((void *)s, 0, sizeof(smb_session_t));
+  memset((void *)s, 0, sizeof(smb_session));
 
   return (s);
 }
 
-void            smb_session_destroy(smb_session_t *s)
+void            smb_session_destroy(smb_session *s)
 {
   if (s != NULL)
   {
@@ -47,7 +47,7 @@ void            smb_session_destroy(smb_session_t *s)
   }
 }
 
-int             smb_session_state(smb_session_t *s)
+int             smb_session_state(smb_session *s)
 {
   if (s != NULL)
     return (s->state);
@@ -55,7 +55,7 @@ int             smb_session_state(smb_session_t *s)
     return (SMB_STATE_ERROR);
 }
 
-int             smb_session_connect(smb_session_t *s, const char *name,
+int             smb_session_connect(smb_session *s, const char *name,
                                     uint32_t ip)
 {
   assert(s != NULL && name != NULL);
@@ -78,7 +78,7 @@ int             smb_session_connect(smb_session_t *s, const char *name,
     return (0);
 }
 
-int             smb_session_send_msg(smb_session_t *s, smb_message_t *msg)
+int             smb_session_send_msg(smb_session *s, smb_message *msg)
 {
   size_t        packet_size;
 
@@ -89,7 +89,7 @@ int             smb_session_send_msg(smb_session_t *s, smb_message_t *msg)
 
   netbios_session_packet_init(s->nb_session, NETBIOS_OP_SESSION_MSG);
 
-  packet_size   = sizeof(smb_packet_t) + msg->cursor;
+  packet_size   = sizeof(smb_packet) + msg->cursor;
   if (!netbios_session_packet_append(s->nb_session, (char *)msg->packet, packet_size))
     return (0);
   if (!netbios_session_packet_send(s->nb_session))
@@ -98,9 +98,9 @@ int             smb_session_send_msg(smb_session_t *s, smb_message_t *msg)
   return (1);
 }
 
-size_t          smb_session_recv_msg(smb_session_t *s, smb_message_t *msg)
+size_t          smb_session_recv_msg(smb_session *s, smb_message *msg)
 {
-  netbios_session_packet_t  *nb_packet;
+  netbios_session_packet  *nb_packet;
   ssize_t                   recv_size;
   size_t                    payload_size;
 
@@ -110,13 +110,13 @@ size_t          smb_session_recv_msg(smb_session_t *s, smb_message_t *msg)
   if(recv_size <= 0)
     return (0);
 
-  nb_packet   = (netbios_session_packet_t *)s->nb_session->recv_buffer;
+  nb_packet   = (netbios_session_packet *)s->nb_session->recv_buffer;
   if (msg != NULL)
-    msg->packet = (smb_packet_t *)nb_packet->payload;
+    msg->packet = (smb_packet *)nb_packet->payload;
 
   payload_size  = ntohs(nb_packet->length);
   payload_size |= (nb_packet->flags & 0x01) << 16; // XXX If this is the case we overran our recv_buffer
-  if (payload_size > recv_size - sizeof(netbios_session_packet_t))
+  if (payload_size > recv_size - sizeof(netbios_session_packet))
   {
     BDSM_dbg("smb_session_recv_msg: Packet size mismatch\n");
     return(0);
@@ -124,20 +124,20 @@ size_t          smb_session_recv_msg(smb_session_t *s, smb_message_t *msg)
 
   if (msg != NULL)
   {
-    msg->payload_size = payload_size - sizeof(smb_header_t);
+    msg->payload_size = payload_size - sizeof(smb_header);
     msg->cursor       = 0;
   }
 
-  return (payload_size - sizeof(smb_header_t));
+  return (payload_size - sizeof(smb_header));
 }
 
 
-int             smb_negotiate(smb_session_t *s)
+int             smb_negotiate(smb_session *s)
 {
   const char            *dialects[] = SMB_DIALECTS;
-  smb_message_t         *msg = NULL;
-  smb_message_t         answer;
-  smb_negotiate_resp_t  *nego;
+  smb_message         *msg = NULL;
+  smb_message         answer;
+  smb_negotiate_resp  *nego;
 
 
   msg = smb_message_new(SMB_CMD_NEGOTIATE, 64);
@@ -160,7 +160,7 @@ int             smb_negotiate(smb_session_t *s)
   if (!smb_session_recv_msg(s, &answer))
     goto error;
 
-  nego = (smb_negotiate_resp_t *)answer.packet->payload;
+  nego = (smb_negotiate_resp *)answer.packet->payload;
   if (answer.packet->header.status != NT_STATUS_SUCCESS
       && nego->wct != 0x11 && nego->security_mode & 0x03)
     goto error;
@@ -182,12 +182,12 @@ int             smb_negotiate(smb_session_t *s)
     return (0);
 }
 
-int             smb_session_login(smb_session_t *s, const char *domain,
+int             smb_session_login(smb_session *s, const char *domain,
                                   const char *user, const char *password)
 {
-  smb_message_t         answer;
-  smb_message_t         *msg = NULL;
-  smb_session_req_t     *req = NULL;
+  smb_message         answer;
+  smb_message         *msg = NULL;
+  smb_session_req     *req = NULL;
   uint8_t               *ntlm2 = NULL;
   smb_ntlmh_t           hash_v2;
   uint64_t              user_challenge;
@@ -197,20 +197,20 @@ int             smb_session_login(smb_session_t *s, const char *domain,
   msg = smb_message_new(SMB_CMD_SETUP, 512);
   smb_message_set_default_flags(msg);
   smb_message_set_andx_members(msg);
-  req = (smb_session_req_t *)msg->packet->payload;
+  req = (smb_session_req *)msg->packet->payload;
 
-  req->wct              = (sizeof(smb_session_req_t) - 3) / 2;
+  req->wct              = (sizeof(smb_session_req) - 3) / 2;
   req->max_buffer       = NETBIOS_SESSION_PAYLOAD
-                          - sizeof(smb_header_t)
-                          - sizeof(netbios_session_packet_t);
-  req->max_buffer      -= sizeof(netbios_session_packet_t);
-  req->max_buffer      -= sizeof(smb_packet_t);
+                          - sizeof(smb_header)
+                          - sizeof(netbios_session_packet);
+  req->max_buffer      -= sizeof(netbios_session_packet);
+  req->max_buffer      -= sizeof(smb_packet);
   req->mpx_count        = 16; // XXX ?
   req->vc_count         = 1;
   req->session_key      = s->srv.session_key;
   req->caps             = s->srv.caps; // XXX caps & our_caps_mask
 
-  smb_message_advance(msg, sizeof(smb_session_req_t));
+  smb_message_advance(msg, sizeof(smb_session_req));
 
   user_challenge = smb_ntlm_generate_challenge();
 
@@ -242,7 +242,7 @@ int             smb_session_login(smb_session_t *s, const char *domain,
   smb_message_put_utf16(msg, "", SMB_LANMAN, strlen(SMB_OS));
   smb_message_put16(msg, 0);
 
-  req->payload_size = msg->cursor - sizeof(smb_session_req_t);
+  req->payload_size = msg->cursor - sizeof(smb_session_req);
 
   if (!smb_session_send_msg(s, msg))
   {
@@ -258,7 +258,7 @@ int             smb_session_login(smb_session_t *s, const char *domain,
     return (0);
   }
 
-  smb_session_resp_t *r = (smb_session_resp_t *)answer.packet->payload;
+  smb_session_resp *r = (smb_session_resp *)answer.packet->payload;
   if (answer.packet->header.status != NT_STATUS_SUCCESS)
   {
     BDSM_dbg("Session Setup AndX : failure.\n");
@@ -273,7 +273,7 @@ int             smb_session_login(smb_session_t *s, const char *domain,
   return (1);
 }
 
-int             smb_session_is_guest(smb_session_t *s)
+int             smb_session_is_guest(smb_session *s)
 {
   // Invalid session object
   if (s == NULL)
@@ -291,7 +291,7 @@ int             smb_session_is_guest(smb_session_t *s)
   return (0);
 }
 
-const char      *smb_session_server_name(smb_session_t *s)
+const char      *smb_session_server_name(smb_session *s)
 {
   if (s == NULL)
     return (NULL);

+ 25 - 25
src/smb_share.c

@@ -29,13 +29,13 @@
 #include "bdsm/smb_file.h"
 
 
-smb_tid         smb_tree_connect(smb_session_t *s, const char *name)
+smb_tid         smb_tree_connect(smb_session *s, const char *name)
 {
-  smb_tree_connect_req_t  *req;
-  smb_tree_connect_resp_t *resp;
-  smb_message_t   resp_msg;
-  smb_message_t   *req_msg;
-  smb_share_t     *share;
+  smb_tree_connect_req  *req;
+  smb_tree_connect_resp *resp;
+  smb_message   resp_msg;
+  smb_message   *req_msg;
+  smb_share     *share;
   size_t          path_len;
   char            *path;
 
@@ -54,8 +54,8 @@ smb_tid         smb_tree_connect(smb_session_t *s, const char *name)
   req_msg->packet->header.tid   = 0xffff; // Behavior of libsmbclient
 
   // Packet payload
-  req = (smb_tree_connect_req_t *)req_msg->packet->payload;
-  smb_message_advance(req_msg, sizeof(smb_tree_connect_req_t));
+  req = (smb_tree_connect_req *)req_msg->packet->payload;
+  smb_message_advance(req_msg, sizeof(smb_tree_connect_req));
   req->wct          = 4;
   req->flags        = 0x0c; // (??)
   req->passwd_len   = 1;    // Null byte
@@ -77,8 +77,8 @@ smb_tid         smb_tree_connect(smb_session_t *s, const char *name)
   if (resp_msg.packet->header.status != NT_STATUS_SUCCESS)
     return (0);
 
-  resp  = (smb_tree_connect_resp_t *)resp_msg.packet->payload;
-  share = calloc(1, sizeof(smb_share_t));
+  resp  = (smb_tree_connect_resp *)resp_msg.packet->payload;
+  share = calloc(1, sizeof(smb_share));
   assert(share != NULL);
 
   share->tid          = resp_msg.packet->header.tid;
@@ -91,7 +91,7 @@ smb_tid         smb_tree_connect(smb_session_t *s, const char *name)
   return(share->tid);
 }
 
-int           smb_tree_disconnect(smb_session_t *s, smb_tid tid)
+int           smb_tree_disconnect(smb_session *s, smb_tid tid)
 {
   assert(s != NULL && tid);
   BDSM_dbg("smb_tree_disconnect: NOT IMPLEMENTED YET\n");
@@ -100,7 +100,7 @@ int           smb_tree_disconnect(smb_session_t *s, smb_tid tid)
 
 // Here we parse the NetShareEnumAll response packet payload to extract
 // The share list.
-static size_t   smb_share_parse_enum(smb_message_t *msg, char ***list)
+static size_t   smb_share_parse_enum(smb_message *msg, char ***list)
 {
   uint32_t          share_count, i;
   uint8_t           *data, *eod;
@@ -137,7 +137,7 @@ static size_t   smb_share_parse_enum(smb_message_t *msg, char ***list)
   return (i);
 }
 
-size_t          smb_share_list_count(smb_share_list_t list)
+size_t          smb_share_list_count(smb_share_list list)
 {
   size_t        res;
 
@@ -150,14 +150,14 @@ size_t          smb_share_list_count(smb_share_list_t list)
   return (res);
 }
 
-const char      *smb_share_list_at(smb_share_list_t list, size_t index)
+const char      *smb_share_list_at(smb_share_list list, size_t index)
 {
   assert (list != NULL);
 
   return (list[index]);
 }
 
-void            smb_share_list_destroy(smb_share_list_t list)
+void            smb_share_list_destroy(smb_share_list list)
 {
   assert(list != NULL);
 
@@ -169,10 +169,10 @@ void            smb_share_list_destroy(smb_share_list_t list)
 // We should normally implement SCERPC and SRVSVC to perform a share list. But
 // since these two protocols have no other use for us, we'll do it the trash way
 // PS: Worst function _EVER_. I don't understand a bit myself
-size_t          smb_share_list(smb_session_t *s, char ***list)
+size_t          smb_share_get_list(smb_session *s, char ***list)
 {
-  smb_message_t         *req, resp;
-  smb_trans_req_t       *trans;
+  smb_message         *req, resp;
+  smb_trans_req       *trans;
   smb_tid               ipc_tid;
   smb_fd                srvscv_fd;
   uint16_t              rpc_len;
@@ -196,10 +196,10 @@ size_t          smb_share_list(smb_session_t *s, char ***list)
   smb_message_set_default_flags(req);
   req->packet->header.tid = ipc_tid;
 
-  smb_message_advance(req, sizeof(smb_trans_req_t));
-  trans = (smb_trans_req_t *)req->packet->payload;
+  smb_message_advance(req, sizeof(smb_trans_req));
+  trans = (smb_trans_req *)req->packet->payload;
 
-  memset((void *)trans, 0, sizeof(smb_trans_req_t));
+  memset((void *)trans, 0, sizeof(smb_trans_req));
 
   rpc_len = NETBIOS_SESSION_PAYLOAD - 256; // XXX
 
@@ -270,10 +270,10 @@ size_t          smb_share_list(smb_session_t *s, char ***list)
   smb_message_set_default_flags(req);
   req->packet->header.tid = ipc_tid;
 
-  smb_message_advance(req, sizeof(smb_trans_req_t));
-  trans = (smb_trans_req_t *)req->packet->payload;
+  smb_message_advance(req, sizeof(smb_trans_req));
+  trans = (smb_trans_req *)req->packet->payload;
 
-  memset((void *)trans, 0, sizeof(smb_trans_req_t));
+  memset((void *)trans, 0, sizeof(smb_trans_req));
 
   trans->wct              = 16;
   trans->max_data_count   = 4280;
@@ -320,7 +320,7 @@ size_t          smb_share_list(smb_session_t *s, char ***list)
   smb_message_put32(req, 0);            // Resume ?
 
   // Sets length values
-  trans->bct              = req->cursor - sizeof(smb_trans_req_t);
+  trans->bct              = req->cursor - sizeof(smb_trans_req);
   trans->data_count       = trans->bct - 17; // 17 -> padding + \PIPE\ + padding
   trans->total_data_count = trans->data_count;
   trans->data_offset      = trans->data_count - 4;

+ 5 - 5
src/smb_stat.c

@@ -21,14 +21,14 @@
 #include "bdsm/smb_stat.h"
 #include "bdsm/smb_fd.h"
 
-smb_stat_t        smb_stat_fd(smb_session_t *s, smb_fd fd)
+smb_stat        smb_stat_fd(smb_session *s, smb_fd fd)
 {
   assert (s != NULL && fd);
 
   return (smb_session_file_get(s, fd));
 }
 
-size_t            smb_stat_list_count(smb_stat_list_t list)
+size_t            smb_stat_list_count(smb_stat_list list)
 {
   size_t          count = 0;
 
@@ -41,7 +41,7 @@ size_t            smb_stat_list_count(smb_stat_list_t list)
   return (count);
 }
 
-smb_stat_t        smb_stat_list_at(smb_stat_list_t list, size_t index)
+smb_stat        smb_stat_list_at(smb_stat_list list, size_t index)
 {
   size_t          pos;
 
@@ -54,7 +54,7 @@ smb_stat_t        smb_stat_list_at(smb_stat_list_t list, size_t index)
   return (list);
 }
 
-const char        *smb_stat_name(smb_stat_t info)
+const char        *smb_stat_name(smb_stat info)
 {
   if (info == NULL)
     return (NULL);
@@ -62,7 +62,7 @@ const char        *smb_stat_name(smb_stat_t info)
     return (info->name);
 }
 
-uint64_t          smb_stat_get(smb_stat_t info, int what)
+uint64_t          smb_stat_get(smb_stat info, int what)
 {
   if (info == NULL)
     return (0);

+ 44 - 44
src/smb_trans2.c

@@ -25,29 +25,29 @@
 #include "bdsm/smb_utils.h"
 #include "bdsm/smb_stat.h"
 
-static smb_file_t *smb_find_parse(smb_message_t *msg)
+static smb_file *smb_find_parse(smb_message *msg)
 {
-  smb_trans2_resp_t       *tr2;
-  smb_tr2_find2_params_t  *params;
-  smb_tr2_find2_entry_t   *iter;
-  smb_file_t              *files, *tmp;
+  smb_trans2_resp       *tr2;
+  smb_tr2_find2_params  *params;
+  smb_tr2_find2_entry   *iter;
+  smb_file              *files, *tmp;
   uint8_t                 *eod;
   size_t                  count, i;
 
   assert(msg != NULL);
 
   // Let's parse the answer we got from server
-  tr2     = (smb_trans2_resp_t *)msg->packet->payload;
-  params  = (smb_tr2_find2_params_t *)tr2->payload;
-  iter    = (smb_tr2_find2_entry_t *)(tr2->payload + sizeof(smb_tr2_find2_params_t));
+  tr2     = (smb_trans2_resp *)msg->packet->payload;
+  params  = (smb_tr2_find2_params *)tr2->payload;
+  iter    = (smb_tr2_find2_entry *)(tr2->payload + sizeof(smb_tr2_find2_params));
   eod     = msg->packet->payload + msg->payload_size;
   count   = params->count;
   files   = NULL;
 
   for(i = 0; i < count && (uint8_t *)iter < eod; i++)
   {
-    // Create a smb_file_t and fill it
-    tmp = calloc(1, sizeof(smb_file_t));
+    // Create a smb_file and fill it
+    tmp = calloc(1, sizeof(smb_file));
     assert(tmp != NULL);
 
     tmp->name_len = smb_from_utf16((const char *)iter->name, iter->name_len,
@@ -66,23 +66,23 @@ static smb_file_t *smb_find_parse(smb_message_t *msg)
     tmp->next = files;
     files     = tmp;
 
-    iter = (smb_tr2_find2_entry_t *)(((char *)iter) + iter->next_entry);
+    iter = (smb_tr2_find2_entry *)(((char *)iter) + iter->next_entry);
   }
 
   return (files);
 }
 
-static smb_message_t *smb_tr2_recv(smb_session_t *s)
+static smb_message *smb_tr2_recv(smb_session *s)
 {
-  smb_message_t           recv, *res;
-  smb_trans2_resp_t       *tr2;
+  smb_message           recv, *res;
+  smb_trans2_resp       *tr2;
   size_t                  growth;
   int                     remaining;
 
   if (!smb_session_recv_msg(s, &recv))
     return (NULL);
 
-  tr2         = (smb_trans2_resp_t *)recv.packet->payload;
+  tr2         = (smb_trans2_resp *)recv.packet->payload;
   growth      = tr2->total_data_count - tr2->data_count;
   res         = smb_message_grow(&recv, growth);
   res->cursor = recv.payload_size;
@@ -94,7 +94,7 @@ static smb_message_t *smb_tr2_recv(smb_session_t *s)
     remaining = smb_session_recv_msg(s, &recv);
     if (remaining)
     {
-      tr2   = (smb_trans2_resp_t *)recv.packet->payload;
+      tr2   = (smb_trans2_resp *)recv.packet->payload;
       smb_message_append(res, tr2->payload + 2 /*pad*/, tr2->data_count);
       remaining = (int)tr2->total_data_count -
                   (tr2->data_displacement + tr2->data_count);
@@ -104,27 +104,27 @@ static smb_message_t *smb_tr2_recv(smb_session_t *s)
   return (res);
 }
 
-smb_file_t  *smb_find(smb_session_t *s, smb_tid tid, const char *pattern)
+smb_file  *smb_find(smb_session *s, smb_tid tid, const char *pattern)
 {
-  smb_message_t           *msg;
-  smb_trans2_req_t        *tr2;
-  smb_tr2_find2_t         *find;
+  smb_message           *msg;
+  smb_trans2_req        *tr2;
+  smb_tr2_find2         *find;
   size_t                  pattern_len, msg_len;
   int                     res;
 
   assert(s != NULL && pattern != NULL && tid);
 
   pattern_len = strlen(pattern) + 1;
-  msg_len     = sizeof(smb_trans2_req_t) + sizeof(smb_tr2_find2_t);
+  msg_len     = sizeof(smb_trans2_req) + sizeof(smb_tr2_find2);
   msg_len    += pattern_len * 2 + 3;
 
   msg = smb_message_new(SMB_CMD_TRANS2, msg_len);
   smb_message_set_default_flags(msg);
   msg->packet->header.tid = tid;
 
-  tr2 = (smb_trans2_req_t *)msg->packet->payload;
+  tr2 = (smb_trans2_req *)msg->packet->payload;
   tr2->wct                = 15;
-  tr2->total_param_count  = pattern_len * 2 + sizeof(smb_tr2_find2_t);
+  tr2->total_param_count  = pattern_len * 2 + sizeof(smb_tr2_find2);
   tr2->max_param_count    = 10; // ?? Why not the same or 12 ?
   tr2->max_data_count     = 0xffff;
   tr2->param_count        = tr2->total_param_count;
@@ -133,16 +133,16 @@ smb_file_t  *smb_find(smb_session_t *s, smb_tid tid, const char *pattern)
   tr2->data_offset        = 88; // Offset of pattern in packet
   tr2->setup_count        = 1;
   tr2->cmd                = SMB_TR2_FIND_FIRST;
-  tr2->bct                = sizeof(smb_tr2_find2_t) + pattern_len * 2 + 3;
+  tr2->bct                = sizeof(smb_tr2_find2) + pattern_len * 2 + 3;
 
-  find = (smb_tr2_find2_t *) tr2->payload;
+  find = (smb_tr2_find2 *) tr2->payload;
   find->attrs     = SMB_FIND2_ATTR_DEFAULT;
   find->count     = 1366;     // ??
   find->flags     = SMB_FIND2_FLAG_DEFAULT;
   find->interest  = 0x0104;   // 'Find file both directory info'
 
-  smb_message_advance(msg, sizeof(smb_trans2_req_t));
-  smb_message_advance(msg, sizeof(smb_tr2_find2_t));
+  smb_message_advance(msg, sizeof(smb_trans2_req));
+  smb_message_advance(msg, sizeof(smb_tr2_find2));
   smb_message_put_utf16(msg, "", pattern, pattern_len);
 
   // Adds padding at the end if necessary.
@@ -164,30 +164,30 @@ smb_file_t  *smb_find(smb_session_t *s, smb_tid tid, const char *pattern)
 }
 
 
-smb_file_t  *smb_stat(smb_session_t *s, smb_tid tid, const char *path)
+smb_file  *smb_fstat(smb_session *s, smb_tid tid, const char *path)
 {
-  smb_message_t           *msg, reply;
-  smb_trans2_req_t        *tr2;
-  smb_trans2_resp_t       *tr2_resp;
-  smb_tr2_query_t         *query;
-  smb_tr2_path_info_t     *info;
-  smb_file_t              *file;
+  smb_message           *msg, reply;
+  smb_trans2_req        *tr2;
+  smb_trans2_resp       *tr2_resp;
+  smb_tr2_query         *query;
+  smb_tr2_path_info     *info;
+  smb_file              *file;
   size_t                  path_len, msg_len;
   int                     res;
 
   assert(s != NULL && path != NULL && tid);
 
   path_len  = strlen(path) + 1;
-  msg_len   = sizeof(smb_trans2_req_t) + sizeof(smb_tr2_query_t);
+  msg_len   = sizeof(smb_trans2_req) + sizeof(smb_tr2_query);
   msg_len  += path_len * 2 + 3; // +3 for eventual padding
 
   msg = smb_message_new(SMB_CMD_TRANS2, msg_len);
   smb_message_set_default_flags(msg);
   msg->packet->header.tid = tid;
 
-  tr2 = (smb_trans2_req_t *)msg->packet->payload;
+  tr2 = (smb_trans2_req *)msg->packet->payload;
   tr2->wct                = 15;
-  tr2->total_param_count  = path_len * 2 + sizeof(smb_tr2_query_t);
+  tr2->total_param_count  = path_len * 2 + sizeof(smb_tr2_query);
   tr2->max_param_count    = 2; // ?? Why not the same or 12 ?
   tr2->max_data_count     = 0xffff;
   tr2->param_count        = tr2->total_param_count;
@@ -196,13 +196,13 @@ smb_file_t  *smb_stat(smb_session_t *s, smb_tid tid, const char *path)
   tr2->data_offset        = 96; // Offset of pattern in packet
   tr2->setup_count        = 1;
   tr2->cmd                = SMB_TR2_QUERY_PATH;
-  tr2->bct                = sizeof(smb_tr2_query_t) + path_len * 2 + 3;
+  tr2->bct                = sizeof(smb_tr2_query) + path_len * 2 + 3;
 
-  query = (smb_tr2_query_t *)tr2->payload;
+  query = (smb_tr2_query *)tr2->payload;
   query->interest   = 0x0107;   // Query File All Info
 
-  smb_message_advance(msg, sizeof(smb_trans2_req_t));
-  smb_message_advance(msg, sizeof(smb_tr2_query_t));
+  smb_message_advance(msg, sizeof(smb_trans2_req));
+  smb_message_advance(msg, sizeof(smb_tr2_query));
   smb_message_put_utf16(msg, "", path, path_len);
 
   // Adds padding at the end if necessary.
@@ -229,9 +229,9 @@ smb_file_t  *smb_stat(smb_session_t *s, smb_tid tid, const char *path)
     return (NULL);
   }
 
-  tr2_resp  = (smb_trans2_resp_t *)reply.packet->payload;
-  info      = (smb_tr2_path_info_t *)(tr2_resp->payload + 4); //+4 is padding
-  file      = calloc(1, sizeof(smb_file_t));
+  tr2_resp  = (smb_trans2_resp *)reply.packet->payload;
+  info      = (smb_tr2_path_info *)(tr2_resp->payload + 4); //+4 is padding
+  file      = calloc(1, sizeof(smb_file));
   assert(file != NULL);
 
   file->name_len  = smb_from_utf16((const char *)info->name, info->name_len,