Moved sockaddr_address_data to serve.c and renamed params.h to serve.h

This commit is contained in:
Alex Young
2012-06-06 10:45:07 +01:00
parent cc97dd4842
commit a80c5ce6b5
6 changed files with 17 additions and 18 deletions

View File

@@ -25,7 +25,7 @@
* client code to be found in remote.c
*/
#include "params.h"
#include "serve.h"
#include "util.h"
#include "ioutil.h"
#include "parse.h"

View File

@@ -19,7 +19,7 @@
* elsewhere in the program.
*/
#include "params.h"
#include "serve.h"
#include "util.h"
#include <stdio.h>

View File

@@ -2,7 +2,7 @@
#define __IOUTIL_H
#include "params.h"
#include "serve.h"
/** Returns a bit field representing which blocks are allocated in file
* descriptor ''fd''. You must supply the size, and the resolution at which

View File

@@ -1,7 +1,7 @@
#include "nbdtypes.h"
#include "ioutil.h"
#include "util.h"
#include "params.h"
#include "serve.h"
#include <stdlib.h>
#include <string.h>

View File

@@ -1,4 +1,4 @@
#include "params.h"
#include "serve.h"
#include "nbdtypes.h"
#include "ioutil.h"
#include "util.h"
@@ -20,6 +20,18 @@
static const int block_allocation_resolution = 4096;//128<<10;
static inline void* sockaddr_address_data(struct sockaddr* sockaddr)
{
struct sockaddr_in* in = (struct sockaddr_in*) sockaddr;
struct sockaddr_in6* in6 = (struct sockaddr_in6*) sockaddr;
if (sockaddr->sa_family == AF_INET)
return &in->sin_addr;
if (sockaddr->sa_family == AF_INET6)
return &in6->sin6_addr;
return NULL;
}
static inline void dirty(struct server *serve, off64_t from, int len)
{
if (serve->mirror)

View File

@@ -97,18 +97,5 @@ struct client_params {
struct server* serve; /* FIXME: remove above duplication */
};
/* FIXME: wrong place */
static inline void* sockaddr_address_data(struct sockaddr* sockaddr)
{
struct sockaddr_in* in = (struct sockaddr_in*) sockaddr;
struct sockaddr_in6* in6 = (struct sockaddr_in6*) sockaddr;
if (sockaddr->sa_family == AF_INET)
return &in->sin_addr;
if (sockaddr->sa_family == AF_INET6)
return &in6->sin6_addr;
return NULL;
}
#endif